Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Julia 1.6 #16

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <emailjoshday@gmail.com> 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
Loading