// SPDX-License-Identifier: Prosperity-3.0.0
// Copyright Scientific Computing Studio
// Source: https://git.scient.ing/education/coursebank
//! Converting the authoring markup into HTML, plain text, and Typst.
//!
//! Stems are written in a small markup that is a subset of Typst with a few
//! Markdown conveniences, because chemistry and biology questions need
//! subscripts, arrows, and Greek letters, and typing HTML entities into YAML by
//! hand is miserable.
//!
//! There is no regular expression engine here. Every rule is a scan, which keeps
//! the dependency list short and makes the escaping order explicit: HTML is
//! escaped *first*, then symbol substitutions run, so that a substitution
//! producing `→` is not itself escaped into `→`.
/// Symbol substitutions, applied after HTML escaping.
///
/// Ordered longest-first within each family so `#sym.arrow.r` is not consumed by
/// a shorter prefix.
const SYMBOLS: &[(&str, &str, &str)] = &[
// (source token, html, plain text)
("#sym.gt.eq", "≥", "\u{2265}"),
("#sym.lt.eq", "≤", "\u{2264}"),
("#sym.eq.not", "≠", "\u{2260}"),
("#sym.plus.minus", "±", "\u{00b1}"),
("#sym.arrow.r", "→", "\u{2192}"),
("#sym.arrow.l", "←", "\u{2190}"),
("#sym.arrow.lr", "↔", "\u{2194}"),
("#sym.rightarrow", "→", "\u{2192}"),
("#sym.leftarrow", "←", "\u{2190}"),
("#sym.times", "×", "\u{00d7}"),
("#sym.dot", "·", "\u{00b7}"),
("#sym.degree", "°", "\u{00b0}"),
("#sym.infinity", "∞", "\u{221e}"),
("#sym.approx", "≈", "\u{2248}"),
("#sym.alpha", "α", "\u{03b1}"),
("#sym.beta", "β", "\u{03b2}"),
("#sym.gamma", "γ", "\u{03b3}"),
("#sym.delta.cap", "Δ", "\u{0394}"),
("#sym.delta", "δ", "\u{03b4}"),
("#sym.epsilon", "ε", "\u{03b5}"),
("#sym.lambda", "λ", "\u{03bb}"),
("#sym.mu", "μ", "\u{03bc}"),
("#sym.pi", "π", "\u{03c0}"),
("#sym.sigma", "σ", "\u{03c3}"),
("#sym.tau", "τ", "\u{03c4}"),
("#sym.phi", "φ", "\u{03c6}"),
("#sym.omega", "ω", "\u{03c9}"),
];
/// Converts authoring markup to an HTML fragment.
///
/// Handles paragraphs, bold, italic, inline code, subscripts, superscripts, and
/// the symbol table. Anything unrecognized passes through escaped, so a stray
/// `");
assert!(!out.contains("