Flarum: Strip `>` in front of code blocks
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 30 May 2022 10:09:00 +0000 (12:09 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Jun 2022 14:18:46 +0000 (16:18 +0200)
This avoids a rendering issue with Parsedown, which would strip the indentation
in the code block, possibly breaking YAML et al.

files/lib/system/exporter/Flarum1xExporter.class.php

index 13f8d8240c51296f5e02e85e99d041db2dd94766..c309d23832d67250a1f3f870a79cf81e5e6244a8 100644 (file)
@@ -710,6 +710,8 @@ final class Flarum1xExporter extends AbstractExporter
         // Unparser::unparse()
         $message = \html_entity_decode(\strip_tags($message), ENT_QUOTES, 'UTF-8');
 
+        $message = \preg_replace('/(^|\n)> (```)/', '\\1\\2', $message);
+
         $out = $parsedown->text($message);
 
         $out = \preg_replace(