Is this a bug or am I doing something wrong?
I have a markdown editor on a page, it has some code snippets etc. In the backoffice preview everything looks good.
So what happens in the Backoffice is that the raw markdown is parsed through a library called Marked, which transforms the ``` tags to pre+code live. It does not receive any pre-formatted HTML from the backend.
The frontend uses a .NET library called HeyRed.MarkdownSharp. This library does not seem to format with pre+code but only code tags. This library seems to be legacy and they refer to another library called Markdig. We ought to switch out that library, but changing the output format would be quite breaking.
I wonder if the best course of action for you at this moment is to override the markdown editor and use something like Markdig instead that is very extendable.
Could I persuade you to create this as an issue on the Github tracker, too, please? I think we either need to show the same preview in the Backoffice as would be created on the frontend, or at the very least ensure that the Backoffice converter and the frontend converter are configured similarly.
Great catch on the library discrepancy! I was wondering why my code blocks looked perfect in the preview but collapsed into a mess on the live site. It’s good to know there’s a PR (#21242) in the works to modernize this. In the meantime, re-parsing the source value with Markdig on the frontend seems like the cleanest way to keep things consistent.