goldmark-pdf: Local links/navigation is not working

Having local navigation, like:

# <a name="top"></a>Markdown Test Page

* [Headings](#Headings)
* [Paragraphs](#Paragraphs)
* [Blockquotes](#Blockquotes)
* [Lists](#Lists)
* [Horizontal rule](#Horizontal)
* [Table](#Table)
* [Code](#Code)
* [Inline elements](#Inline)

***

# <a name="Headings"></a>Headings

# Heading one

Sint sit cillum pariatur eiusmod nulla pariatur ipsum. Sit laborum anim qui mollit tempor pariatur nisi minim dolor. Aliquip et adipisicing sit sit fugiat commodo id sunt. Nostrud enim ad commodo incididunt cupidatat in ullamco ullamco Lorem cupidatat velit enim et Lorem. Ut laborum cillum laboris fugiat culpa sint irure do reprehenderit culpa occaecat. Exercitation esse mollit tempor magna aliqua in occaecat aliquip veniam reprehenderit nisi dolor in laboris dolore velit.

## Heading two

[[Top]](#top)

obrázok

will render links but they won’t work.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I’ve added support for local links on the current master branch.

Some things to note:

This only works for hashtag links to headers. The header ID attribute need to be generated by the parser using the goldmark option WithAutoHeadingID.

          goldmark.WithParserOptions(
              parser.WithAutoHeadingID(),
          ),

This means that adding internal links like <a name="here"></a> or <span id="this"></span>. Will not work. There are inline HTML fragments which this package cannot render at all.

Upgrade to the most recent commit with go get github.com/stephenafamo/goldmark-pdf@3ab67f1 and try it out.