nea / MarkdownViewerPlusPlus

A Notepad++ Plugin to view a Markdown file rendered on-the-fly
MIT License
1.19k stars 141 forks source link

Numbered lists have unwanted line feed / carriage control after the number. #162

Open bwims opened 4 months ago

bwims commented 4 months ago

Issue description

Numbered lists have line breaks after the numbers

Markdown to reproduce

1. **Basic Shed with Insulation:**
   - **Size:** Small (6x4 ft to 8x6 ft)
   - **Cost:** £1,500 to £3,000
   - **Details:** Includes basic insulation, simple interior finishes, and no additional services like electricity or plumbing.

2. **Standard Garden Office:**
   - **Size:** Medium (10x8 ft to 12x10 ft)
   - **Cost:** £5,000 to £10,000
   - **Details:** Better quality insulation, basic interior finishes, electricity, and potentially some heating solutions.

3. **High-End Garden Studio/Office:**
   - **Size:** Large (12x10 ft to 20x12 ft)
   - **Cost:** £10,000 to £25,000+
   - **Details:** High-quality insulation, premium interior finishes, full electrics, heating, double-glazed windows, and possibly plumbing for water supply and drainage.

Screenshot

This is what the VSCode preview shows ( I believe correctly)

image

This is what MarkdownViewerPlusPlus displays (I believe incorrectly

image

Environment

alcoolfire commented 1 month ago

I am experiencing the same problem, but it doesn't matter if it is a numbered or bulleted list. The bug is triggered only when there is at least one blank line between at least one adjacent pair of list items, a so-called "loose" list. The bug is not triggered for "tight" lists. So, this tight list markdown will render correctly in MarkdownViewer++:

- first
- second
- third

but this loose list will not:

- first

- second
- third

and neither will this loose list:

- first

- second

- third

The CommonMark list spec seems clear to me:

A list is a sequence of one or more list items of the same type. The list items may be separated by any number of blank lines.

Markdown source is supposed to be relatively human-friendly, which is why loose lists are permitted and used by many people. Nothing in the markdown specs that I've found should ever lead to a line break being inserted between a list marker and its associated text.

Notepad++ v7.9.2 and MarkdownViewer++ v0.8.2.25525

alcoolfire commented 1 month ago

The CommonMark spec Example 306 shows the HTML to be generated for loose lists, which follows. It is the addition of the <p> tags that are used for loose lists:

<ul>
<li>
<p>foo</p>
</li>
<li>
<p>bar</p>
</li>
<li>
<p>baz</p>
</li>
</ul>

Try that in a mainstream web browser. Courtesy of GitHub markdown support, the following should show the result in whatever browser one happens to be viewing this bug report with:

  • foo

  • bar

  • baz

Then paste that very same block of HTML into a markdown file for MarkdownViewer++ to render and one will see it rendered incorrectly (line break between list markers and text). I think this suggests a bug in the embedded HTML renderer in MarkdownViewer++ rather than in the markdown-to-HTML conversion stage.