-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for any language: #5
Conversation
Use the file extension as the language class for highlight.js appears to support file extensions as language classes, see: https://github.com/highlightjs/highlight.js#supported-languages
It appears I'll see if the correct info can be extracted using the Pygments API: https://pygments.org/ |
Thanks for looking into this - it's a good idea. I'd be interested to see if there's a suitable source for the extension->language mapping. |
It must be more accurate than the file extension.
It seems Pygments provides such a mapping through a pair of |
self.assertEquals('rust', get_lang_class('HelloWorld.rs')) | ||
self.assertEquals('docker', get_lang_class('Dockerfile')) | ||
self.assertEquals('xml', get_lang_class('HelloWorld.xml')) | ||
self.assertEquals('toml', get_lang_class('HelloWorld.toml')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the test seems to fail on this line - I wonder if there's varying support for the toml
extension in different versions of pygments.
> self.assertEquals('toml', get_lang_class('HelloWorld.toml'))
E AssertionError: 'toml' != 'none'
E - toml
E + none
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems I used Pygments~=2.5
or newer, which version fails for you? Would it make sense to require a certain version of it, or just remove this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failure when running this through pytest
...
Auto-detect the source language and the alias to use using the Pygments API.