Improve docutils.utils (#14122)

This commit is contained in:
Semyon Moroz
2025-05-22 10:31:38 +00:00
committed by GitHub
parent fbc3c33ba2
commit d168883e0f
16 changed files with 951 additions and 9 deletions
+1
View File
@@ -88,6 +88,7 @@ class Node:
# Left out
# - def ensure_str (deprecated)
# - def unescape (canonical import from docutils.utils)
def unescape(text: str, restore_backslashes: bool = False, respect_whitespace: bool = False) -> str: ...
class Text(Node, str):
tagname: ClassVar[str]
+9 -8
View File
@@ -2,25 +2,29 @@ import optparse
from _typeshed import StrPath, SupportsWrite, Unused
from collections.abc import Callable, Iterable, Mapping
from re import Pattern
from typing import Any, Literal, TypeVar
from typing import Any, Final, Literal, TypeVar
from typing_extensions import TypeAlias
from docutils import ApplicationError, DataError, nodes
from docutils.frontend import Values
from docutils.io import ErrorOutput, FileOutput
from docutils.nodes import document
from docutils.nodes import document, unescape as unescape
_T = TypeVar("_T")
_Observer: TypeAlias = Callable[[nodes.system_message], object]
_SystemMessageLevel: TypeAlias = Literal[0, 1, 2, 3, 4]
__docformat__: Final = "reStructuredText"
class DependencyList:
list: list[str]
file: FileOutput | None
def __init__(self, output_file: str | None = None, dependencies: Iterable[str] = ()) -> None: ...
def set_output(self, output_file: str | None) -> None: ...
def add(self, *filenames: str) -> None: ...
def add(self, *paths: str) -> None: ...
def close(self) -> None: ...
_SystemMessageLevel: TypeAlias = Literal[0, 1, 2, 3, 4]
class SystemMessagePropagation(ApplicationError): ...
class Reporter:
levels: list[str]
@@ -127,13 +131,10 @@ def column_indices(text: str) -> list[int]: ...
east_asian_widths: dict[str, int]
def column_width(text: str) -> int: ...
_T = TypeVar("_T")
def uniq(L: list[_T]) -> list[_T]: ...
def normalize_language_tag(tag: str) -> list[str]: ...
def xml_declaration(encoding: str | None = None) -> str: ...
release_level_abbreviations: dict[str, str]
def version_identifier(version_info: tuple[int, int, int, str, int, bool] | None = None) -> str: ...
def unescape(text: str, restore_backslashes: bool = False, respect_whitespace: bool = False) -> str: ...
@@ -0,0 +1,28 @@
from collections.abc import Generator, Iterable
from typing import Literal
from typing_extensions import TypeAlias
from docutils import ApplicationError
_TokenNames: TypeAlias = Literal["long", "short", "none"]
with_pygments: bool
unstyled_tokens: list[str]
class LexerError(ApplicationError): ...
class Lexer:
code: str
language: str
tokennames: _TokenNames
lexer: Lexer | None
def __init__(self, code: str, language: str, tokennames: _TokenNames = "short") -> None: ...
def merge(self, tokens: Iterable[tuple[_TokenNames, str]]) -> Generator[tuple[_TokenNames, str]]: ...
def __iter__(self) -> Generator[tuple[list[str], str]]: ...
class NumberLines:
tokens: Iterable[tuple[list[str], str]]
startline: int
fmt_str: str
def __init__(self, tokens: Iterable[tuple[list[str], str]], startline: int, endline: int) -> None: ...
def __iter__(self) -> Generator[tuple[list[str], str]]: ...
@@ -0,0 +1,41 @@
from io import TextIOWrapper
from typing import TextIO
from typing_extensions import TypeAlias, deprecated
unicode = str
_DataType: TypeAlias = str | Exception
@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
class SafeString:
data: object
encoding: str
encoding_errors: str
decoding_errors: str
def __init__(
self,
data: object,
encoding: str | None = None,
encoding_errors: str = "backslashreplace",
decoding_errors: str = "replace",
) -> None: ...
def __unicode__(self) -> str: ...
@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
class ErrorString(SafeString): ...
@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
class ErrorOutput:
stream: TextIO | TextIOWrapper
encoding: str
encoding_errors: str
decoding_errors: str
def __init__(
self,
stream=None,
encoding: str | None = None,
encoding_errors: str = "backslashreplace",
decoding_errors: str = "replace",
) -> None: ...
def write(self, data: _DataType) -> None: ...
def close(self) -> None: ...
@@ -0,0 +1,11 @@
from typing import Literal
from docutils.nodes import Node
class MathError(ValueError):
details: list[Node]
def __init__(self, msg: object, details: list[Node] = []) -> None: ...
def toplevel_code(code: str) -> str: ...
def pick_math_environment(code: str, numbered: bool = False) -> Literal["align*", "equation*", "align", "equation"]: ...
def wrap_math_code(code: str, as_block: bool | None) -> str: ...
@@ -0,0 +1,44 @@
from collections.abc import Iterable
from docutils.utils.math.mathml_elements import MathElement, mover, msub, msubsup, msup, mtd, munder, munderover
letters: dict[str, str]
ordinary: dict[str, str]
greek_capitals: dict[str, str]
functions: dict[str, str | None]
modulo_functions: dict[str, tuple[bool, bool, bool, str]]
math_alphabets: dict[str, str]
stretchables: dict[str, str]
operators: dict[str, str]
thick_operators: dict[str, str]
small_operators: dict[str, str]
movablelimits: tuple[str, ...]
spaces: dict[str, str]
accents: dict[str, str]
over: dict[str, tuple[str, float]]
under: dict[str, tuple[str, float]]
anomalous_chars: dict[str, str]
mathbb: dict[str, str]
matrices: dict[str, tuple[str, str]]
layout_styles: dict[str, dict[str, bool | int]]
fractions: dict[str, dict[str, bool | int | str] | dict[str, bool | int] | dict[str, int]]
delimiter_sizes: list[str]
bigdelimiters: dict[str, int]
def tex_cmdname(string: str) -> tuple[str, str]: ...
def tex_number(string: str) -> tuple[str, str]: ...
def tex_token(string: str) -> tuple[str, str]: ...
def tex_group(string: str) -> tuple[str, str]: ...
def tex_token_or_group(string: str) -> tuple[str, str]: ...
def tex_optarg(string: str) -> tuple[str, str]: ...
def parse_latex_math(root: MathElement, source: str) -> MathElement: ...
def handle_cmd(name: str, node: MathElement, string: str) -> tuple[MathElement, str]: ...
def handle_math_alphabet(name: str, node: MathElement, string: str) -> tuple[MathElement, str]: ...
def handle_script_or_limit(
node: MathElement, c: str, limits: str = ""
) -> munderover | msubsup | munder | msub | mover | msup: ...
def begin_environment(node: MathElement, string: str) -> tuple[mtd, str]: ...
def end_environment(node: MathElement, string: str) -> tuple[MathElement, str]: ...
def tex_equation_columns(rows: Iterable[str]) -> int: ...
def align_attributes(rows: Iterable[str]) -> dict[str, str | bool]: ...
def tex2mathml(tex_math: str, as_block: bool = False) -> str: ...
@@ -0,0 +1,635 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import ClassVar, Final, TextIO, TypeVar
_T = TypeVar("_T")
__version__: Final[str]
class Trace:
debugmode: ClassVar[bool]
quietmode: ClassVar[bool]
showlinesmode: ClassVar[bool]
prefix: ClassVar[str | None]
@classmethod
def debug(cls, message: str) -> None: ...
@classmethod
def message(cls, message: str) -> None: ...
@classmethod
def error(cls, message: str) -> None: ...
@classmethod
def show(cls, message: str, channel: TextIO) -> None: ...
class ContainerConfig:
extracttext: ClassVar[dict[str, list[str]]]
class EscapeConfig:
chars: ClassVar[dict[str, str]]
entities: ClassVar[dict[str, str]]
class FormulaConfig:
alphacommands: ClassVar[dict[str, str]]
array: ClassVar[dict[str, str]]
bigbrackets: ClassVar[dict[str, list[str]]]
bracketcommands: ClassVar[dict[str, str]]
combiningfunctions: ClassVar[dict[str, str]]
commands: ClassVar[dict[str, str]]
cmddict: ClassVar[dict[str, str]]
oversetfunctions: ClassVar[dict[str, str]]
undersetfunctions: ClassVar[dict[str, str]]
endings: ClassVar[dict[str, str]]
environments: ClassVar[dict[str, list[str]]]
fontfunctions: ClassVar[dict[str, str]]
hybridfunctions: ClassVar[dict[str, list[str]]]
hybridsizes: ClassVar[dict[str, str]]
labelfunctions: ClassVar[dict[str, str]]
limitcommands: ClassVar[dict[str, str]]
modified: ClassVar[dict[str, str]]
onefunctions: ClassVar[dict[str, str]]
spacedcommands: ClassVar[dict[str, str]]
starts: ClassVar[dict[str, str]]
symbolfunctions: ClassVar[dict[str, str]]
textfunctions: ClassVar[dict[str, str]]
unmodified: ClassVar[dict[str, list[str]]]
class CommandLineParser:
options: Incomplete
def __init__(self, options) -> None: ...
def parseoptions(self, args): ...
def readoption(self, args): ...
def readquoted(self, args, initial): ...
def readequalskey(self, arg, args): ...
class Options:
location: Incomplete
debug: bool
quiet: bool
version: bool
help: bool
simplemath: bool
showlines: bool
branches: Incomplete
def parseoptions(self, args) -> None: ...
def processoptions(self) -> None: ...
def usage(self) -> None: ...
def showoptions(self) -> None: ...
def showversion(self) -> None: ...
class Cloner:
@classmethod
def clone(cls, original: _T) -> _T: ...
@classmethod
def create(cls, type: type[_T]) -> _T: ...
class ContainerExtractor:
allowed: Incomplete
extracted: Incomplete
def __init__(self, config) -> None: ...
def extract(self, container): ...
def process(self, container, list) -> None: ...
def safeclone(self, container): ...
class Parser:
begin: int
parameters: Incomplete
def __init__(self) -> None: ...
def parseheader(self, reader): ...
def parseparameter(self, reader) -> None: ...
def parseending(self, reader, process) -> None: ...
def parsecontainer(self, reader, contents) -> None: ...
class LoneCommand(Parser):
def parse(self, reader): ...
class TextParser(Parser):
stack: Incomplete
ending: Incomplete
endings: Incomplete
def __init__(self, container) -> None: ...
def parse(self, reader): ...
def isending(self, reader): ...
class ExcludingParser(Parser):
def parse(self, reader): ...
class BoundedParser(ExcludingParser):
def parse(self, reader): ...
class BoundedDummy(Parser):
def parse(self, reader): ...
class StringParser(Parser):
begin: Incomplete
def parseheader(self, reader): ...
def parse(self, reader): ...
class ContainerOutput:
def gethtml(self, container) -> None: ...
def isempty(self): ...
class EmptyOutput(ContainerOutput):
def gethtml(self, container): ...
def isempty(self): ...
class FixedOutput(ContainerOutput):
def gethtml(self, container): ...
class ContentsOutput(ContainerOutput):
def gethtml(self, container): ...
class TaggedOutput(ContentsOutput):
tag: Incomplete
breaklines: bool
empty: bool
def settag(self, tag, breaklines: bool = False, empty: bool = False): ...
def setbreaklines(self, breaklines): ...
def gethtml(self, container): ...
def open(self, container): ...
def close(self, container): ...
def selfclosing(self, container): ...
def checktag(self, container): ...
class FilteredOutput(ContentsOutput):
filters: Incomplete
def __init__(self) -> None: ...
def addfilter(self, original, replacement) -> None: ...
def gethtml(self, container): ...
def filter(self, line): ...
class StringOutput(ContainerOutput):
def gethtml(self, container): ...
class Globable:
leavepending: bool
endinglist: Incomplete
def __init__(self) -> None: ...
def checkbytemark(self) -> None: ...
def isout(self): ...
def current(self): ...
def checkfor(self, string): ...
def finished(self): ...
def skipcurrent(self): ...
def glob(self, currentcheck): ...
def globalpha(self): ...
def globnumber(self): ...
def isidentifier(self): ...
def globidentifier(self): ...
def isvalue(self): ...
def globvalue(self): ...
def skipspace(self): ...
def globincluding(self, magicchar): ...
def globexcluding(self, excluded): ...
def pushending(self, ending, optional: bool = False) -> None: ...
def popending(self, expected: Incomplete | None = None): ...
def nextending(self): ...
class EndingList:
endings: Incomplete
def __init__(self) -> None: ...
def add(self, ending, optional: bool = False) -> None: ...
def pickpending(self, pos) -> None: ...
def checkin(self, pos): ...
def pop(self, pos): ...
def findending(self, pos): ...
def checkpending(self) -> None: ...
class PositionEnding:
ending: Incomplete
optional: Incomplete
def __init__(self, ending, optional) -> None: ...
def checkin(self, pos): ...
class Position(Globable):
def __init__(self) -> None: ...
def skip(self, string) -> None: ...
def identifier(self): ...
def extract(self, length) -> None: ...
def checkfor(self, string): ...
def checkforlower(self, string): ...
def skipcurrent(self): ...
def __next__(self): ...
def checkskip(self, string): ...
def error(self, message) -> None: ...
class TextPosition(Position):
pos: int
text: Incomplete
def __init__(self, text) -> None: ...
def skip(self, string) -> None: ...
def identifier(self): ...
def isout(self): ...
def current(self): ...
def extract(self, length): ...
class Container:
partkey: Incomplete
parent: Incomplete
begin: Incomplete
contents: Incomplete
def __init__(self) -> None: ...
def process(self) -> None: ...
def gethtml(self): ...
def escape(self, line, replacements={"&": "&amp;", "<": "&lt;", ">": "&gt;"}): ...
def escapeentities(self, line): ...
def searchall(self, type): ...
def searchremove(self, type): ...
def searchprocess(self, type, process): ...
def locateprocess(self, locate, process) -> None: ...
def recursivesearch(self, locate, recursive, process) -> None: ...
def extracttext(self): ...
def group(self, index, group, isingroup) -> None: ...
def remove(self, index) -> None: ...
def tree(self, level: int = 0) -> None: ...
def getparameter(self, name): ...
def getparameterlist(self, name): ...
def hasemptyoutput(self): ...
class BlackBox(Container):
parser: Incomplete
output: Incomplete
contents: Incomplete
def __init__(self) -> None: ...
class StringContainer(Container):
parsed: Incomplete
parser: Incomplete
output: Incomplete
string: str
def __init__(self) -> None: ...
def process(self) -> None: ...
def replacespecial(self, line): ...
def changeline(self, line): ...
def extracttext(self): ...
class Constant(StringContainer):
contents: Incomplete
string: Incomplete
output: Incomplete
def __init__(self, text) -> None: ...
class DocumentParameters:
displaymode: bool
class FormulaParser(Parser):
begin: Incomplete
def parseheader(self, reader): ...
def parsetype(self, reader): ...
def parse(self, reader): ...
def parseformula(self, reader): ...
def parsesingleliner(self, reader, start, ending): ...
def parsemultiliner(self, reader, start, ending): ...
class FormulaBit(Container):
type: str | None
size: int
original: str
contents: Incomplete
output: Incomplete
def __init__(self) -> None: ...
factory: Incomplete
def setfactory(self, factory): ...
def add(self, bit) -> None: ...
def skiporiginal(self, string, pos) -> None: ...
def computesize(self): ...
def clone(self): ...
class TaggedBit(FormulaBit):
output: Incomplete
def constant(self, constant, tag): ...
contents: Incomplete
def complete(self, contents, tag, breaklines: bool = False): ...
def selfcomplete(self, tag): ...
class FormulaConstant(Constant):
original: Incomplete
size: int
type: str | None
def __init__(self, string) -> None: ...
def computesize(self): ...
def clone(self): ...
class RawText(FormulaBit):
def detect(self, pos): ...
def parsebit(self, pos) -> None: ...
class FormulaSymbol(FormulaBit):
modified: Incomplete
unmodified: Incomplete
def detect(self, pos): ...
def parsebit(self, pos) -> None: ...
def addsymbol(self, symbol, pos) -> None: ...
class FormulaNumber(FormulaBit):
def detect(self, pos): ...
def parsebit(self, pos): ...
class Comment(FormulaBit):
start: Incomplete
def detect(self, pos): ...
def parsebit(self, pos) -> None: ...
class WhiteSpace(FormulaBit):
def detect(self, pos): ...
def parsebit(self, pos) -> None: ...
class Bracket(FormulaBit):
start: Incomplete
ending: Incomplete
inner: Incomplete
def __init__(self) -> None: ...
def detect(self, pos): ...
def parsebit(self, pos): ...
def parsetext(self, pos): ...
def parseliteral(self, pos): ...
def parsecomplete(self, pos, innerparser) -> None: ...
def innerformula(self, pos) -> None: ...
def innertext(self, pos) -> None: ...
literal: str
def innerliteral(self, pos) -> None: ...
class SquareBracket(Bracket):
start: Incomplete
ending: Incomplete
def clone(self): ...
class MathsProcessor:
def process(self, contents, index) -> None: ...
class FormulaProcessor:
processors: Incomplete
def process(self, bit) -> None: ...
def processcontents(self, bit) -> None: ...
def processinsides(self, bit) -> None: ...
def traversewhole(self, formula) -> None: ...
def traverse(self, bit) -> Generator[Incomplete, Incomplete]: ...
def italicize(self, bit, contents) -> None: ...
class Formula(Container):
parser: Incomplete
output: Incomplete
def __init__(self) -> None: ...
def process(self) -> None: ...
contents: Incomplete
def classic(self) -> None: ...
def parse(self, pos): ...
header: Incomplete
def parsedollarinline(self, pos) -> None: ...
def parsedollarblock(self, pos) -> None: ...
parsed: Incomplete
def parsedollar(self, pos) -> None: ...
def parseinlineto(self, pos, limit) -> None: ...
def parseblockto(self, pos, limit) -> None: ...
def parseupto(self, pos, limit): ...
class WholeFormula(FormulaBit):
def detect(self, pos): ...
def parsebit(self, pos) -> None: ...
class FormulaFactory:
types: Incomplete
skippedtypes: Incomplete
defining: bool
instances: Incomplete
def __init__(self) -> None: ...
def detecttype(self, type, pos): ...
def instance(self, type): ...
def create(self, type): ...
def clearskipped(self, pos) -> None: ...
def skipany(self, pos): ...
def parseany(self, pos): ...
def parsetype(self, type, pos): ...
def parseformula(self, formula): ...
class FormulaCommand(FormulaBit):
types: Incomplete
start: Incomplete
commandmap: ClassVar[dict[str, str] | dict[str, list[str]] | None]
def detect(self, pos): ...
output: Incomplete
def parsebit(self, pos): ...
def parsewithcommand(self, command, pos): ...
def parsecommandtype(self, command, type, pos): ...
def extractcommand(self, pos): ...
def emptycommand(self, pos): ...
def parseupgreek(self, command, pos): ...
class CommandBit(FormulaCommand):
command: Incomplete
translated: Incomplete
def setcommand(self, command) -> None: ...
def parseparameter(self, pos): ...
def parsesquare(self, pos): ...
def parseliteral(self, pos): ...
def parsesquareliteral(self, pos): ...
def parsetext(self, pos): ...
class EmptyCommand(CommandBit):
commandmap: ClassVar[dict[str, str]]
contents: Incomplete
def parsebit(self, pos) -> None: ...
class SpacedCommand(CommandBit):
commandmap: ClassVar[dict[str, str]]
contents: Incomplete
def parsebit(self, pos) -> None: ...
class AlphaCommand(EmptyCommand):
commandmap: ClassVar[dict[str, str]]
greek_capitals: Incomplete
def parsebit(self, pos) -> None: ...
class OneParamFunction(CommandBit):
commandmap: ClassVar[dict[str, str]]
simplified: bool
output: Incomplete
def parsebit(self, pos) -> None: ...
html: Incomplete
def simplifyifpossible(self) -> None: ...
class SymbolFunction(CommandBit):
commandmap: ClassVar[dict[str, str]]
def detect(self, pos): ...
output: Incomplete
def parsebit(self, pos) -> None: ...
class TextFunction(CommandBit):
commandmap: ClassVar[dict[str, str]]
output: Incomplete
def parsebit(self, pos) -> None: ...
def process(self) -> None: ...
class FontFunction(OneParamFunction):
commandmap: ClassVar[dict[str, str]]
def process(self) -> None: ...
class BigBracket:
size: Incomplete
original: Incomplete
alignment: Incomplete
pieces: Incomplete
def __init__(self, size, bracket, alignment: str = "l") -> None: ...
def getpiece(self, index): ...
def getpiece1(self, index): ...
def getpiece3(self, index): ...
def getpiece4(self, index): ...
def getcell(self, index): ...
def getcontents(self): ...
def getsinglebracket(self): ...
class FormulaEquation(CommandBit):
piece: str
output: Incomplete
def parsebit(self, pos) -> None: ...
class FormulaCell(FormulaCommand):
alignment: Incomplete
output: Incomplete
def setalignment(self, alignment): ...
def parsebit(self, pos) -> None: ...
class FormulaRow(FormulaCommand):
cellseparator: Incomplete
alignments: Incomplete
output: Incomplete
def setalignments(self, alignments): ...
def parsebit(self, pos) -> None: ...
def createcell(self, index): ...
class MultiRowFormula(CommandBit):
rows: Incomplete
size: Incomplete
def parserows(self, pos) -> None: ...
def iteraterows(self, pos) -> Generator[Incomplete]: ...
def addempty(self) -> None: ...
def addrow(self, row) -> None: ...
class FormulaArray(MultiRowFormula):
piece: str
output: Incomplete
def parsebit(self, pos) -> None: ...
valign: str
alignments: Incomplete
def parsealignments(self, pos) -> None: ...
class FormulaMatrix(MultiRowFormula):
piece: str
output: Incomplete
valign: str
alignments: Incomplete
def parsebit(self, pos) -> None: ...
class FormulaCases(MultiRowFormula):
piece: str
output: Incomplete
alignments: Incomplete
contents: Incomplete
def parsebit(self, pos) -> None: ...
class EquationEnvironment(MultiRowFormula):
output: Incomplete
alignments: Incomplete
def parsebit(self, pos) -> None: ...
class BeginCommand(CommandBit):
commandmap: ClassVar[dict[str, str]]
types: Incomplete
size: Incomplete
def parsebit(self, pos) -> None: ...
def findbit(self, piece): ...
class CombiningFunction(OneParamFunction):
commandmap: ClassVar[dict[str, str]]
def parsebit(self, pos) -> None: ...
def parsesingleparameter(self, pos): ...
class OversetFunction(OneParamFunction):
commandmap: ClassVar[dict[str, str]]
symbol: Incomplete
parameter: Incomplete
output: Incomplete
def parsebit(self, pos) -> None: ...
class UndersetFunction(OneParamFunction):
commandmap: ClassVar[dict[str, str]]
symbol: Incomplete
parameter: Incomplete
output: Incomplete
def parsebit(self, pos) -> None: ...
class LimitCommand(EmptyCommand):
commandmap: ClassVar[dict[str, str]]
output: Incomplete
def parsebit(self, pos) -> None: ...
class LimitPreviousCommand(LimitCommand):
commandmap: ClassVar[None] # type: ignore[assignment]
output: Incomplete
def parsebit(self, pos) -> None: ...
class LimitsProcessor(MathsProcessor):
def process(self, contents, index) -> None: ...
def checklimits(self, contents, index): ...
def limitsahead(self, contents, index) -> None: ...
def modifylimits(self, contents, index) -> None: ...
def getlimit(self, contents, index): ...
def modifyscripts(self, contents, index) -> None: ...
def checkscript(self, contents, index): ...
def checkcommand(self, contents, index, type): ...
def getscript(self, contents, index): ...
class BracketCommand(OneParamFunction):
commandmap: ClassVar[dict[str, str]]
def parsebit(self, pos) -> None: ...
original: Incomplete
command: Incomplete
contents: Incomplete
def create(self, direction, character): ...
class BracketProcessor(MathsProcessor):
def process(self, contents, index): ...
def processleft(self, contents, index) -> None: ...
def checkleft(self, contents, index): ...
def checkright(self, contents, index): ...
def checkdirection(self, bit, command): ...
def findright(self, contents, index): ...
def findmax(self, contents, leftindex, rightindex): ...
def resize(self, command, size) -> None: ...
class ParameterDefinition:
parambrackets: ClassVar[list[tuple[str, str]]]
name: str
literal: bool
optional: bool
value: Incomplete
literalvalue: Incomplete
def __init__(self) -> None: ...
def parse(self, pos): ...
def read(self, pos, function) -> None: ...
class ParameterFunction(CommandBit):
params: Incomplete
def readparams(self, readtemplate, pos) -> None: ...
def paramdefs(self, readtemplate) -> Generator[Incomplete]: ...
def getparam(self, name): ...
def getvalue(self, name): ...
def getliteralvalue(self, name): ...
class HybridFunction(ParameterFunction):
commandmap: ClassVar[dict[str, list[str]]]
contents: Incomplete
def parsebit(self, pos) -> None: ...
def writeparams(self, writetemplate): ...
def writepos(self, pos): ...
def writeparam(self, pos): ...
def writefunction(self, pos): ...
def readtag(self, pos): ...
def writebracket(self, direction, character): ...
size: Incomplete
def computehybridsize(self) -> None: ...
class HybridSize:
configsizes: ClassVar[dict[str, str]]
def getsize(self, function): ...
def math2html(formula): ...
def main() -> None: ...
@@ -0,0 +1,13 @@
from typing import Final
mathbb: Final[dict[str, str]]
mathbf: Final[dict[str, str]]
mathbfit: Final[dict[str, str]]
mathcal: Final[dict[str, str]]
mathfrak: Final[dict[str, str]]
mathit: Final[dict[str, str]]
mathsf: Final[dict[str, str]]
mathsfbf: Final[dict[str, str]]
mathsfbfit: Final[dict[str, str]]
mathsfit: Final[dict[str, str]]
mathtt: Final[dict[str, str]]
@@ -0,0 +1,82 @@
import numbers
import xml.etree.ElementTree as ET
from collections.abc import Iterable
from typing import ClassVar, Final, SupportsIndex, overload
from typing_extensions import Self
GLOBAL_ATTRIBUTES: Final[tuple[str, ...]]
class MathElement(ET.Element):
nchildren: ClassVar[int | None]
parent: MathElement | None
def __init__(self, *children, **attributes: object) -> None: ... # attributes is passed to self.a_str method
@staticmethod
def a_str(v: object) -> str: ...
def set(self, key: str, value: object) -> None: ... # value is passed to self.a_str method
@overload # type: ignore[override]
def __setitem__(self, key: SupportsIndex, value: MathElement) -> None: ...
@overload # type: ignore[override]
def __setitem__(self, key: slice, value: Iterable[MathElement]) -> None: ...
def is_full(self) -> bool: ...
def close(self) -> MathElement | None: ...
def append(self, element: MathElement) -> Self: ... # type: ignore[override]
def extend(self, elements: Iterable[MathElement]) -> Self: ... # type: ignore[override]
def pop(self, index: int = -1): ...
def in_block(self) -> bool: ...
def indent_xml(self, space: str = " ", level: int = 0) -> None: ...
def unindent_xml(self) -> None: ...
def toxml(self, encoding: str | None = None) -> str: ...
class MathRow(MathElement): ...
class MathSchema(MathElement):
nchildren: ClassVar[int]
switch: bool
def __init__(self, *children, switch: bool = False, **kwargs) -> None: ...
class MathToken(MathElement):
nchildren: ClassVar[int]
text: str
def __init__(self, text: str | numbers.Number, **attributes: object) -> None: ...
class math(MathRow): ...
class mtext(MathToken): ...
class mi(MathToken): ...
class mn(MathToken): ...
class mo(MathToken): ...
class mspace(MathElement):
nchildren: ClassVar[int]
class mrow(MathRow):
def transfer_attributes(self, other) -> None: ...
class mfrac(MathSchema): ...
class msqrt(MathRow):
nchildren: ClassVar[int]
class mroot(MathSchema): ...
class mstyle(MathRow): ...
class merror(MathRow): ...
class menclose(MathRow):
nchildren: ClassVar[int]
class mpadded(MathRow): ...
class mphantom(MathRow):
nchildren: ClassVar[int]
class msub(MathSchema): ...
class msup(MathSchema): ...
class msubsup(MathSchema):
nchildren: ClassVar[int]
class munder(msub): ...
class mover(msup): ...
class munderover(msubsup): ...
class mtable(MathElement): ...
class mtr(MathRow): ...
class mtd(MathRow): ...
@@ -0,0 +1,8 @@
from typing import Final
document_template: Final[str]
def blahtexml(math_code: str, as_block: bool = False) -> str: ...
def latexml(math_code: str, as_block: bool = False) -> str: ...
def pandoc(math_code: str, as_block: bool = False) -> str: ...
def ttm(math_code: str, as_block: bool = False) -> str: ...
@@ -0,0 +1,14 @@
mathaccent: dict[str, str]
mathalpha: dict[str, str]
mathbin: dict[str, str]
mathclose: dict[str, str]
mathfence: dict[str, str]
mathop: dict[str, str]
mathopen: dict[str, str]
mathord: dict[str, str]
mathover: dict[str, str]
mathpunct: dict[str, str]
mathradical: dict[str, str]
mathrel: dict[str, str]
mathunder: dict[str, str]
space: dict[str, str]
@@ -0,0 +1 @@
uni2tex_table: dict[int, str]
@@ -0,0 +1,9 @@
from typing import Final
openers: Final[str]
closers: Final[str]
delimiters: Final[str]
closing_delimiters: Final[str]
quote_pairs: dict[str, str]
def match_chars(c1: str, c2: str) -> bool: ...
+10 -1
View File
@@ -1,4 +1,11 @@
import argparse
import re
from typing import Final, Literal
__author__: Final[str]
__version__: Final[str]
__date__: Final[str]
__copyright__: Final[str]
class RomanError(Exception): ...
class OutOfRangeError(RomanError): ...
@@ -9,6 +16,8 @@ romanNumeralMap: tuple[tuple[str, int], ...]
def toRoman(n: int) -> str: ...
romanNumeralPattern: re.Pattern[str]
romanNumeralPattern: Final[re.Pattern[str]]
def fromRoman(s: str) -> int: ...
def parse_args() -> argparse.Namespace: ...
def main() -> Literal[0]: ...
@@ -0,0 +1,44 @@
from collections.abc import Generator, Iterable
from re import Pattern
from typing import ClassVar, Final, Literal
options: Final[str]
class smartchars:
endash: ClassVar[str]
emdash: ClassVar[str]
ellipsis: ClassVar[str]
apostrophe: ClassVar[str]
quotes: ClassVar[dict[str, str | tuple[str, str, str, str]]]
language: str
def __init__(self, language: str = "en") -> None: ...
class RegularExpressions:
START_SINGLE: ClassVar[Pattern[str]]
START_DOUBLE: ClassVar[Pattern[str]]
ADJACENT_1: ClassVar[Pattern[str]]
ADJACENT_2: ClassVar[Pattern[str]]
OPEN_SINGLE: ClassVar[Pattern[str]]
OPEN_DOUBLE: ClassVar[Pattern[str]]
DECADE: ClassVar[Pattern[str]]
APOSTROPHE: ClassVar[Pattern[str]]
OPENING_SECONDARY: ClassVar[Pattern[str]]
CLOSING_SECONDARY: ClassVar[Pattern[str]]
OPENING_PRIMARY: ClassVar[Pattern[str]]
CLOSING_PRIMARY: ClassVar[Pattern[str]]
regexes: RegularExpressions
default_smartypants_attr: Final = "1"
def smartyPants(text: str, attr="1", language: str = "en") -> str: ...
def educate_tokens(text_tokens: Iterable[tuple[str, str]], attr="1", language: str = "en") -> Generator[str]: ...
def educateQuotes(text: str, language: str = "en") -> str: ...
def educateBackticks(text: str, language: str = "en") -> str: ...
def educateSingleBackticks(text: str, language: str = "en") -> str: ...
def educateDashes(text: str) -> str: ...
def educateDashesOldSchool(text: str) -> str: ...
def educateDashesOldSchoolInverted(text: str) -> str: ...
def educateEllipses(text: str) -> str: ...
def stupefyEntities(text: str, language: str = "en") -> str: ...
def processEscapes(text: str, restore: bool = False) -> str: ...
def tokenize(text: str) -> Generator[tuple[Literal["tag", "text"], str]]: ...
@@ -0,0 +1 @@
schemes: dict[str, str]