omd2tex.objects package#
Submodules#
- omd2tex.objects.base module
- omd2tex.objects.citation module
- omd2tex.objects.codeblock module
- omd2tex.objects.document module
- omd2tex.objects.equation module
- omd2tex.objects.file module
- omd2tex.objects.footnote module
- omd2tex.objects.fragment module
- omd2tex.objects.headline module
- omd2tex.objects.image module
- omd2tex.objects.list module
- omd2tex.objects.makefile module
- omd2tex.objects.paragraph module
ParagraphParagraph.to_latex()Paragraph.change_letters_for_equations()Paragraph.highlight_text1()Paragraph.highlight_text2()Paragraph.replace_inline_code()Paragraph.replace_inline_equation()Paragraph.replace_outline_equation()Paragraph.restore_placeholders()Paragraph.latinify_lines()Paragraph.eq_ru_letter_workaround()Paragraph.text_errors_workaround()Paragraph.process_references()Paragraph.process_citations()Paragraph.escape_latex_special_chars()Paragraph.remove_all_highlight()Paragraph.merge_items()
- omd2tex.objects.preamble module
- omd2tex.objects.quote module
- omd2tex.objects.reference module
- omd2tex.objects.table module
Module contents#
- class omd2tex.objects.Paragraph(text: str, parse: bool = True)[source]#
Bases:
BaseClass- static change_letters_for_equations(text: str, dict_file: str = '', surround_func=<function Paragraph.<lambda>>) str[source]#
Replace symbols in equations using a mapping file and wrapper.
- Parameters:
text – Input equation text.
dict_file – Optional path to a JSON mapping file; defaults to bundled formulas.
surround_func – Callable applied to mapped values.
- Returns:
Transformed text with mapped symbols.
- static highlight_text1(text: str) str[source]#
Convert HTML superscript/subscript markers to LaTeX equivalents.
- static highlight_text2(text: str) str[source]#
Convert markdown emphasis markers to LaTeX formatting.
- static replace_inline_code(text: str) tuple[str, list][source]#
Replace inline code segments with placeholders preserving content.
- static replace_inline_equation(text: str) tuple[str, list][source]#
Replace inline equations with placeholders preserving content.
- static replace_outline_equation(text: str) tuple[str, list][source]#
Replace outline equations with placeholders preserving content.
- static restore_placeholders(text: str, inline_equations=[], inline_codes=[], outline_equations=[]) str[source]#
Restore code and equation placeholders into the provided text.
- static latinify_lines(lines: str, probability=0.05, seed=None, change_dict='') str[source]#
Randomly replace characters based on latinify mapping and probability.
- static eq_ru_letter_workaround(text: str) str[source]#
Wrap Cyrillic characters in equations with text mode to avoid errors.
- static text_errors_workaround(text: str) str[source]#
Normalize known problematic characters and dashes.
- static process_references(text: str) str[source]#
Convert wiki-style references to LaTeX cref calls using global mapping.
- static process_citations(text: str) str[source]#
Normalize citation markers to LaTeX
\cite{}commands.Supports patterns like
![[ @cite|text ]],[[ @cite ]], and\cite{@cite}, returning formatted citations or empty strings when source entries are missing.- Parameters:
text – Input string possibly containing various citation syntaxes.
- Returns:
Text with citation patterns replaced by LaTeX citations; returns empty strings when citations are missing.
- static escape_latex_special_chars(text: str) str[source]#
Escape unescaped LaTeX special characters in the provided text.
- Parameters:
text (str) – Входная строка с LaTeX-выражениями
- Returns:
Строка с экранированными специальными символами LaTeX
- Return type:
str
- class omd2tex.objects.CodeBlock(blocktype: str, blocklines: list)[source]#
Bases:
BaseClass
- class omd2tex.objects.Reference(ref_text: str)[source]#
Bases:
BaseClass
- class omd2tex.objects.Image(filename: str, parrentdir: str, caption: str = '', width: int | None = None, height: int | None = None, dir: str | None = None)[source]#
Bases:
BaseClass
- class omd2tex.objects.Quote(quotelines: List[str], filename: str = '', parrentdir='', filedepth=0, quotedepth=0)[source]#
Bases:
BaseClass- to_latex() str[source]#
Convert the quote and its elements to LaTeX.
- Parameters:
None
- Returns:
LaTeX string for the quote environment with proper indentation.
- classmethod create(quotelines: List[str], filename: str = '', parrentdir='', filedepth=0, quotedepth=0) BaseClass[source]#
Factory to create and process quote content in one step.
- Parameters:
quotelines – Raw quote lines including leading markers.
filename – Source filename for context.
parrentdir – Parent directory path for nested includes.
filedepth – Current file recursion depth.
quotedepth – Current quote recursion depth.
- Returns:
Processed element resulting from quote interpretation.
- class omd2tex.objects.Footnote[source]#
Bases:
BaseClass- collection = {}#
- class omd2tex.objects.Enumerate(text: str, depth: int, number: int = 0, complete: bool = False, reference=None)[source]#
Bases:
List
- class omd2tex.objects.Bullet(text: str, depth: int, number: int = 0, complete: bool = False, reference=None)[source]#
Bases:
List
- class omd2tex.objects.Check(text: str, depth: int, number: int = 0, complete: bool = False, reference=None)[source]#
Bases:
List
- class omd2tex.objects.List(text: str, depth: int, number: int = 0, complete: bool = False, reference=None)[source]#
Bases:
BaseClass- to_latex_item() str[source]#
Render a single list item to LaTeX.
- Returns:
LaTeX string representing the list item content.
- to_latex() str[source]#
Render the list and merged nested items to LaTeX.
- Returns:
LaTeX string for the list content, including merged sublists when present.
- append(item: List) None[source]#
Append another list item at the same depth.
- Parameters:
item – List item to append; must match depth.
- Returns:
None
- Raises:
TypeError – If item type or depth is incompatible.
- static append_items(items: list) list[source]#
Group consecutive list items of equal depth.
- Parameters:
items – Sequence of parsed elements possibly containing List instances.
- Returns:
List with grouped List items aggregated by depth.
- merge(item: List) None[source]#
Merge a deeper nested item under the current list element.
- Parameters:
item – Nested List item.
- Returns:
None
- Raises:
TypeError – If provided item is not deeper than the current one.
- class omd2tex.objects.Citation(key: str)[source]#
Bases:
BaseClass- citation_list = []#
- class omd2tex.objects.File(filename: str | None = None, parrentdir: str | None = None, filedepth: int = 0)[source]#
Bases:
BaseClass
- class omd2tex.objects.Document(filename: str = '', settings: Dict[str, Any] | str = None, preamble: str = None)[source]#
Bases:
BaseClass- to_latex_file(filename: str = '') None[source]#
Write the rendered LaTeX document to a file.
- Parameters:
filename – Optional override for output filename; defaults to derived from markdown name.
- Returns:
None
- Side Effects:
Writes LaTeX files to disk and may create makefiles.
- to_latex_project(filename='') None[source]#
Create a full LaTeX project directory with includes and assets.
- Parameters:
filename – Optional override for main filename.
- Returns:
None
- Raises:
ValueError – If the document or file is not initialized before export.
- Side Effects:
Writes multiple files/directories and copies theme assets when needed.