@@ -13,8 +13,20 @@ export
13
13
14
14
# -----------------------------------------------------------------------------# escape/unescape
15
15
const escape_chars = (' &' => " &" , ' <' => " <" , ' >' => " >" , " '" => " '" , ' "' => " "" )
16
- unescape (x:: AbstractString ) = replace (x, reverse .(escape_chars)... )
17
- escape (x:: String ) = replace (x, r" &(?=\s )" => " &" , escape_chars[2 : end ]. .. )
16
+ function unescape (x:: AbstractString )
17
+ result = x
18
+ for (pat, r) in reverse .(escape_chars)
19
+ result = replace (result, pat => r)
20
+ end
21
+ return result
22
+ end
23
+ function escape (x:: String )
24
+ result = replace (x, r" &(?=\s )" => " &" )
25
+ for (pat, r) in escape_chars[2 : end ]
26
+ result = replace (result, pat => r)
27
+ end
28
+ return result
29
+ end
18
30
19
31
# -----------------------------------------------------------------------------# NodeType
20
32
"""
137
149
Node (o:: Node ; kw... ) = isempty (kw) ? o : Node ((get (kw, x, getfield (o, x)) for x in fieldnames (Node)). .. )
138
150
139
151
function Node (node:: LazyNode )
140
- (;nodetype, tag, attributes, value) = node
152
+ nodetype = node. nodetype
153
+ tag = node. tag
154
+ attributes = node. attributes
155
+ value = node. value
141
156
c = XML. children (node)
142
157
Node (nodetype, tag, attributes, value, isempty (c) ? nothing : map (Node, c))
143
158
end
0 commit comments