Switch to fenced code blocks in markdown

`:fenced_code_blocks:` Blocks delimited with 3 or more ~ or backticks will be considered as code, without the need to be indented. An optional language name may be added at the end of the opening fence for the code block.

`:disable_indented_code_blocks:` Do not parse usual markdown code blocks. Markdown converts text with four spaces at the front of each line to code blocks. This option prevents it from doing so. Recommended to use with fenced_code_blocks: true.

Fixes #2764
This commit is contained in:
Henne Vogelsang 2021-07-05 21:56:25 +02:00
parent 0dd433fac1
commit 2c520d9975
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
2 changed files with 6 additions and 4 deletions

View file

@ -191,9 +191,11 @@ module FormatHelper
return '' if text.nil?
options = {
autolink: true,
space_after_headers: true,
no_intra_emphasis: true
autolink: true,
space_after_headers: true,
no_intra_emphasis: true,
fenced_code_blocks: true,
disable_indented_code_blocks: true
}
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options)
markdown.render(text).html_safe