New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for table of contents rendering #56

Open
fluffy-critter opened this Issue Apr 21, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@fluffy-critter
Copy link
Collaborator

fluffy-critter commented Apr 21, 2018

Expected Behavior

There should be some means of signaling that we should render a table of contents in the more-text.

With this mechanism, we would set nesting_level on the HtmlRenderer and also run an HtmlTocRenderer with the same nesting level.

Possible Solution

entry._get_markup() could also take a show_toc=N parameter, which is set to None on entry.text and to a value indicated by a Toc-Level header on the entry itself. Perhaps it should take the minimum of the entry's value and the template's value (so both the template and the entry need to want a TOC for it to display).

The TOC content itself could be wrapped in a <div class="toc"> (or maybe an id with the caveat that it only makes sense to render a single entry's more content on a single page).

Context

Would be great for the manual, among other things.

@fluffy-critter

This comment has been minimized.

Copy link
Collaborator

fluffy-critter commented May 1, 2018

In the interest of generality I'd actually like to see the TOC renderer be called explicitly, like:

{% if entry.toc %}
<div class="toc">{{entry.toc}}</div>
{% endif %}

where entry.toc is truthy if Toc-Level is set, and renders out the HtmlTocRenderer for entry.more. And then entry.more would always use Toc-Level for its nesting_level parameter.

It's also tempting to just have the template itself indicate whether it should use HtmlTocRenderer or not, and set the nesting_level, so that entry.text can get it too, but I'm fine with limiting TOCs to entry.more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment