@@ -6,10 +6,42 @@ const ETX = '\x03' # ASCII control character: End of Text
6
6
const DEFAULT_STYLE = :folded
7
7
const DEFAULT_CHOMP = :strip
8
8
9
+ """
10
+ block(str, style=$(repr (DEFAULT_STYLE)) , chomp=$(repr (DEFAULT_CHOMP)) ) -> AbstractString
11
+
12
+ Revise a multiline string according to the provided `style` and `chomp`. Works similarly to
13
+ YAML multiline strings (also known as block scalars).
14
+
15
+ # Arguments
16
+ - `str::AbstractString`: The multiline string to be processed
17
+
18
+ # Keywords
19
+ - `style::Symbol`: Replace newlines with spaces (`:folded`) or keep newlines (`:literal`)
20
+ - `chomp::Symbol`: No newlines at the end (`:strip`), single newline at the end (`:clip`),
21
+ or keep all newlines from the end (`:keep`)
22
+ """
9
23
function block (str:: AbstractString ; style= DEFAULT_STYLE, chomp= DEFAULT_CHOMP)
10
24
block (str, style, chomp)
11
25
end
12
26
27
+ """
28
+ block(str, indicators) -> AbstractString
29
+
30
+ Revise a multiline string according to the provided style and chomp encoded in the
31
+ `indicators` string.
32
+
33
+ # Arguments
34
+ - `str::AbstractString`: The multiline string to be processed
35
+ - `indicators::AbstractString`: A terse string representing the style and chomp. Indicators
36
+ can be either in letter-form or in YAML-form:
37
+
38
+ - "fs" / ">-": folded and strip
39
+ - "fc" / ">": folded and clip
40
+ - "fk" / ">+": folded and keep
41
+ - "ls" / "|-": literal and strip
42
+ - "lc" / "|": literal and clip
43
+ - "lk" / "|+": literal and keep
44
+ """
13
45
function block (str:: AbstractString , indicators:: AbstractString )
14
46
indicators_len = length (indicators)
15
47
indicators_len > 2 && throw (ArgumentError (" Too many indicators provided" ))
@@ -145,6 +177,20 @@ function block(str::AbstractString, style::Symbol, chomp::Symbol)
145
177
return String (take! (out))
146
178
end
147
179
180
+ """
181
+ @blk_str -> String
182
+
183
+ Construct a multiline string according to the indicators listed after the ending quote:
184
+
185
+ - `f` replace newlines with spaces (folded)
186
+ - `l` keep newlines (literal)
187
+ - `s` no newlines at the end (strip)
188
+ - `c` single newline at the end (clip)
189
+ - `k` keep all newlines from the end (keep)
190
+
191
+ Note string interpolation is still respected any newlines added from interpolation will be
192
+ also be processed.
193
+ """
148
194
macro blk_str (str:: AbstractString , indicators:: AbstractString = " " )
149
195
parsed = interpolate (str)
150
196
0 commit comments