MultiMarkdown-6 icon indicating copy to clipboard operation
MultiMarkdown-6 copied to clipboard

Make anchors better when using TOC

Open ghost opened this issue 3 years ago • 7 comments

Hi,

Multimarkdown is a wonderful piece of software and it works as advertised. I wanted to file this idea for an improvement of handling table of contents (TOC) anchors when exporting to HTML.

Currently, all TOC anchors are quite plain and there is no processing at this time in multimarkdown. While i can understand that action, it leaves the anchors a bit plain. Example of an anchor, from one HTML page:

foo.bar/index.html#Firstparagraph

Now prom the usability aspect, we should have something more like

foo.bar/index.html#first-paragraph

Now from semantic point of view, it would be neat to have an option to process these anchors a bit. Pandoc does it quite good and can be used as an example:

  • all letters are lowercase
  • all anchors wave dash (-) instead of space
  • you can set TOC title, which will be omitted from the TOC list

Is it possible to think about this and implement it in the future? Thank you.

ghost avatar Mar 21 '21 16:03 ghost

Perhaps you are not using MultiMarkdown? MultiMarkdown doesn't generate anchors like #Firstparagraph. It lower cases them and strips out characters that are not allowed (such as spaces)

fletcher avatar Mar 21 '21 17:03 fletcher

Perhaps you are not using MultiMarkdown? MultiMarkdown doesn't generate anchors like #Firstparagraph. It lower cases them and strips out characters that are not allowed (such as spaces)

I am using multimarkdown however i am also using cyrillic script for pages therefore case is not being changed.

Other part is true: Latin alphabet headers are converted into lowercase with spaces stripped and no - instead of that space. I can use random ID generator for headers but that is not ideal for cross-linking on pages.

ghost avatar Mar 21 '21 18:03 ghost

Yes -- unicode case folding would require including a larger library, which is not worth the "cost" for most users.

You can specify a custom label for any header that you like if you don't want to use the default - # Header [whatever-you-want]

fletcher avatar Mar 21 '21 18:03 fletcher

Thank you for the answer. I dont mind the fact that case is capitalized in anchor links but i wanted to mention it.

You can specify a custom label for any header that you like if you don't want to use the default - # Header [whatever-you-want]

I am i aware of that option however I wanted to use fully automated TOC generation without using any hard coded stuff. Is there a way to re-think decision to strip all spaces and instead replace them with dashes? That could be more than welcome feature and it would make anchor links much more readable in general

ghost avatar Mar 21 '21 18:03 ghost

It would break backwards compatibility with 17 years of MultiMarkdown.... So probably not something I'll do right now, but can consider it the next time there is a major new version.

fletcher avatar Mar 28 '21 12:03 fletcher

Is it possible to rethink maybe as a opt-in switch? Sorry for being pushy, i am just exploring options here.

ghost avatar Mar 28 '21 19:03 ghost

Possibly.

fletcher avatar Mar 28 '21 19:03 fletcher