ses-pdf 0.2.0

Professional PDF report engine for structural engineering calculations and drawing sheets — equations, tables, charts, Arch sizes, and title blocks via Typst.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Escape Typst special characters in plain text content.
/// Math strings must NOT be passed through this — they are placed inside `$...$` verbatim.
pub(crate) fn escape_text(s: &str) -> String {
    let mut out = String::with_capacity(s.len());
    for ch in s.chars() {
        match ch {
            '#' | '@' | '_' | '*' | '[' | ']' | '<' | '>' | '\\' | '~' | '`' => {
                out.push('\\');
                out.push(ch);
            }
            _ => out.push(ch),
        }
    }
    out
}