Skip to content

Commit

Permalink
Merge pull request #2327 from sparklemotion/2324-xhtml-self-closing-t…
Browse files Browse the repository at this point in the history
…ags_v1.12.x

fix: HTML4::Document.to_xhtml self-closing tags (v1.12.x)
  • Loading branch information
flavorjones authored Sep 24, 2021
2 parents 564ac17 + a0180c7 commit 01e1618
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nokogiri/xml/node/save_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SaveOptions
DEFAULT_HTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
end
# the default for XHTML document
DEFAULT_XHTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_XHTML
DEFAULT_XHTML = FORMAT | NO_DECLARATION | AS_XHTML

# Integer representation of the SaveOptions
attr_reader :options
Expand Down
9 changes: 9 additions & 0 deletions test/html4/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ def test_to_xhtml
assert_match("UTF-8", html.to_xhtml(encoding: "UTF-8"))
end

def test_to_xhtml_self_closing_tags
# https://github.com/sparklemotion/nokogiri/issues/2324
html = "<html><body><br><table><colgroup><col>"
doc = Nokogiri::HTML::Document.parse(html)
xhtml = doc.to_xhtml
assert_match(%r(<br ?/>), xhtml)
assert_match(%r(<col ?/>), xhtml)
end

def test_no_xml_header
html = Nokogiri::HTML(<<~EOHTML)
<html>
Expand Down

0 comments on commit 01e1618

Please sign in to comment.