5
6
7
8
9
10
11
12
13
14
|
# File 'lib/action_text_syntax_highlighter/pre_tags_to_highlighted_code_blocks_conversion.rb', line 5
def convert_pre_tags_to_highlighted_code_blocks
@document = Nokogiri::HTML::DocumentFragment.parse(body.to_html)
@document.css("pre").each do |node|
code_block_content = sanitizer.sanitize node.inner_html
code_block = ActionTextSyntaxHighlighter::HighlightedCodeBlock.create(content: code_block_content)
node.swap attachment_node_for(code_block)
end
update(body: @document.to_s)
end
|