all2md.options.latex

Configuration options for LaTeX parsing and rendering.

This module defines options for LaTeX document conversion.

class all2md.options.latex.LatexOptions

Bases: BaseParserOptions

Configuration options for LaTeX-to-AST parsing.

This dataclass contains settings specific to parsing LaTeX documents into AST representation using pylatexenc library.

Parameters:
  • parse_preamble (bool, default True) – Whether to parse document preamble for metadata. When True, extracts title, author, date, etc.

  • parse_math (bool, default True) – Whether to parse math environments into MathBlock/MathInline nodes. When True, preserves LaTeX math notation in AST.

  • parse_custom_commands (bool, default False) – Whether to attempt parsing custom LaTeX commands. SECURITY: Disabled by default to prevent unexpected behavior.

  • strict_mode (bool, default False) – Whether to raise errors on invalid LaTeX syntax. When False, attempts to recover gracefully.

  • encoding (str, default "utf-8") – Text encoding to use when reading LaTeX files.

  • preserve_comments (bool, default False) – Whether to preserve LaTeX comments in the AST. When True, comments are stored in node metadata.

parse_preamble: bool = True
parse_math: bool = True
parse_custom_commands: bool = False
strict_mode: bool = False
encoding: str = 'utf-8'
preserve_comments: bool = False
__init__(extract_metadata: bool = False, parse_preamble: bool = True, parse_math: bool = True, parse_custom_commands: bool = False, strict_mode: bool = False, encoding: str = 'utf-8', preserve_comments: bool = False) None
class all2md.options.latex.LatexRendererOptions

Bases: BaseRendererOptions

Configuration options for AST-to-LaTeX rendering.

This dataclass contains settings for rendering AST documents as LaTeX output suitable for compilation with pdflatex/xelatex.

Parameters:
  • document_class (str, default "article") – LaTeX document class to use (article, report, book, etc.).

  • include_preamble (bool, default True) – Whether to generate a complete document with preamble. When False, generates only document body (for inclusion).

  • packages (list[str], default ["amsmath", "graphicx", "hyperref"]) – LaTeX packages to include in preamble.

  • math_mode ({"inline", "display"}, default "display") – Preferred math rendering mode for ambiguous cases.

  • line_width (int, default 0) – Target line width for text wrapping (0 = no wrapping).

  • escape_special (bool, default True) – Whether to escape special LaTeX characters ($, %, &, etc.). Only disable if input is already LaTeX-safe.

  • use_unicode (bool, default True) – Whether to allow Unicode characters in output. When False, uses LaTeX escapes for special characters.

  • comment_mode ({"percent", "todonotes", "marginnote", "ignore"}, default "percent") – How to render Comment and CommentInline AST nodes: - “percent”: Render as LaTeX comments (% Comment text) - “todonotes”: Use \todo{} command from todonotes package (colored margin notes) - “marginnote”: Use \marginpar{} for margin notes (simple side notes) - “ignore”: Skip comment nodes entirely This controls presentation of comments from source documents.

document_class: str = 'article'
include_preamble: bool = True
packages: list[str]
math_mode: Literal['inline', 'display'] = 'display'
line_width: int = 0
escape_special: bool = True
use_unicode: bool = True
comment_mode: Literal['percent', 'todonotes', 'marginnote', 'ignore'] = 'percent'
__init__(fail_on_resource_errors: bool = False, max_asset_size_bytes: int = 52428800, metadata_policy: MetadataRenderPolicy = <factory>, creator: str | None = 'all2md', document_class: str = 'article', include_preamble: bool = True, packages: list[str] = <factory>, math_mode: LatexMathRenderMode = 'display', line_width: int = 0, escape_special: bool = True, use_unicode: bool = True, comment_mode: LatexCommentMode = 'percent') None