LegNeato / mdbook-typst

An mdBook backend to output Typst markup, pdf, png, or svg
54 stars 4 forks source link

footnote support #10

Open cittadhammo opened 1 month ago

cittadhammo commented 1 month ago

Would it be possible to add footnote support:


Here is a simple footnote[^1]. With some additional text after it.

[^1]: My reference.
LegNeato commented 1 month ago

I think it would be easy from the markdown side, but what should they be converted to on the mdbook side? I don't think mdbook supports footnotes but perhaps I am mistaken.

cittadhammo commented 1 month ago

Yes sorry, there is an explanation here for example https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/

or here https://rust-lang.github.io/mdBook/format/markdown.html#:~:text=Footnotes,a%20caret%20at%20the%20front. for mdbook proper

My workflow is to write a book. So far, I have used a mdbook to latex converter, but when I saw your project, I thought I could give it a try. It works very well, the only thing missing is that the footnote should be nicely integrated on the footer of the page where they appear, Latex is very good at this.

What do you think?

LegNeato commented 1 month ago

Yeah, it should be a straightforward addition. I won't be able to get to it for a couple of weeks due to travel but I can do it when I get back if you don't take a crack at it before then!

cittadhammo commented 1 month ago

@LegNeato Good, thank you, I have never coded in rust, but I will have a look at your code and why not do a PR if I can ;-)

LegNeato commented 2 weeks ago

Working on this, should have it done in the next week

LegNeato commented 2 weeks ago

So the annoying part of doing this is we'll have to buffer the entire document to support these, as the footnote links can be anywhere in the document.

cittadhammo commented 2 weeks ago

Yes, this is why I added this other function to store the references of the footnotes: https://github.com/LegNeato/mdbook-typst/pull/16/commits/d1aa4ba4eefac7557ad5e48f1d1ed2b04827dcea

it is still very fast, even for my 300+ pages project.