126.96.36.199.1.2. nikola.packages.pygments_better_html package¶
Better HTML formatter for Pygments.
Copyright © 2020-2023, Chris Warrick. License: 3-clause BSD. Portions copyright © 2006-2019, the Pygments authors. (2-clause BSD).
- class nikola.packages.pygments_better_html.BetterHtmlFormatter(**options)¶
Format tokens as HTML 4
<span>tags, with alternate formatting styles.
linenos = 'table'renders each line of code in a separate table row
linenos = 'ol'renders each line in a <li> element (inside <ol>)
Both options allow word wrap and don’t include line numbers when copying.
- aliases = ['html']¶
A list of short, unique identifiers that can be used to lookup the formatter from a list, e.g. using :func:`.get_formatter_by_name()`.
- filenames = ['*.html', '*.htm']¶
A list of fnmatch patterns that match filenames for which this formatter can produce output. The patterns in this list should be unique among all formatters.
- format_unencoded(tokensource, outfile)¶
Format code and write to outfile.
The formatting process uses several nested generators; which of them are used is determined by the user’s options.
Each generator should take at least one argument,
inner, and wrap the pieces of text generated by this.
Always yield 2-tuples: (code, text). If “code” is 1, the text is part of the original tokensource being highlighted, if it’s 0, the text is some piece of wrapping. This makes it possible to use several different wrappers that process the original source linewise, e.g. line number generators.
- get_style_defs(arg=None, wrapper_classes=None)¶
Generate CSS style definitions.
Return CSS style definitions for the classes produced by the current highlighting style.
argcan be a string or list of selectors to insert before the token type classes.
wrapper_classesare a list of classes for the wrappers, defaults to the
- name = 'HTML'¶
Full name for the formatter, in human-readable form.