badboy / mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.
Mozilla Public License 2.0
163 stars 20 forks source link

Links in mdbook-printed PDF documents open the browser #32

Closed Hoffenbar closed 1 year ago

Hoffenbar commented 1 year ago

I use mdbook-toc a lot to generate intra-page-tocs, which works wonderfull in browsers. If I print such page through the browser print function, the links are functioning while viewing the PDF, too. But if I use mdbook´s own print function, clicking on such link in the PDF would do nothing. I wonder if this is a mdbook or mdbook-toc topic, and if it has something to do with specifing after|before = [ "links" ] within [preprocessor.toc]?

badboy commented 1 year ago

mdbook-toc generates markdown links that directly link to an anchor ([header](#header-id)). mdbook's generated print.html seems to turn them into a relative URL (href="path/to/your/chapter.html#header-id), which then get turned into absolute URLs when printing. This would also happen for links you write yourself. This is not a bug in mdbook-toc and I don't have recommendations how to work around this (might require changing how links in print.html are generated)