FIX: skip hidden nodes when converting from HTML to Markdown
This commit is contained in:
parent
09cb61b533
commit
c8044c6956
|
@ -37,6 +37,8 @@ class HtmlToMarkdown
|
|||
end
|
||||
|
||||
def visit(node)
|
||||
return if node["style"] && node["style"][/display[[:space:]]*:[[:space:]]*none/]
|
||||
|
||||
if node.description&.block? && node.parent&.description&.block? && @stack[-1].markdown.size > 0
|
||||
block = @stack[-1].dup
|
||||
@markdown << format_block
|
||||
|
|
|
@ -21,6 +21,10 @@ describe HtmlToMarkdown do
|
|||
)).to eq("Hello,\n\nThis is the 1st paragraph.\n\nThis is another paragraph")
|
||||
end
|
||||
|
||||
it "skips hidden tags" do
|
||||
expect(html_to_markdown(%Q{<p>Hello <span style="display: none">cruel </span>World!</p>})).to eq("Hello World!")
|
||||
end
|
||||
|
||||
it "converts <strong>" do
|
||||
expect(html_to_markdown("<strong>Strong</strong>")).to eq("**Strong**")
|
||||
expect(html_to_markdown("<strong>Str*ng</strong>")).to eq("__Str*ng__")
|
||||
|
|
Loading…
Reference in New Issue