vito / booklit

a pretty lit content authoring system
https://booklit.page
MIT License
175 stars 55 forks source link

Adding footnotes #16

Open bake opened 5 years ago

bake commented 5 years ago

Hi, I like to use footnotes on my pages. I wrote a very simple plugin that accomplishes this by adding arguments to a call of \footnote to a package global slice and rendering it when \footnotemark is called. This is probably not the best way to do it.

Do you think a feature like this should be added to baselit?

vito commented 5 years ago

Neat! Yeah, this could be a good idea for baselit.

Maybe the footnotes could be kept as state on the *Plugin object instead?

bake commented 5 years ago

To be honest, I don't know why I didn't set it inside the struct. The repo is updated, thank you. There still is the problem of duplicate references when using multiple \footnotemark on a single page (which might not happen often).

For example, both footnotes will get an index 0:

\footnote{Foo.}
\footnotemark

\footnote{Bar.}
\footnotemark

Do you have an idea where the current index should be stored (if at all)?

vito commented 5 years ago

(Sorry for the delay!)

For my understanding, do you see this to mainly be a problem when multiple sections are rendered inline into one page?

Maybe the footnotes should include the section tag in their anchor - i.e. #fn-section-title-1?

bake commented 5 years ago

Exactly, I think your solution should work. I'll give it a try when I'm back home.

bake commented 5 years ago

Sorry, this took longer than expected.

I am not sure how to access previous footnotes from within baselit. The plugin-approach seems a lot simpler.

I suspect it would work similar to the toc, but reading upward and printing the sections titles querying the footnotes in all subsections.

A new \footnote then should look in its parent sections until it finds a previous \footnote and increment the found id or it finds a \footnotemark, in which case its id should start at 0 or 1.

vito commented 5 years ago

@bakerolls No worries! I think a separate plugin is fine especially since there's state involved.

I think if you put the section's tag in the footnote anchor the IDs don't really matter, since they'll always be relative to the section tag. Does that make sense?