markdown pre-formatted - ``` - is rendered as a single line
Forum: Issue with rendering markdown of formated text in NOTE
Using markdown and ``` to mark text as pre-formatted is wrongly rendered as one single line.
A note containing
``` a b ```
is expected to be rendered as two lines
a b
and not as a single line:
ab
The data presented in the GEDCOM view is correct:
1 BIRT 2 DATE 01 JAN 1850 2 NOTE Markdown 3 CONT 3 CONT
3 CONT a 3 CONT b 3 CONT
but the HTML is incorrect:
<td class> <div class="mb-2"> <p><em>Markdown</em></p><pre><code>ab</code></pre> </div> </td>
I noticed the reverse is also true. Multiple lines which should be part of the same paragraph in regular text are rendered on separate lines.
Our MarkdownFactory removes newlines, git blames "fix #4402". https://github.com/fisharebest/webtrees/blob/main/app/Factories/MarkdownFactory.php#L139 If that processing step is omitted, then code blocks work somewhat better.
Those <br> tags are not expected.
Those
<br>tags are not expected.
Well yes, the commonmark environment we create contains 'soft_break' => '<br/>' so this deviation from plain markdown / commonmark seems to be on purpose.
Well yes, the commonmark environment we create contains 'soft_break' => '
' so this deviation from plain markdown / commonmark seems to be on purpose.
IIRC, the markdown spec gives you a choice with newlines. Either they can introduce a line-break - or they can be ignored.
We chose to add a line break, as that seems to be what most people expect.