webtrees icon indicating copy to clipboard operation
webtrees copied to clipboard

markdown pre-formatted - ``` - is rendered as a single line

Open poulhs opened this issue 3 years ago • 4 comments

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>

poulhs avatar Jun 30 '23 19:06 poulhs

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.

Image Image

BertKoor avatar Jan 22 '26 11:01 BertKoor

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.

Image

Those <br> tags are not expected. Image

BertKoor avatar Jan 22 '26 11:01 BertKoor

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.

BertKoor avatar Jan 22 '26 12:01 BertKoor

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.

fisharebest avatar Jan 22 '26 17:01 fisharebest