2-spaces creates an indented UL, but OL needs 3-spaces #110

Closed
opened 2026-01-29 14:27:17 +00:00 by claunia · 2 comments
Owner

Originally created by @russau on GitHub (May 15, 2017).

Hi all,

I've discovered an issue with some markdown I'm converting. The unordered lists considers two-spaces an indent, yet the ordered lists need 3-spaces to indent.

I'll pulled the latest and written a test below. Is this the intended behavior? Playing with stackoverflow's stackedit I see two-spaces on a 1. treated as an indent.

Thanks,
Russ

// contains a nested list
var md1 = @"- listitem1
- listitem2
  - two spaces indented
";
// no nested list
var md2 = @"1. listitem1
1. listitem2
  1. two spaces indented
";
// contains a nested list
var md3 = @"1. listitem1
1. listitem2
   1. three spaces indented
";
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
Console.WriteLine(Markdown.ToHtml(md1));
Console.WriteLine(Markdown.ToHtml(md2));
Console.WriteLine(Markdown.ToHtml(md3));

The output contains:

<ul>
<li>listitem1</li>
<li>listitem2
<ul>
<li>two spaces indented</li>
</ul>
</li>
</ul>

<ol>
<li>listitem1</li>
<li>listitem2</li>
<li>two spaces indented</li>
</ol>

<ol>
<li>listitem1</li>
<li>listitem2
<ol>
<li>three spaces indented</li>
</ol>
</li>
</ol>
Originally created by @russau on GitHub (May 15, 2017). Hi all, I've discovered an issue with some markdown I'm converting. The unordered lists considers two-spaces an indent, yet the ordered lists need 3-spaces to indent. I'll pulled the latest and written a test below. Is this the intended behavior? Playing with stackoverflow's stackedit I see two-spaces on a 1. treated as an indent. Thanks, Russ ``` // contains a nested list var md1 = @"- listitem1 - listitem2 - two spaces indented "; // no nested list var md2 = @"1. listitem1 1. listitem2 1. two spaces indented "; // contains a nested list var md3 = @"1. listitem1 1. listitem2 1. three spaces indented "; var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); Console.WriteLine(Markdown.ToHtml(md1)); Console.WriteLine(Markdown.ToHtml(md2)); Console.WriteLine(Markdown.ToHtml(md3)); ``` The output contains: ``` <ul> <li>listitem1</li> <li>listitem2 <ul> <li>two spaces indented</li> </ul> </li> </ul> <ol> <li>listitem1</li> <li>listitem2</li> <li>two spaces indented</li> </ol> <ol> <li>listitem1</li> <li>listitem2 <ol> <li>three spaces indented</li> </ol> </li> </ol> ```
claunia added the invalid label 2026-01-29 14:27:17 +00:00
Author
Owner

@xoofx commented on GitHub (May 15, 2017):

This is a normal behavior of CommonMark list

It depends on the number of characters taken by - or 1. AND the number of spaces after that.

So the following list should be indented like this (note 3 spaces after the first -). Check on babelmark

-   a
    - b

Same for the following list (Check on babelmark3)

10.  a
     1. b
@xoofx commented on GitHub (May 15, 2017): This is a normal behavior of [CommonMark list](http://spec.commonmark.org/0.27/#list-items) It depends on the number of characters taken by `-` or `1.` AND the number of spaces after that. So the following list should be indented like this (note 3 spaces after the first `-`). Check on [babelmark](https://babelmark.github.io/?text=-+++a%0A++++-+b) ``` - a - b ``` Same for the following list (Check on [babelmark3](https://babelmark.github.io/?text=10.++a%0A+++++1.+b)) ``` 10. a 1. b ```
Author
Owner

@russau commented on GitHub (May 15, 2017):

Thanks for the clarification!

@russau commented on GitHub (May 15, 2017): Thanks for the clarification!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#110