-
Notifications
You must be signed in to change notification settings - Fork 736
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
Invalid doctests causes wrong highlighting in complete code fragment #1991
Comments
Thanks for the report! I think this was simply implemented incorrectly. This is a use case for recursive highlighting - scan for the docstring first and delegate. This is the proper way to do embedding when the parent language completely controls the extent of the embed. Here's an example of rouge/lib/rouge/lexers/html.rb Line 121 in 4e47529
|
Name of the lexer
python
Code sample
A sample of the code that produces the bug (note the missing
'
in the return value of the doctest)Online sample
Version 4.1.3:
Version 4.1.0:
Additional context
Since v4.1.1 (#1932), the Python lexer supports highlight doctests. However, if the doctests are invalid, the invalid highlighting extends beyond the scope of the doctest.
While I would normally think we shouldn't expect great highlighting if the syntax is invalid, I feel like doctests are an exception: the code in question is still valid Python code, as the doctests are comments.
Perhaps we could disable doctest highlighting if an error is found? (No clue if possible in Rouge).
The text was updated successfully, but these errors were encountered: