Skip to content
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 an easily customizable TOC #13

Closed
dlesnoff opened this issue Apr 4, 2023 · 1 comment
Closed

Add an easily customizable TOC #13

dlesnoff opened this issue Apr 4, 2023 · 1 comment

Comments

@dlesnoff
Copy link

dlesnoff commented Apr 4, 2023

In the few Nimib files that I created, I always resort to templates similar to this one for the creation of a table of contents (TOC):

var nbToc: NbBlock

template addToc =
  newNbBlock("nbText", false, nb, nbToc, ""):
    nbToc.output = "### Table of Contents:\n\n"

template nbSection(name:string) =
  let anchorName = name.toLower.replace(" ", "-")
  nbText "<a name = \"" & anchorName & "\"></a>\n## " & name & "\n\n---"
  # see below, but any number works for a numbered list
  nbToc.output.add "1. <a href=\"#" & anchorName & "\">" & name & "</a>\n"

It would be interesting to make this easily configurable with a simple addToc command, that would define nbSection, nbSubSection, nbSubSubSection, nbParagraph (like Latex?) or nbH1Title, nbH2Title, etc ... for each level of heading.
It would be cool if the Toc appearance could be configurable too (level of heading, title?) without having to resort to nbToc.output and newNbBlock.

@pietroppeter
Copy link
Member

The idea was to add this to nimib itself, see pietroppeter/nimib#58

@dlesnoff dlesnoff closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants