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

fix: HTML4::Document.to_xhtml self-closing tags (v1.12.x) #2327

Merged
merged 1 commit into from Sep 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nokogiri/xml/node/save_options.rb
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
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