pillar-markup / Microdown

Microdown is a cleaned and simpler markdown but with more powerful features such as extensions.
Other
40 stars 31 forks source link

MicListItemBlock and new line breaks #513

Open kasperosterbye opened 2 years ago

kasperosterbye commented 2 years ago

Moved as issue from long thread on lse-microdown mailing list.


Please also remember that we are not implementing markdown and the strange rule github uses. Even markdown editors sometimes are not following any reasonable rules. Like putting an - after a list break the previous element in macdown.

So I think that we should have what we think is good. And not some crazy shit.

S

On 22 Jul 2022, at 06:35, Kasper Osterbye [kasper.osterbye@gmail.com](mailto:kasper.osterbye@gmail.com) wrote:

Hernán

I found the “Markdown philosophy” section https://daringfireball.net/projects/markdown/syntax#philosophy to be quite informative.

In general I believe it is better to take such technical discussions as issues in github than here on the mailing list. I at least often search old closed issues on github for Pharo to see if something odd has been discussed before.

Best,

Kasper

On 22 Jul 2022, at 01.28, Hernán Morales Durand [hernan.morales@gmail.com](mailto:hernan.morales@gmail.com) wrote:

Hi Kasper,

Thanks for your email. I just tried in a gist and indeed Github Markdown cannot break a list with a new line. See https://gist.github.com/hernanmd/842cb08db14ab8a19c5da5efabb314d9 This is surprising given that it is used everywhere.

I just read some threads about automatic list numbering in an editor: https://youtrack.jetbrains.com/issue/IDEA-292704/Do-not-automatically-number-lists-in-markdown, very interesting to understand editor re-numbering, but not so much about avoid resuming list numbering. TL;DR: they seem to rely on a linter to configure similar stuff (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md029---ordered-list-item-prefix). If you like this path I could open an issue for Microdown Linter but this is another subject probably for the future.

About the Markdown list auto-numbering, it seems that writing normal text (below a numbered item) breaks the consumption of line items. And writing 4 spaces will indent text to belong to the list item, preventing from breaking the auto-numbering (https://stackoverflow.com/questions/18088955/markdown-continue-numbered-list)

Let me know if you want me to open an issue on this too.

Cheers,

Hernán

El jue, 21 jul 2022 a las 7:10, Kasper Osterbye ([kasper.osterbye@gmail.com](mailto:kasper.osterbye@gmail.com)) escribió: Cheers Hernán

I have no answer off hand. It is part of Markdown I would like to understand better one day. I find indentation and breaking of lists in any markdown to be surprising - and in microdown as well.

When I run into an example like you mention here, I normally try in github and a markdown editor to see what those do.

For example, I have not yet found a why to break a numbered list in anyway using github markdown.

  1. Foo 1

  2. Foo 2

  3. Foo 3 How to format the above to get

  4. Foo 1

  5. Foo 2

  6. Foo 3

Besides the parsing issues, the Text rendering in Microdown is troublesome with too many CR added for my taste. I would like to fix this as well when I have found a way to clearly understand the whole thing.

Sorry I am no real help.

Best,

Kasper

On 21 Jul 2022, at 00.03, Hernán Morales Durand [hernan.morales@gmail.com](mailto:hernan.morales@gmail.com) wrote:

Hi Kasper,

I have an issue here with MicListItemBlock which (when created) should be in another (new) Mic*ListBlock, but it is included as part of a previous list. It happens with numbered list parsing after a break. See please the annotated screenshot.

You can also see attached a screenshot of the corresponding Mic tree.

I found one could overcome this problem by writing:

  1. some text
  2. new list text

But I guess this is not the intended behavior. The weird thing is that it works fine with the UnorderedList.

Is this related to the trimming in #canConsumeLine: ?

Let me know what you think.

Hernán <Screen Shot 2022-07-20 at 23.27.41.png><Screen Shot 2022-07-20 at 23.49.27.png>

kasperosterbye commented 2 years ago

Based on what I read, I see the following suggestion for how Microdown could work wrt lists.

Where does one list item end?

My proposal is that a list item is ended when

This also gives the ways in which a list item is not ended, in particular

Where does a list end

A list (or nested list) is ended when the item is ended, and the next block is not a new item for the list.

1. bla
  foo 
- bla bla2. 
  bar
new line with no indent

The ordered list (of one item) is ended because it is followed by a block which is not an ordered list item. The unordered list (of one item) is ended because it is followed by a block which is not an unordered list item.

  1. bla foo
    • bla bla2. bar.

new line with no indent

Special for numbered lists

Normally numbered list can accept any number in the input. That is

1. bla
1. bla
1. bla

gives a numbered list 1. 2. 3.

I suggest we follow the convention that the first item specify the starting number:

5. bla
1. bla
1. bla

gives numbered list 5. 6. 7.