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 a toc/table of contents option #291

Open
maralorn opened this issue Jul 16, 2020 · 6 comments
Open

Add a toc/table of contents option #291

maralorn opened this issue Jul 16, 2020 · 6 comments
Labels
enhancement New feature or request NeuronNG/Triage proposal Proposal with exact spec yet to be fleshed out

Comments

@maralorn
Copy link
Contributor

I think at would be good to have the possibility, to set a flag to automatically generate a table of contents at the beginning of the zettel based on the headings in the zettel.

Alternative suggestion would be to have some custom query like <toc?for_zettels=...> That would be even more flexible e.g. giving the possibility to make one zettel with the table of contents of multiple others.

@srid srid added proposal Proposal with exact spec yet to be fleshed out enhancement New feature or request labels Jul 16, 2020
@srid
Copy link
Owner

srid commented Jul 16, 2020

I was thinking a simple toc: true in the YAML frontmatter should do it.

Not sure if the case for a toc query type is strong enough (why would one want to generate ToC based on a different zettel?) ... although the idea (i.e., using query type to say 'i want toc here') is interesting.

@felko
Copy link
Contributor

felko commented Jul 16, 2020

I was thinking about something similar to the latter idea, which would behave like <z:tags?filter=...>, but instead of only showing the matching tags, zettels would also show up under the corresponding node in the tree.

Example:

  • A is tagged my-book/part1
  • B1 and B2 are tagged my-book/part1/chapter1
  • C is tagged my-book/part1/chapter2
  • D is tagged my-book/part2
<z:toc?filter=my-book/**>
==>
- my-book
  - part1
    - A
    - chapter1
      - B1
      - B2
    - chapter2
      - C
  - my-book
    - part2
      - D

There are some issues with this though, because we don't know how to order the zettels, and also because a single zettels can have multiple tags that match my-book/**.

@maralorn
Copy link
Contributor Author

maralorn commented Jul 16, 2020

why would one want to generate ToC based on a different zettel?

Well, the question is a bit, what use cases we assume valid for a zettelkasten.

But imagine you are writing a book. Every chapter is one zettel, which has multiple sections.
Then as an entry point into the book one could create one zettel which displays the tocs of all chapters in a list. Thereby you can achieve to have one big table of content stretching over multiple zettels.

I am actually planing to collect theorems for my thesis in neuron. Right now if I want a linked toc, I need to put every section in one zettel. With a toc feature, I could just have everything in one zettel. With the fancy toc feature, I could go the middle ground. The toc could span multiple zettels but also the structure inside them.

I really like the idea the longer I think about it. Of course, as always, someone would need to implement it.

@maralorn
Copy link
Contributor Author

One second motivation, why a <z:toc> query or something like that would be useful is that it gives the possibility to have some introductory text before the toc, like the wikipedia does it.

@b0o
Copy link

b0o commented Jul 17, 2020

I've written a little tool that accomplishes something similar to this using jq to parse Neuron's query output.

If I want a zettel to appear in my ToC (I call it an index, but it is really more of a ToC), I add a tag starting with index/ followed by the desired path within the ToC for that zettel, e.g. index/comp/linux/security. A zettel can have multiple of these index tags, and multiple zettels can have the same index tag. Zettels can also belong to any level of the hierarchy.

I have my tool configured to generate a new zettel for each level of the index hierarchy, with links to any leaf nodes (zettels) or sub-trees (deeper layers of the index hierarchy).

Here's an example of navigating the generated index/ToC pages:

demo-01

It can be tweaked to use a 'sentinel' other than index/, and could also easily be used to generate multiple different ToCs, e.g. my-book/foo/bar and my-other-book/qux/spam.

It works pretty well for me so far, maybe it could help inspire the UI of a similar feature built in to Neuron.

P.s. be careful if you try to use my script, as it will rm $HOME/zettelkasten/index-*. It's only been written with my use case in mind thus far.

@srid
Copy link
Owner

srid commented Aug 4, 2020

The suggestion to support Wikipedia style {{..}} templates in #312 (comment) seems relevant here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NeuronNG/Triage proposal Proposal with exact spec yet to be fleshed out
Projects
None yet
Development

No branches or pull requests

4 participants