Skip to content

Commit

Permalink
Merge pull request #47 from essenciary/patch-1
Browse files Browse the repository at this point in the history
Fix for incorrect parsing of custom html elements
  • Loading branch information
porterjamesj authored Jun 1, 2018
2 parents e28b25e + fca3538 commit 4d6f329
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function elem_tag(ge::CGumbo.Element)
tag = CGumbo.TAGS[ge.tag+1] # +1 is for 1-based julia indexing
if tag == :unknown
ot = ge.original_tag
tag = unsafe_string(ot.data, ot.length)[2:end-1] |> Symbol
tag = split(unsafe_string(ot.data, ot.length)[2:end-1])[1] |> Symbol
end
tag
end
Expand Down
9 changes: 9 additions & 0 deletions test/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ let
page = parsehtml("<weird></weird")
@test tag(page.root[2][1]) == :weird
end


# test that non-standard tags, with attributes, are parsed correctly

let
page = Gumbo.parsehtml("<my-element cool></my-element>")
@test tag(page.root[2][1]) == Symbol("my-element")
@test Gumbo.attrs(page.root[2][1]) == Dict("cool" => "")
end

0 comments on commit 4d6f329

Please sign in to comment.