plesty.lib.report.markup
The inline markup of report text, parsed once for every renderer.
Four marks and nothing else: **bold**, *italic*, `code` and
$math$. Math and code are taken literally — no mark is read inside them —
and \$ is a dollar sign rather than the start of math. A mark that is
never closed is text.
Attributes
Classes
One piece of inline text. |
Functions
|
Split text into spans. |
|
Split text into paragraphs at blank lines, each with its lines joined. |
|
Return text with its marks removed, for a place that cannot show them. |
|
Return parsed spans as plain text, as |
|
Return a math expression as plain text: symbols as characters, no markup. |
|
Turn |
Module Contents
- plesty.lib.report.markup._MARK
- class plesty.lib.report.markup.Span
One piece of inline text.
- Variables:
kind –
"text","math","code","bold"or"italic".text – The literal text of a text, math or code span.
children – The spans inside a bold or italic span.
- kind: str
- text: str = ''
- plesty.lib.report.markup.parse(text: str) list[Span]
Split text into spans.
- Parameters:
text (str) – Inline text with marks.
- Returns:
The spans, in order; plain text between marks is a
"text"span.- Return type:
list[Span]
- plesty.lib.report.markup.paragraphs(text: str) list[str]
Split text into paragraphs at blank lines, each with its lines joined.
- Parameters:
text (str)
- Return type:
list[str]
- plesty.lib.report.markup.plain(text: str) str
Return text with its marks removed, for a place that cannot show them.
An axis label or a legend entry in a figure is one line of plain text, so
$\Delta E$ (µeV)becomesΔE (µeV): math loses its dollars, a handful of common commands become their characters, and the rest of a command’s backslash is dropped.- Parameters:
text (str)
- Return type:
str
- plesty.lib.report.markup.plain_spans(spans: list[Span]) str
Return parsed spans as plain text, as
plain()does.- Parameters:
spans (list[Span])
- Return type:
str
- plesty.lib.report.markup._SYMBOLS
- plesty.lib.report.markup._plain_math(tex: str) str
Return a math expression as plain text: symbols as characters, no markup.
- Parameters:
tex (str)
- Return type:
str
- plesty.lib.report.markup._unescape(text: str) str
Turn
\$back into a dollar sign in plain text.- Parameters:
text (str)
- Return type:
str