markdown-it / markdown-it-container

Fenced container plugin for markdown-it markdown parser
MIT License
496 stars 74 forks source link

Incorrect parsing of one-line container #21

Closed Timur-P closed 6 years ago

Timur-P commented 6 years ago

I want to use containers as file format descriptors. Since containers can't be nested as of now, I use empty container as separator of larger parts of the document, in a format like this ::: meta :::

::: type type :::

::: tags tag1 tag2 :::

::: end_meta :::

However, if container uses only one line, it's end container token generated only after next ::: on separate line (for the above format - after container_type_close).

{ "type":"container_meta_open", "tag":"div", "attrs":null, "map":[ 2, 6 ], "nesting":1, "level":0, "children":null, "content":"", "markup":":::", "info":" meta", "meta":null, "block":true, "hidden":false }, { "type":"container_type_open", "tag":"div", "attrs":null, "map":[ 4, 6 ], "nesting":1, "level":1, "children":null, "content":"", "markup":":::", "info":" slugs", "meta":null, "block":true, "hidden":false }, ... ... ... { "type":"container_type_close", "tag":"div", "attrs":null, "map":null, "nesting":-1, "level":1, "children":null, "content":"", "markup":"", "info":"", "meta":null, "block":true, "hidden":false }, { "type":"container_meta_close", "tag":"div", "attrs":null, "map":null, "nesting":-1, "level":0, "children":null, "content":"", "markup":":::", "info":"", "meta":null, "block":true, "hidden":false },

Can you fix that?

puzrin commented 6 years ago

Not a bug.

This plugin and it's markup are intended to be multiline. You try to use it in wrong way, and that will not work.

Timur-P commented 6 years ago

Well, of course I understand that this is not a bug. I used incorrect word "fix". But I think it could be a nice feature to have. At least container is not standard element and could step aside some standard things :) So, I am just humbly asking to consider implementation of this feature.

puzrin commented 6 years ago

That's completely different approach for both markup and implementation. There are no benefits in mixing everything in one place. You'd better to create your own plugin.

Timur-P commented 6 years ago

Ok, I got it, thanks for the answer. I guess nesting of containers is also out of scope?

Timur-P commented 6 years ago

Sorry, I've just looked into closed issues, and it looks like it should work

Timur-P commented 6 years ago

Sorry for bothering, I'll play with more ::::

GreenImp commented 1 year ago

Not a bug.

This plugin and it's markup are intended to be multiline. You try to use it in wrong way, and that will not work.

@puzrin I've read over the docs and found this: https://spec.commonmark.org/0.18/#example-95

Info strings for backtick code blocks cannot contain backticks:

``` aa ```
foo
<p><code>aa</code>
foo</p>

Which suggests that inline code fence blocks should work. Is this something that may be made available in the future?