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

Feature request: parse markdown comments #2273

Open
samgaudet opened this issue Nov 8, 2022 · 0 comments · May be fixed by #2316
Open

Feature request: parse markdown comments #2273

samgaudet opened this issue Nov 8, 2022 · 0 comments · May be fixed by #2316
Labels
A-lexing area: changes to individual lexers

Comments

@samgaudet
Copy link

Overview

Comments are not interpreted when parsing markdown strings.

Expected behavior

Markdown comments are parsed, similar to many other lexers. For example, in Python:

from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
code = "print('hello world')  # (1)"
print(highlight(code, PythonLexer(), HtmlFormatter()))

Produces the following string:

<div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">&#39;hello world&#39;</span><span class="p">)</span>  <span class="c1"># (1)</span>
</pre></div>

Actual behavior

Markdown comments are not parsed. The following parsing:

from pygments import highlight
from pygments.lexers import MarkdownLexer
from pygments.formatters import HtmlFormatter
markdown = "# Something <!--- (1) --->"
print(highlight(markdown, MarkdownLexer(), HtmlFormatter()))

Produces the following string:

<div class="highlight"><pre><span></span><span class="gh"># Something &lt;!--- (1) ---&gt;</span>
</pre></div>

Practical implication

Who cares? Well, pygments is popularly used within packages such as mkdocs-material to parse fenced code.
The current funcitonality limits the ability to use features of certain packages built on top of pygments, such as code annotations in mkdocs-material.

Environment

System: MacOS
pygments version: 2.13.0


Thank you in advance for taking the time to look at this, and I greatly appreciate the pygments package, as well as its development team.

@Anteru Anteru added the A-lexing area: changes to individual lexers label Nov 8, 2022
@stelcodes stelcodes linked a pull request Jan 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants