diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index e7bb0743d0..251bb9bbe5 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -4,6 +4,16 @@ require 'singleton' require_relative './sanitize_config' 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) "
#{encode(code).gsub("\n", "
")}
" end