fix: rendering in typst
Pipeline / check (pull_request) Successful in 3m8s
Pipeline / docs (pull_request) Skipped
Pipeline / nightly (pull_request) Skipped
Pipeline / release (pull_request) Skipped

This commit is contained in:
2026-09-22 00:19:40 -04:00
parent 003340dc6f
commit cfe8a3216c
8 changed files with 414 additions and 81 deletions
+47
View File
@@ -1031,6 +1031,17 @@ fn render(
}
let mut warnings = Vec::new();
for (slot, body) in &bodies {
if crate::markup::needs_chem_import(&template.source, body) {
warnings.push(format!(
"the `{}` slot carries a chemical formula, but the template {} does not import \
whalogen, so Typst will stop at `unknown variable: ce`; add `{}`",
slot.as_str(),
template.origin,
crate::markup::CHEM_IMPORT
));
}
}
if template.is_inert() {
warnings.push(format!(
"the template {} declares no coursebank markers, so the report is empty; add `// \
@@ -1213,6 +1224,42 @@ mod tests {
}
}
#[test]
fn report_markup_takes_the_same_path_as_a_paper() {
for source in [
"$\\ce{H2O <=> H+ + OH-}$",
"the backbone $\\ce{-C=O}$ group",
"$K_w = [\\text{H}^+][\\text{OH}^-]$",
"see @fig:x where x < y",
"costs \\$5, and just $5",
] {
let expected = crate::markup::to_typst(source);
assert_eq!(
markup_value(source, true).to_typst(0),
format!("[{expected}]"),
"content mode diverged on {source:?}"
);
assert_eq!(
markup_value(source, false).to_typst(0),
Value::str(expected).to_typst(0),
"string mode diverged on {source:?}"
);
}
}
#[test]
fn a_report_carrying_chemistry_names_a_template_missing_the_import() {
let body = "#let cb-data = (stem: [#ce(\"H2O\")])";
assert!(crate::markup::needs_chem_import(
"#import \"@preview/mitex:0.2.7\": mi\n// coursebank:data\n",
body
));
assert!(!crate::markup::needs_chem_import(
crate::markup::CHEM_IMPORT,
body
));
}
#[test]
fn the_headline_leads_with_the_distribution() {
let lines = headline(&empty_cohort());