Skip to content

Commit fc5bb64

Browse files
committed
Fix issue with import of code containing '<'
This fixes the problem that all code from an opening angle bracket through to the next closing bracket or the end of the code element is lost at import, since Nokogiri::XML::Node#replace interprets the bracket as the start of an HTML tag. By instead using the content= method the new content string gets XML escaped.
1 parent 60c9dc1 commit fc5bb64

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ def html_to_markdown(content_div)
8484

8585
# map all code elements to their inner_text
8686
pre.search('code').each do |code|
87-
code.replace(highlight(code_to_text(code), lang))
87+
code.content = highlight(code_to_text(code), lang)
8888
end
8989
end
9090

9191
# map all code elements to their inner_text
9292
content_div.search('pre > code').each do |code|
93-
code.replace(code_to_text(code))
93+
code.content = code_to_text(code)
9494
end
9595

9696
# remove the 'class' attribute from all pre tags

0 commit comments

Comments
 (0)