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

Linkable headers #21

Open
HugoGranstrom opened this issue Jun 19, 2021 · 4 comments
Open

Linkable headers #21

HugoGranstrom opened this issue Jun 19, 2021 · 4 comments

Comments

@HugoGranstrom
Copy link
Member

Similarly to the cheatsheet example in Nimib I think making all the headers linkable is a good idea. That would make it easier to direct people asking questions to specific sections among other things. It would also allow us to have TOCs on every page like in the cheatsheet example if we wanted to. The current implementation needs some work though, optimally the headers themself (or a symbol in front/after of them) should be clickable so one easily can copy the link.

@pietroppeter Do you think this is functionality that (optionally) should be offered by Nimib/NimiBook itself or should we roll our own version here?

@pietroppeter
Copy link
Contributor

Yes, I think it should be offered by nimib. Ideally directly in the markdown rendering (and links should have the link icon appearing on hover as in GitHub).

@HugoGranstrom
Copy link
Member Author

OK, great! 👍 Can open an issue later unless you beat me to it ;) On this topic, should Nimib have more of these basic building blocks built-in? For example nbList which takes an openArray[string] and produces the list. Things people would probably roll themselves either way basically.

Ideally directly in the markdown rendering

You mean directly in nim-markdown?

@pietroppeter
Copy link
Contributor

Nope, go ahead on open that! Not sure what you mean by the list.
No, did not mean in Nim-markdown, if I remember correctly you can configure the way Nim-markdown works adding components, but the thing is I have not a clear idea on how to do that.
Also, to create a toc and put it in some place, you would need to do something when block is created (e.g. add a value in a toc or refs array inside the context).

@HugoGranstrom
Copy link
Member Author

Nope, go ahead on open that! Not sure what you mean by the list.

On my way!
Judging from the rest of your answer we didn't have the same ideas in our heads hehe. Your idea is to automagically turn all #, ##, etc into links behind the scene? My mind was at adding a nbTitle template. The list would then be an nbList that would work like this:

nbList(["First", "Second", "Third"])

# produces:

"""
- First
- Second
- Third
"""

But idk if that's something you would want to have built-in to Nimib or if it should belong in a separate package nimib-helpers or just nimib/helpers. Then one could do such things as handling TOCs and stuff inside the templates.

No, did not mean in Nim-markdown, if I remember correctly you can configure the way Nim-markdown works adding components, but the thing is I have not a clear idea on how to do that.

Interesting, didn't know that. :)

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