5.1.1.3.3. SyntaxHighlighter

This modules provides a facility to syntax highlight a text document.

class CodeReview.Diff.SyntaxHighlighter.HighlightedText(raw_text_document, lexer)[source]

Bases: list

This class implements an highlighted text.

The parameter raw_text_document is a DiffViewer.RawTextDocument instance and the parameter lexer is a Pygments lexer instance.

class CodeReview.Diff.SyntaxHighlighter.HighlightedTextFragment(flat_slice, token)[source]

Bases: object

This class implements an highlighted text fragment.

The parameter token specifies the Pygments token type.

Public Attributes:

slice

token

CodeReview.Diff.SyntaxHighlighter.highlight_text(raw_text_document, lexer)[source]

Highlight a text.

The parameter raw_text_document is a DiffViewer.RawTextDocument instance and the parameter lexer is a Pygments lexer instance.

Return an DiffViewer.TextDocumentModel instance. The document has one text block that contains all the fragments. Text fragments use light views.