Skip to content

Commit

Permalink
Merge pull request #16 from IHPSystems/feature/julia_1.6
Browse files Browse the repository at this point in the history
Add support for Julia 1.6
  • Loading branch information
joshday authored Aug 28, 2023
2 parents 143c2b2 + de00f35 commit a1e739b
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 <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

2 comments on commit a1e739b

@joshday
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/90573

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" a1e739b456d3efe7952b9a2acc52d09698637b4c
git push origin v0.3.1

Please sign in to comment.