mmark icon indicating copy to clipboard operation
mmark copied to clipboard

The other heading style

Open istathar opened this issue 6 years ago • 2 comments

I have a significant corpus of material that uses the original Markdown syntax for headings ("setext style, I think?) with

Level 1
=======

and

Level 2
-------

headings. We value these for the visual strength and structural separation they give when scanning the original text documents. I like the goals you set out for mmark but I'd need to contribute to enable support for these if I was to use this for real. Do you think this would be possible with the code as currently designed?

AfC

istathar avatar Jun 06 '18 13:06 istathar

Yes, that's setext headings. As I state here

Setext headings are not supported for the sake of simplicity.

If we're to support this style of headings, it'll considerably complicate parsing of paragraphs because headings can interrupt paragraphs so we'd need to constantly check following line if it has === or --- and if the line we're grabbing can thus be interpreted as a header.

I don't remember exactly though, you'll need to check the spec. But I left them out for a reason, I think. You're free to try to add them, just keep an eye on bencmarks too. Be careful with paragraph parsing because it's about 80-90% of real-world input and so it's a major performance bottleneck.

mrkkrp avatar Jun 06 '18 14:06 mrkkrp

Actually may be quite doable. The interesting feature is this:

https://spec.commonmark.org/0.28/#example-51

So we could perhaps just check if a paragraph ends with such "header line" and then decide what we've parsed accordingly. Will need to try to conform to as many examples from the spec as possible.

mrkkrp avatar Jun 06 '18 14:06 mrkkrp