@@ -10,6 +10,49 @@ function block(str::AbstractString; style=DEFAULT_STYLE, chomp=DEFAULT_CHOMP)
10
10
block (str, style, chomp)
11
11
end
12
12
13
+ function block (str:: AbstractString , indicators:: AbstractString )
14
+ indicators_len = length (indicators)
15
+ indicators_len > 2 && throw (ArgumentError (" Too many indicators provided" ))
16
+
17
+ # Note: Using '\0` to indicate undefined
18
+ style_char, chomp_char = if indicators_len == 2
19
+ indicators
20
+ elseif indicators_len == 1
21
+ ind = indicators[1 ]
22
+ if ind in " fl"
23
+ ind, ' \0 '
24
+ else
25
+ ' \0 ' , ind
26
+ end
27
+ else
28
+ ' \0 ' , ' \0 '
29
+ end
30
+
31
+ style = if style_char == ' f'
32
+ :folded
33
+ elseif style_char == ' l'
34
+ :literal
35
+ elseif style_char == ' \0 '
36
+ DEFAULT_STYLE
37
+ else
38
+ throw (ArgumentError (" Unknown block style indicator: $(repr (style_char)) " ))
39
+ end
40
+
41
+ chomp = if chomp_char == ' c'
42
+ :clip
43
+ elseif chomp_char == ' s'
44
+ :strip
45
+ elseif chomp_char == ' k'
46
+ :keep
47
+ elseif chomp_char == ' \0 '
48
+ DEFAULT_CHOMP
49
+ else
50
+ throw (ArgumentError (" Unknown block chomping indicator: $(repr (chomp_char)) " ))
51
+ end
52
+
53
+ return block (str, style, chomp)
54
+ end
55
+
13
56
function block (str:: AbstractString , style:: Symbol , chomp:: Symbol = DEFAULT_CHOMP)
14
57
# Append an additional, non-space, character to force one more iteration of the style
15
58
# loop
@@ -95,46 +138,7 @@ function block(str::AbstractString, style::Symbol, chomp::Symbol=DEFAULT_CHOMP)
95
138
end
96
139
97
140
macro blk_str (str:: AbstractString , indicators:: AbstractString = " " )
98
- indicators_len = length (indicators)
99
- indicators_len > 2 && throw (ArgumentError (" Too many indicators provided" ))
100
-
101
- # Note: Using '\0` to indicate undefined
102
- style_char, chomp_char = if indicators_len == 2
103
- indicators
104
- elseif indicators_len == 1
105
- ind = indicators[1 ]
106
- if ind in " fl"
107
- ind, ' \0 '
108
- else
109
- ' \0 ' , ind
110
- end
111
- else
112
- ' \0 ' , ' \0 '
113
- end
114
-
115
- style = if style_char == ' f'
116
- :folded
117
- elseif style_char == ' l'
118
- :literal
119
- elseif style_char == ' \0 '
120
- DEFAULT_STYLE
121
- else
122
- throw (ArgumentError (" Unknown block style indicator: $(repr (style_char)) " ))
123
- end
124
-
125
- chomp = if chomp_char == ' c'
126
- :clip
127
- elseif chomp_char == ' s'
128
- :strip
129
- elseif chomp_char == ' k'
130
- :keep
131
- elseif chomp_char == ' \0 '
132
- DEFAULT_CHOMP
133
- else
134
- throw (ArgumentError (" Unknown block chomping indicator: $(repr (chomp_char)) " ))
135
- end
136
-
137
- return block (str, style, chomp)
141
+ return block (str, indicators)
138
142
end
139
143
140
144
end
0 commit comments