sbrl / Pepperminty-Wiki

A wiki in a box
https://peppermint.mooncarrot.space/
Mozilla Public License 2.0
178 stars 20 forks source link

[Wiki Matrix] Automatic tables-of-contents #155

Closed sbrl closed 4 years ago

sbrl commented 6 years ago

Reading through the feature list on Wiki Matrix whilst updating the release number on there revealed a pair of features that would be both (relatively) easy to implement and be rather useful!

This is the other of them: Automatic tables of contents. Perhaps we only show it if there are more than, say, 4 headings in it? It could be configurable, of course. MediaWiki shows it before the first major heading, but after the introductory paragraph(s). Maybe we could do something similar? If we're undecided we can always make that a setting too. Of course, we'll want to be able to turn it off if it's undesirable as well.

This might do well as a part preprocessor in a new module, actually.

sbrl commented 4 years ago

Oh wow, while dealing with removing ParsedownExtreme (which wasn't working as intended - everything was a mess) and implementing all the features we're interested in, we've actually implemented this! Yay!

Just make sure you never include the string █yyZiy9c9oHVExhVummYZId_dO9-fvaGFvgQirEapxOtaL-s7WnK34lF9ObBoQ0EH2kvtd6VKcAL2█ in any of your pages, as you'll find it replaced by an automatic table of contents :P

We could perhaps alter this magic string to instead include < and > or something and use rawHtml when returning from the [__TOC__] identifier to avoid potential, but I'm not sure if that's a good idea for users that might use raw HTML in their wikis (since that's an option, even if it's not recommended).

Alternatively, we could abuse a non-printable control character from the ascii table like 0x11 device control 1, but I think that's thinking too much about a teeeeeny issue that nobody's ever going to notice

I think we can call this done :D

sbrl commented 4 years ago

Note to self: Don't forget to update WikiMatrix when do the next stable release.....