slatedocs / slate

Beautiful static documentation for your API
https://slatedocs.github.io/slate
Apache License 2.0
36.06k stars 147 forks source link

Feature: Using HTML instead of text for generation of TOC titles #551

Closed terrymun closed 8 years ago

terrymun commented 8 years ago

First of all, thanks for developing Slate—it is immensely helpful with generating API docs without needing to devise a whole new way of presenting code. Also helps to motivate devs who are often a bit lethargic about writing up documentations ;)

Anyway, I am wondering if we can switch from using .text() to using .html() when declaring the content of the anchor elements generated by the TOC. The reason behind being that there are certain typesetting requirements for some headers (for example, in biology, species and/or genus names must be italicised, which is lost in the TOC list).

This is done by changing line 404 in the _jquery.tocify.js file from:

"text": self.text()

... to:

"html": self.html()

I know this presents a security risk, because authors can then inject any HTML element in the header elements and have it parsed by the JS file generating the TOC, but I would consider this as an unlikely case... I could be wrong, tho!

I'll be more than happy to do make a PR, but I would like to ask for your opinion on this issue first.

lord commented 8 years ago

Hey! Glad to hear you're making good use of Slate.

Hmm. This is an interesting thought. I think that preserving italics makes sense and is a good idea, but I'm a little worried that copying all HTML isn't quite the right solution either, since it's not really obvious that it works that way at first glance and I'm worried it can cause confusion. That said — I agree, italics should be preserved. We're going to remove Tocify at some point anyway, and I've noted this idea in that issue so the new system implements some solution. Thanks for the feedback!