-
I want to parse a markdown file and detect quick outlines, something like this
Sadly the parser trims the leading spaces. So I get this (no empty space after
Somehow I can circumvent this adding a non significant empty space to the text before parsing
And that gives me exactly what I wanted
Basically I want a simple syntax extension where the leading white space has some meaning. Is there a way to prevent auto-trimming in the mdast? I come up with a solution but I do not want to depend in a hack that might break in the future |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
What do you mean detect? What are “quick outlines”?
This is how markdown works. Leading and trailing spaces are dropped.
this is also how markdown works. Leading and trailing spaces are dropped, but other spaces are not, meaning between non-space character. A
That isn’t markdown. It doesn’t work in other places where markdown works. There might be some hacky ways around it with out pluggable parser, but it won’t work in other places.
I think your solution is a great solution. It works everywhere that supports CommonMark/GFM. It won’t change in the future. |
Beta Was this translation helpful? Give feedback.
What do you mean detect? What are “quick outlines”?
This is how markdown works. Leading and trailing spaces are dropped.
this is also how markdown works. Leading and trailing spaces are dropped, but other spaces are not, meaning between non-space character. A
(non-breaking space) is such a character.That isn’t markdown. It doesn’t work…