@@ -13,8 +13,20 @@ export
1313
1414# -----------------------------------------------------------------------------# escape/unescape
1515const 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
1830
1931# -----------------------------------------------------------------------------# NodeType
2032"""
137149Node (o:: Node ; kw... ) = isempty (kw) ? o : Node ((get (kw, x, getfield (o, x)) for x in fieldnames (Node)). .. )
138150
139151function 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
141156 c = XML. children (node)
142157 Node (nodetype, tag, attributes, value, isempty (c) ? nothing : map (Node, c))
143158end
0 commit comments