Skip to main content

Module raw_blocks

Module raw_blocks 

Source
Expand description

Raw TeX block parsing (LaTeX commands and non-math environments)

This module handles block-level raw TeX content:

  1. LaTeX commands: \DeclareMathOperator, \newcommand, etc.
  2. Non-math environments: \begin{tabular}, \begin{figure}, etc.

Math environments (equation, align, etc.) are handled as INLINE content in paragraphs, not as blocks. See INLINE_MATH_ENVIRONMENTS list below.

Per Pandoc behavior:

  • Consecutive LaTeX command lines are grouped into a single TEX_BLOCK
  • Non-math environments become TEX_BLOCK
  • Math environments are parsed inline (in paragraphs)
  • Blank lines or non-LaTeX content terminate the block
  • Only enabled when raw_tex extension is active

Functions§

can_start_raw_block
Check if content could start a raw TeX block.
extract_environment_name
Extract environment name from \begin{name} line. Returns None if not a valid \begin{…} line.
is_inline_math_environment
Check if an environment name is an inline math environment.
parse_raw_tex_block
Parse a raw TeX block from lines array.