pypa / readme_renderer

Safely render long_description/README files in Warehouse
Apache License 2.0
158 stars 89 forks source link

Ignore unknown lexers #116

Closed Julian closed 2 years ago

Julian commented 6 years ago

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 commented 6 years ago

Seems pretty reasonable to me.

di commented 5 years ago

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.