-
Notifications
You must be signed in to change notification settings - Fork 766
Closed
Milestone
Description
If I have the following Sphinx source:
Do the following in your Python shell:
.. sourcecode:: pycon
>>> for i in range(3):
... print(i)
...
0
1
2
You can also run the following code as a script:
.. sourcecode:: pycon
for i in range(3):
print(i)
This will output:
.. sourcecode:: text
0
1
2the output in the first code snippet is marked up with Token.Generic.Output, but the output of the second code snippet is marked up with Token.Text (in fact it isn't marked up at all).
In my current style the result looks like this:
i.e. both outputs look different. I could of course use the console lexer for the second output and hope that the lexer doesn't find anything that it will interpret as a prompt. The better solution however would be to have a new lexer that simply outputs everything marked up with the token Token.Generic.Output.
Code for that might look something like this:
class OutputLexer(lexer.Lexer):
"""
Simple lexer that highlights everything as output.
"""
name = 'Text output'
aliases = ['output']
filenames = ['*.txt']
mimetypes = ['text/plain']
priority = 0.005
def get_tokens_unprocessed(self, text):
yield 0, token.Generic.Output, text
def analyse_text(text):
return OutpuLexer.priorityIf this is accepted I can work on a pull request implementing OutputLexer.
Metadata
Metadata
Assignees
Labels
No labels
