plesty.lib.report.markup ======================== .. py:module:: plesty.lib.report.markup .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: plesty.lib.report.markup._MARK plesty.lib.report.markup._SYMBOLS Classes ------- .. autoapisummary:: plesty.lib.report.markup.Span Functions --------- .. autoapisummary:: plesty.lib.report.markup.parse plesty.lib.report.markup.paragraphs plesty.lib.report.markup.plain plesty.lib.report.markup.plain_spans plesty.lib.report.markup._plain_math plesty.lib.report.markup._unescape Module Contents --------------- .. py:data:: _MARK .. py:class:: Span One piece of inline text. :ivar kind: ``"text"``, ``"math"``, ``"code"``, ``"bold"`` or ``"italic"``. :ivar text: The literal text of a text, math or code span. :ivar children: The spans inside a bold or italic span. .. py:attribute:: kind :type: str .. py:attribute:: text :type: str :value: '' .. py:attribute:: children :type: list[Span] :value: [] .. py:function:: parse(text: str) -> list[Span] Split *text* into spans. :param text: Inline text with marks. :returns: The spans, in order; plain text between marks is a ``"text"`` span. .. py:function:: paragraphs(text: str) -> list[str] Split *text* into paragraphs at blank lines, each with its lines joined. .. py:function:: 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. .. py:function:: plain_spans(spans: list[Span]) -> str Return parsed spans as plain text, as :func:`plain` does. .. py:data:: _SYMBOLS .. py:function:: _plain_math(tex: str) -> str Return a math expression as plain text: symbols as characters, no markup. .. py:function:: _unescape(text: str) -> str Turn ``\$`` back into a dollar sign in plain text.