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

Link contains subscript: md2html #8981

Closed
anasram opened this issue Aug 2, 2023 · 2 comments
Closed

Link contains subscript: md2html #8981

anasram opened this issue Aug 2, 2023 · 2 comments
Labels

Comments

@anasram
Copy link

anasram commented Aug 2, 2023

Pandoc version: 3.1.6

I'm trying to convert a markdown file to HTML.

The markdown file looks like this:

Lorem ipsum dolor sit amet, consectetur [^\[link\]^](#ref "Title")
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.

Using the following command:

pandoc -f markdown -t html "markdown.md" -o "output.html";

The result was:

<p>Lorem ipsum dolor sit amet, consectetur [^\[link\]^](#ref “Title”)
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.</p>

While, when I put ^ outside the link, it works properly:

<p>Lorem ipsum dolor sit amet, consectetur <sup><a href="#ref"
title="Title">[link]</a></sup> adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.</p>

Seems like:

  • When a link contains a subscript: 🗷
  • When a subscript contains a link: 🗹
@anasram anasram added the bug label Aug 2, 2023
@jgm
Copy link
Owner

jgm commented Aug 4, 2023

The cause is this code at l. 1815 of the Markdown reader:

-- a reference label for a link
reference :: PandocMonad m => MarkdownParser m (F Inlines, Text)
reference = do
  guardDisabled Ext_footnotes <|> notFollowedBy' (string "[^")
  withRaw $ trimInlinesF <$> inlinesInBalancedBrackets

This is to prevent

hello[^noteref]

from being parsed as a link -- instead it is a footnote reference.

There may be a less heavy-handed way of handling this.

@jgm
Copy link
Owner

jgm commented Aug 5, 2023

Workaround: add spaces

[ ^\[link\]^ ](#ref "Title")

@jgm jgm closed this as completed in 5e66811 Oct 20, 2023
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

2 participants