Skip to content

Commit

Permalink
Add support for Julia 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
stemann committed Aug 21, 2023
1 parent 143c2b2 commit de00f35
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia
- 'nightly'
os:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name = "XML"
uuid = "72c71f33-b9b6-44de-8c94-c961784809e2"
authors = ["Josh Day <[email protected]> and contributors"]
version = "0.3.0"
version = "0.3.1"

[deps]
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"

[compat]
julia = "1.7"
OrderedCollections = "1.4, 1.5"
julia = "1.6"
21 changes: 18 additions & 3 deletions src/XML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ export

#-----------------------------------------------------------------------------# escape/unescape
const escape_chars = ('&' => "&amp;", '<' => "&lt;", '>' => "&gt;", "'" => "&apos;", '"' => "&quot;")
unescape(x::AbstractString) = replace(x, reverse.(escape_chars)...)
escape(x::String) = replace(x, r"&(?=\s)" => "&amp;", escape_chars[2:end]...)
function unescape(x::AbstractString)
result = x
for (pat, r) in reverse.(escape_chars)
result = replace(result, pat => r)
end
return result
end
function escape(x::String)
result = replace(x, r"&(?=\s)" => "&amp;")
for (pat, r) in escape_chars[2:end]
result = replace(result, pat => r)
end
return result
end

#-----------------------------------------------------------------------------# NodeType
"""
Expand Down Expand Up @@ -137,7 +149,10 @@ end
Node(o::Node; kw...) = isempty(kw) ? o : Node((get(kw, x, getfield(o, x)) for x in fieldnames(Node))...)

function Node(node::LazyNode)
(;nodetype, tag, attributes, value) = node
nodetype = node.nodetype
tag = node.tag
attributes = node.attributes
value = node.value
c = XML.children(node)
Node(nodetype, tag, attributes, value, isempty(c) ? nothing : map(Node, c))
end
Expand Down
8 changes: 6 additions & 2 deletions src/raw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ would visit nodes by reading top-down through an XML file. Not defined for `XML
"""
function next(o::Raw)
i = o.pos + o.len + 1
(; depth, data, type) = o
depth = o.depth
data = o.data
type = o.type
i = findnext(!isspace, data, i) # skip insignificant whitespace
isnothing(i) && return nothing
if type === RawElementOpen || type === RawDocument
Expand Down Expand Up @@ -294,7 +296,9 @@ end
Return the previous node in the document during depth-first traversal. Not defined for `XML.Node`.
"""
function prev(o::Raw)
(; depth, data, type) = o
depth = o.depth
data = o.data
type = o.type
type === RawDocument && return nothing
j = o.pos - 1
j = findprev(!isspace, data, j) # skip insignificant whitespace
Expand Down

0 comments on commit de00f35

Please sign in to comment.