jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.78k stars 3.39k forks source link

buf report: leading underscore are missing when converting markdown section to html id #10373

Closed Kamilcuk closed 1 week ago

Kamilcuk commented 1 week ago

Explain the problem.

Pandoc when processing markdown sections removes the leading _ when producing html with id tag:

$ pandoc -f markdown - <<<'Go to [_section](#_section)'$'\n\n''### _section'
<p>Go to <a href="#_section">_section</a></p>
<h3 id="section">_section</h3>

The id="section' is wrong, it should id="_section". This breaks the links, href="#_section" navigates to _section not to section.

What can I do to fix?

Pandoc version?

$ pandoc --version
pandoc 3.1.11.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/kamil/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
jgm commented 1 week ago

Pandoc's algorithm for creating ids automatically is documented in the manual.

It isn't "wrong," it's just not what you're expecting.

Here are some things you can do:

  1. Specify the id explicitly: ### _section {#_section}
  2. Use -f markdown+gfm_auto_identifiers