pyaota.generator.yaml2tex module¶
LaTeX rendering helpers for pyaota.
- pyaota.generator.yaml2tex.normalize_punctuation(s)[source]¶
Normalize Word-style Unicode punctuation to ASCII/TeX-friendly equivalents.
- Return type:
- pyaota.generator.yaml2tex.render_choice(choice, correct_key=None, highlight_correct=False, default_style=None)[source]¶
Render a single choice dict to LaTeX.
type: “text” -> choice[<label>]{<text>}
type: “code” -> inline or block via render_code_block
highlight_correct: if True, the correct choice’s LABEL is wrapped in correctlabel{…}, leaving the body (including inl) untouched.
- Return type:
- pyaota.generator.yaml2tex.render_code_block(text, style=None, force_env=True)[source]¶
Render code as either an inline or block snippet.
- When style is None (the default) the output uses plain LaTeX verbatim:
(“inline”, ‘verb|…|’) for a single nonblank line
(“block”, ‘begin{verbatim}…’) for multi-line
- When style is a listings style name the output uses listings:
(“inline”, ‘inl{…}’) single line
(“block”, ‘begin{lstlisting}[style=…]…’) multi-line
Caller decides how to embed the result.
- pyaota.generator.yaml2tex.render_mcq(q, show_id=False, highlight_correct=False, scramble_choices=False, default_style=None)[source]¶
Render a single multiple-choice question to LaTeX.
show_id: if True, prefix the first text stem block with “(ID) “.
highlight_correct: if True, visually mark the correct answer.
- Return type:
- pyaota.generator.yaml2tex.render_question(q, **kwargs)[source]¶
Render a single question dict to LaTeX, dispatching to the appropriate renderer based on question type.
- Return type:
- pyaota.generator.yaml2tex.render_stem_block(block, default_style=None)[source]¶
Render a single stem block (text, code, or image) to LaTeX.
- Return type:
- pyaota.generator.yaml2tex.render_text(s, default_style=None)[source]¶
Render a text string that may contain
inline codeand@@inline math@@markers into LaTeX.coderegions use verb|…| (verbatim mode, default_style=None) or inl{…} (listings mode, default_style set)@@math@@regions are passed through as$...$Everything else is escaped for normal text.
- Return type:
- pyaota.generator.yaml2tex.render_tf(q, show_id=False, highlight_correct=False, default_style=None)[source]¶
Render a single true/false question to LaTeX.
show_id: if True, prefix the first text stem block with “(ID) “.
highlight_correct: if True, visually mark the correct answer.
- Return type:
- pyaota.generator.yaml2tex.tex_escape_inline_code(s)[source]¶
Escape content that will go inside inl{…}.
normalize punctuation
escape %, _, {, } so TeX doesn’t get confused
- Return type: