orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
324 stars 76 forks source link

Links to span id defined anchors are not clickable #130

Open pstavirs opened 1 year ago

pstavirs commented 1 year ago

If an id is defined for a span element in the source MD/HTML, an href to it is not clickable in the generated PDF. If I change span to div the problem is not seen.

Here's a minimal example -

$ cat mkdocs.yml 
site_name: My Docs
plugins:
    - with-pdf:
        show_anchors: true
$ cat docs/index.md 
# Welcome to MkDocs

For full documentation visit [mkdocs.org](https://www.mkdocs.org).

## Commands

* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.

<span id="span_id"/>
<div id="div_id"/>
<a id="a_id"/>

## Project layout

    mkdocs.yml    # The configuration file.
    docs/
        index.md  # The documentation homepage.
        ...       # Other markdown pages, images and other files.

The build only generates the div_id anchor point, not the span_id or a_id -

$ mkdocs build
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/srivatsp/Code/span-test/site
INFO     -  Number headings up to level 3.
INFO     -  Generate a table of contents up to heading level 2.
INFO     -  Generate a cover page with "default_cover.html.j2".
INFO     -  Converting <img> alignment(workaround).
INFO     -  Anchor points provided:
INFO     -  | #.:
INFO     -  | #.:commands
INFO     -  | #.:div_id
INFO     -  | #.:project-layout
INFO     -  | #.:welcome-to-mkdocs
INFO     -  | #author
INFO     -  | #copyright
INFO     -  | #doc-cover
INFO     -  | #doc-toc
INFO     -  Rendering for PDF.
INFO     -  Output a PDF to "/home/srivatsp/Code/span-test/site/pdf/document.pdf".
INFO     -  Converting 1 articles to PDF took 19.0s
INFO     -  Documentation built in 19.26 seconds