Aidurber / obsidian-plugin-dynamic-toc

An Obsidian plugin for creating Tables of Contents that stay updated with your document
MIT License
269 stars 41 forks source link

Export do PDF does not create document links #18

Closed manfredbjorlin closed 3 years ago

manfredbjorlin commented 3 years ago

When exporting to PDF from Obsidian the TOC does not appear to be document links in the same way as when making footnotes.

Aidurber commented 3 years ago

Hi @manfredbjorlin, I've finally got around to looking into this. Just going to do a brain dump.

When Obsidian converts the markdown into HTML, it does not add an ID to the header elements.

Header element HTML

In order to link inside a document, the target element needs an ID. That ID becomes the href for the anchor tag. This is clear when you take a look at how footnotes work.

Foot note element HTML

Obsidian generates a unique ID for each footnote, which allows for the link to work.

That being said I could give headers a similar treatment, I'm unsure in the amount of work required.

Edit: I think there's more to it than this actually. In the rendered markdown table of content, the links work. I think it may be due to HTML being more forgiving than in PDFs.

Aidurber commented 3 years ago

After much pain, I've discovered it's not possible at the moment.

It's a known issue in Obsidian that same document links aren't functional in PDFs. With the exception of footnotes (for some reason).

Source: https://forum.obsidian.md/t/pdf-export-make-links-within-same-document-functional/16384

In the mean time I'm afraid there isn't much we can do. I'm going to close. I've subscribed to that feature request, if that changes I'll take another look at this.