prevent lists from being parsed as markdown
This commit is contained in:
parent
723a4a76b8
commit
6280a7f3a3
|
@ -4,6 +4,16 @@ require 'singleton'
|
||||||
require_relative './sanitize_config'
|
require_relative './sanitize_config'
|
||||||
|
|
||||||
class HTMLRenderer < Redcarpet::Render::HTML
|
class HTMLRenderer < Redcarpet::Render::HTML
|
||||||
|
def preprocess(document)
|
||||||
|
# Prevent markdown lists from being parsed as markdown
|
||||||
|
# Rich text lists not only play with the formatting funny, but also get completely obliterated when federating
|
||||||
|
# to instances that don't do rich test
|
||||||
|
#
|
||||||
|
# This is a gross way to do it but I couldn't find anything better
|
||||||
|
# It simply finds anything at the start of a line that would be parsed as a list and escapes it with backslashes
|
||||||
|
document.gsub(/^(\s*)(-|\+|\*) /, '\1\\\\\2 ').gsub(/^(\s*\d+)\. /, '\1\. ')
|
||||||
|
end
|
||||||
|
|
||||||
def block_code(code, language)
|
def block_code(code, language)
|
||||||
"<pre><code>#{encode(code).gsub("\n", "<br/>")}</code></pre>"
|
"<pre><code>#{encode(code).gsub("\n", "<br/>")}</code></pre>"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue