Skip to content

Commit 78add66

Browse files
committed
add info, tweak markdown format
1 parent 8cfb60e commit 78add66

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,48 @@ use Text::More :strip-comment;
2323
# the '#' is the default comment character
2424
my $line = " some text # a comment";
2525
$line = strip-comment $line;
26-
say $line # OUTPUT: « some text ␤»
26+
say $line; # OUTPUT: « some text ␤»
2727
```
28-
If you want to be fancier:
28+
If you want to be fancier, return the stripped line and its comment,
29+
bit normalized (trimmed of leading and trailing spaces, contiguous
30+
spaces collapsed to one):
2931

3032
```raku
3133
# define your own comment character(s)
3234
# save the comment and normalize the returned strings
3335
my ($line, $comm) = strip-comment $line, :mark<%%>, :save-comment, :normalize;
34-
say $line # OUTPUT: «some text␤»
35-
say $comm # OUTPUT: «a comment␤»
36+
say $line; # OUTPUT: «some text␤»
37+
say $comm; # OUTPUT: «a comment␤»
3638
```
37-
3839
The default behavior is to find the first comment character in the input
3940
string, but you may choose to start the search from the end of the
4041
input string:
4142

4243
```raku
4344
my $line = "text 1 # text 2 # comment";
4445
$line = strip-comment $line, :reverse;
45-
say $line # OUTPUT: «text 1 # text 2 ␤»
46+
say $line; # OUTPUT: «text 1 # text 2 ␤»
4647
```
47-
4848
Note that the routine is line oriented, so embedded newlines
4949
may give unexpected results:
50-
5150
```raku
5251
my $line = q:to/HERE/;
5352
text 1 # comment 1
5453
text 2 # comment 2
5554
HERE
5655
$line = strip-comment $line
57-
say $line # OUTPUT: «text 1 ␤»
56+
say $line; # OUTPUT: «text 1 ␤»
5857
```
59-
6058
## Installation
61-
6259
``` Raku
6360
zef install Text::Utils
6461
```
65-
6662
## Documentation
67-
6863
``` Raku
6964
zef install p6doc
7065
p6doc Text::Utils
7166
```
72-
7367
## See also
74-
7568
- `Text::Abbrev`
7669
- `Text::BorderedBlock`
7770
- `Text::Diff::Sift4`

0 commit comments

Comments
 (0)