Skip to content

Commit d366e14

Browse files
committed
Fix Docs::Parse#document? when document has no doctype
1 parent 56d9398 commit d366e14

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lib/docs/core/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def html
1111
private
1212

1313
def document?
14-
@content =~ /\A\s*<!doctype/i
14+
@content =~ /\A\s*<(?:\!doctype|html)/i
1515
end
1616

1717
def parse_as_document

test/lib/docs/core/parser_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def parser(content)
2222
it "returns the <body>" do
2323
body = '<!doctype html><meta charset=utf-8><title></title><div>Test</div>'
2424
assert_equal '<div>Test</div>', parser(body).html.inner_html
25+
26+
body = '<html><meta charset=utf-8><title></title><div>Test</div></html>'
27+
assert_equal '<div>Test</div>', parser(body).html.inner_html
2528
end
2629
end
2730
end

0 commit comments

Comments
 (0)