Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section headings containing spaces in github flavored markdown link to non-existing anchors #6335

Closed
mineo opened this issue May 4, 2020 · 3 comments
Labels

Comments

@mineo
Copy link

mineo commented May 4, 2020

Input file a.wiki:

= Test Heading =

text

Pandoc call: pandoc --output=test.md -t gfm --toc --standalone a.wiki

produces

  - [Test Heading](#test_heading)

# Test Heading

text

Online: https://gist.github.com/mineo/2b21f4d1e0ffa062adaef113037c2fb8. The test heading in the TOC links to https://gist.github.com/mineo/2b21f4d1e0ffa062adaef113037c2fb8#test_heading, but clicking on the heading in the document itself changes the anchor in the URL to https://gist.github.com/mineo/2b21f4d1e0ffa062adaef113037c2fb8#test-heading. These are not the same:

diff --git a/a b/b
index ea0a751..3abb72f 100644
--- a/a
+++ b/b
@@ -1 +1 @@
-https://gist.github.com/mineo/2b21f4d1e0ffa062adaef113037c2fb8#test-heading
+https://gist.github.com/mineo/2b21f4d1e0ffa062adaef113037c2fb8#test_heading

Github converts spaces in the heading to hyphens, pandoc converts them to underscores.

@mb21
Copy link
Collaborator

mb21 commented May 4, 2020

Can you try in a github repo? possibly it's different in a gist?

@mineo
Copy link
Author

mineo commented May 4, 2020

Sure. It's the same in a repository: https://github.com/mineo/markdowntest/blob/master/test.md

@mb21 mb21 added the writer label May 4, 2020
@jgm
Copy link
Owner

jgm commented May 4, 2020

The automatic identifiers are created by the reader, not the writer. In this case, the reader format is mediawiki, so mediawiki's scheme for identifiers is used (_ instead of -).

Actually, the extension gfm_auto_identifiers should be usable with mediawiki input (-f mediawiki+gfm_auto_identifiers), but it doesn't quite work because something in the mediawiki reader special-cases a - -> _ conversion. I think I can fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants