[][src]Crate rustdoc_highlight

Basic syntax highlighting functionality.

This module uses libsyntax's lexer to provide token-based highlighting for the HTML documentation generated by rustdoc.

If you just want to syntax highlighting for a Rust program, then you can use the render_inner_with_highlighting or render_with_highlighting functions. For more advanced use cases (if you want to supply your own css classes or control how the HTML is generated, or even generate something other then HTML), then you should implement the Writer trait and use a Classifier.

Structs

Classifier

Processes a program (nested in the internal lexer), classifying strings of text by highlighting category (Class). Calls out to a Writer to write each span of text in sequence.

Enums

Class

How a span of text is classified. Mostly corresponds to token kinds.

HighlightError

Traits

Writer

Trait that controls writing the output of syntax highlighting. Users should implement this trait to customise writing output.

Functions

render_inner_with_highlighting

Highlights src, returning the HTML output. Returns only the inner html to be inserted into an element. C.f., render_with_highlighting which includes an enclosing <pre> block.

render_with_highlighting

Highlights src, returning the HTML output.