Right now, in wtpython.formatters we have PythonCodeConverter which assumes all <pre> blocks are python code. This is certainly a good assumption given our code, but it's likely we'll encounter non-python code in a stackoverflow post.
Pygments appears to be able to guess a language from a code block.
https://pygments.org/docs/quickstart/#guessing-lexers
https://pygments.org/docs/api/#pygments.lexers.guess_lexer
Suggest replacing PythonCodeConverter with a PygmentsCodeConverter that will try to detect a language. If there's an issue, then python should be a fallback.
Right now, in
wtpython.formatterswe havePythonCodeConverterwhich assumes all<pre>blocks are python code. This is certainly a good assumption given our code, but it's likely we'll encounter non-python code in a stackoverflow post.Pygments appears to be able to guess a language from a code block.
https://pygments.org/docs/quickstart/#guessing-lexers
https://pygments.org/docs/api/#pygments.lexers.guess_lexer
Suggest replacing
PythonCodeConverterwith aPygmentsCodeConverterthat will try to detect a language. If there's an issue, then python should be a fallback.