fabricatio_typst.rust
Classes
Functions
|
Adds comment prefix // to each line of the string. |
|
Converts all supported TeX math expressions in a string to Typst format. |
|
Extracts the body content enclosed by exactly two wrapper strings. |
|
Extracts sections from markdown-style text by header level. |
|
Fixes misplaced labels in a string by moving them outside display math blocks. |
|
Replaces the body content enclosed by two wrapper strings. |
|
Splits metadata (YAML front matter) from a Typst document string. |
|
Removes leading and trailing comment lines from a multi-line string. |
|
Converts a raw LaTeX string to Typst format. |
|
Converts a Python object to a YAML string with comment formatting. |
|
Removes comment prefix // from each line of the string. |
Package Contents
- class fabricatio_typst.rust.BibManager
- fabricatio_typst.rust.comment(string: str) str
Adds comment prefix // to each line of the string.
- Parameters:
string – The input string to comment.
- Returns:
A string with // prepended to each line.
- fabricatio_typst.rust.convert_all_tex_math(string: str) str
Converts all supported TeX math expressions in a string to Typst format.
Handles $…$, $$…$$, (…), and […] delimiters.
- Parameters:
string – The input string containing TeX math expressions.
- Returns:
A PyResult containing the string with converted math expressions.
- fabricatio_typst.rust.extract_body(string: str, wrapper: str) str | None
Extracts the body content enclosed by exactly two wrapper strings.
- Parameters:
string – The string containing the wrapped body.
wrapper – The wrapper string that marks the beginning and end.
- Returns:
The body content if exactly one match found, None otherwise.
- fabricatio_typst.rust.extract_sections(string: str, level: int = 1, section_char: str = '#') list[tuple[str, str]]
Extracts sections from markdown-style text by header level.
- Parameters:
string – The markdown text to parse.
level – The header level to extract (e.g., 1 for #, 2 for ##).
section_char – Optional character to use as header marker (default: #).
- Returns:
A list of tuples containing (header_text, section_content).
- fabricatio_typst.rust.fix_misplaced_labels(string: str) str
Fixes misplaced labels in a string by moving them outside display math blocks.
Labels in the format <label> that appear inside […] blocks are moved to outside the block.
- Parameters:
string – The input string to fix.
- Returns:
A string with misplaced labels moved outside display math blocks.
- fabricatio_typst.rust.replace_thesis_body(string: str, wrapper: str, new_body: str) str | None
Replaces the body content enclosed by two wrapper strings.
- Parameters:
string – The original string containing the wrapped body.
wrapper – The wrapper string that marks the beginning and end.
new_body – The new body content to insert.
- Returns:
The string with the body replaced, or None if wrapper not found.
- fabricatio_typst.rust.split_out_metadata(string: str) tuple[Any | None, str]
Splits metadata (YAML front matter) from a Typst document string.
Extracts leading comment lines as YAML metadata and returns the remaining content.
- Parameters:
string – The input string with potential YAML front matter.
- Returns:
A tuple of (parsed metadata as Python object or None, remaining string content).
- fabricatio_typst.rust.strip_comment(string: str) str
Removes leading and trailing comment lines from a multi-line string.
- Parameters:
string – The input string to strip comments from.
- Returns:
A string with leading and trailing comment lines removed.
- fabricatio_typst.rust.tex_to_typst(string: str) str
Converts a raw LaTeX string to Typst format.
- Parameters:
string – The raw LaTeX string to convert.
- Returns:
A PyResult containing the converted Typst string.