Skip to content

Commit 9a15a9d

Browse files
committed
Code review changes
1 parent 393d0d7 commit 9a15a9d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Tooling for manipulating multiline strings.
1010

1111
## Features
1212

13-
The package features the `@m_str` macro, inspired from [YAML's block scalars](https://yaml-multiline.info/), which provide options for manipulating multiline strings via a style and chomp indicator:
13+
The package features a multiline string literal (`@m_str`), inspired from [YAML's block scalars](https://yaml-multiline.info/), which provide options for manipulating multiline string literals via a style and chomp indicator:
1414

1515
- Style indicator:
1616
- `f` replace newlines with spaces (folded)
@@ -52,3 +52,5 @@ to this function doesn't contain magic that may interfere with
5252
with the non-magical computation occurring on this device.
5353
"""
5454
```
55+
56+
Take note that a Julia [triple-quoted string literal](https://docs.julialang.org/en/v1/manual/strings/#Triple-Quoted-String-Literals) will leave most newlines in place.

src/MultilineStrings.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ function multiline(str::AbstractString, style::Symbol, chomp::Symbol)
104104

105105
# Replace newlines with spaces (folded)
106106
if style === :folded
107-
# The code below is equivalent to these two regexes:
107+
# The code below is equivalent to these two regexes (the non-regex code has much
108+
# better performance):
108109
# ```
109110
# str = replace(str, r"(?<=\S)\n(?=\S)" => " ")
110111
# str = replace(str, r"(?<=\n)\n(?=\S)" => "")
@@ -180,17 +181,19 @@ end
180181
"""
181182
@m_str -> String
182183
183-
Construct a multiline string according to a style and chomp indicators (provided after the
184-
ending quote):
184+
Manipulate a multiline string literal according to a style and chomp indicator (provided
185+
after the ending quote):
185186
186187
- Style indicator:
187-
- `f` replace newlines with spaces (folded)
188+
- `f` replace newlines with spaces (folded, default)
188189
- `l` keep newlines (literal)
189190
- Chomp indicator:
190-
- `s` no newlines at the end (strip)
191+
- `s` no newlines at the end (strip, default)
191192
- `c` single newline at the end (clip)
192193
- `k` keep all newlines from the end (keep)
193194
195+
If both a style and chomp indicator is provided the style indicator must be specified first.
196+
194197
Note string interpolation is still respected any newlines added from interpolation will be
195198
also be processed.
196199

0 commit comments

Comments
 (0)