Preserve newlines and indentation in <pre> tags from RSS import (#10922)
This commit is contained in:
parent
9377eee4f5
commit
52cf81624e
2 changed files with 7 additions and 1 deletions
|
|
@ -14,7 +14,7 @@ module ReverseMarkdown
|
|||
|
||||
def treat(node, state)
|
||||
case node.name
|
||||
when "code"
|
||||
when "code", "text"
|
||||
node.text
|
||||
when "br"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -24,5 +24,11 @@ RSpec.describe ReverseMarkdown::Converters::CustomPre, type: :lib do
|
|||
result = create_custom_pre.convert(node)
|
||||
expect(result.split[0]).to eq("```html")
|
||||
end
|
||||
|
||||
it "preserves newlines and indentation" do
|
||||
node = Nokogiri::HTML("<pre>def foo\n puts 'Hello World'<br>end</pre>").search("pre")[0]
|
||||
result = create_custom_pre.convert(node)
|
||||
expect(result).to eq("\n```\ndef foo\n puts 'Hello World'\nend\n```\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue