Open frank-mendez opened 2 years ago
In case its helpful to anyone in the interim:
mr-pdf
appears to find and remove elements matching the --excludeSelectors
flag after inserting the PDF table of contents. So, in the interim while awaiting or proposing a fix, you can provide selectors that remove the broken entries based on the pattern used to create those entries. You might need to crawl the source if it changes, but the class names are currently toc-item-1
, toc-item-2
, and toc-item-3
for h1
, h2
, and h3
respectively.
npx mr-pdf --initialDocURLs="http://my-site/my-first-doc-page" --excludeSelectors=".pdf--hidden,.toc-item-3"
Hi @frank-mendez resolved in this PR from docs-to-pdf
a fork of mr-pdf
https://github.com/kohheepeace/mr-pdf/blob/master/src/utils.ts#L235
if (header.match(/id( )*=( )*"\S*"/g)) {
return header.replace(/id( )*=( )*"\S*"/g, `id="${headerId}"`);
}
这里改一下可以修复
Table of Contents: only the first-level menu item actually has a hyperlink to the page, the sub-levels do not - is that a bug or by design? If it's not possible to hyperlink the sub-sections, then I'm not sure it makes much sense to have them listed in the TOC at all - it takes up 3 pages of the manual, has no page numbers nor links, so maybe better to only have the top level in the TOC