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

Ignore unknown lexers #116

Closed
Julian opened this issue Aug 28, 2018 · 2 comments · Fixed by #256
Closed

Ignore unknown lexers #116

Julian opened this issue Aug 28, 2018 · 2 comments · Fixed by #256

Comments

@Julian
Copy link

Julian commented Aug 28, 2018

Given a lexer that Pygments doesn't know about (a common one being TOML), it'd be great if readme_renderer / PyPI simply rendered the block as fixed-width text without highlighting, and didn't complain / break.

GitHub and other places that reST might be being rendered (like within Sphinx) often have additional language support, and so I often will use some additional languages, even though they might not fully render with highlighting in other places.

@theacodes
Copy link
Member

Seems pretty reasonable to me.

@di
Copy link
Member

di commented May 15, 2019

This behavior is due to docutils, it doesn't fall back on any other lexer if a given lexer is not found (see http://docutils.sourceforge.net/sandbox/gitpull/setuptools/docutils/utils/code_analyzer.py)

We could fix this in readme_renderer by attempting to render the document again with the tokennames == 'none' setting set, but this would cause all code-blocks to render as literal blocks if a single unknown lexer is found.

Personally I think we should just fail here: the user is asking us to highlight with a specific language, and we can't.

miketheman added a commit to miketheman/readme_renderer that referenced this issue Aug 21, 2022
In previous versions, this example would error, but now emits a code
block. If the end user includes a syntax that Pygments does not
implement yet, or makes a mistake, the resulting HTML will be valid and
succeed, but may not be as pretty as other code blocks.

Resolves: pypa#116
Refs: pypa#168

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
miketheman added a commit to miketheman/readme_renderer that referenced this issue Aug 21, 2022
In previous versions, this example would error, but now emits a code
block. If the end user includes a syntax that Pygments does not
implement yet, or makes a mistake, the resulting HTML will be valid and
succeed, but may not be as pretty as other code blocks.

Resolves: pypa#116
Refs: pypa#168

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants