A platform for community discussion. Free, open, simple.
FIX: Inline error when converting html to markdown
Blake Ericksona89574ccb9fb
diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rbindex 448a0cd7257..d2fb51f34c8 100644--- a/lib/html_to_markdown.rb+++ b/lib/html_to_markdown.rb@@ -99,7 +99,7 @@ class HtmlToMarkdownenddef is_inline?(node)- node.text? || ("br" != node.name && node.description.inline? && node.children.all? { |n| is_inline?(n) })+ node.text? || ("br" != node.name && node.description&.inline? && node.children.all? { |n| is_inline?(n) })enddef collapse_spaces!(nodes, was_space = true)diff --git a/spec/components/html_to_markdown_spec.rb b/spec/components/html_to_markdown_spec.rbindex 3d19c66f9a2..0fde6eaa12b 100644--- a/spec/components/html_to_markdown_spec.rb+++ b/spec/components/html_to_markdown_spec.rb@@ -65,6 +65,23 @@ describe HtmlToMarkdown doexpect(html_to_markdown(html)).to eq(markdown.strip)end+ it "doesn't error on non-inline elements like (aside, section)" do++ html = <<~HTML+ <aside class="quote no-group">+ <blockquote>+ <p>hello.</p>+ </blockquote>+ </aside>+ HTML++ markdown = <<~MD+ > hello.+ MD++ expect(html_to_markdown(html)).to eq(markdown.strip)+ end+it "skips hidden tags" doexpect(html_to_markdown(%Q{<p>Hello <span style="display: none">cruel </span>World!</p>})).to eq("Hello World!")expect(html_to_markdown(%Q{<p>Hello <span hidden>cruel </span>World!</p>})).to eq("Hello World!")