From 6594a0f530d42209c3c6f5f6a7e56fbff93b62e5 Mon Sep 17 00:00:00 2001 From: T0mstone Date: Wed, 23 Jul 2025 14:22:16 +0200 Subject: [PATCH] Make docs align with actual behavior --- docs/src/lib.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/docs/src/lib.rs b/docs/src/lib.rs index 64f5309a2..242b65ca7 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -720,24 +720,26 @@ fn symbols_model(resolver: &dyn Resolver, group: &GroupData) -> SymbolsModel { for (variant, value, deprecation) in symbol.variants() { let value_char = value.parse::().ok(); + let shorthand = |list: &[(&'static str, char)]| { value_char.and_then(|c| { list.iter().copied().find(|&(_, x)| x == c).map(|(s, _)| s) }) }; - let base_char = base_char(value); let name = complete(variant); list.push(SymbolModel { name, markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST), math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST), - math_class: base_char.and_then(|c| { + // Matches `typst_layout::math::GlyphFragment::new` + math_class: value.chars().next().and_then(|c| { typst_utils::default_math_class(c).map(math_class_name) }), value: value.into(), - accent: base_char + // Matches casting `Symbol` to `Accent` + accent: value_char .is_some_and(|c| typst::math::Accent::combine(c).is_some()), alternates: symbol .variants() @@ -778,13 +780,6 @@ pub fn urlify(title: &str) -> EcoString { .collect() } -/// Convert a string to a `char`, ignoring any suffixed variation selectors. -fn base_char(value: &str) -> Option { - value.trim_end_matches(|c: char| { - matches!(c, '\u{180B}'..='\u{180D}' | '\u{180F}' | '\u{FE00}'..='\u{FE0F}' | '\u{E0100}'..='\u{E01EF}') - }).parse::().ok() -} - /// Extract the first line of documentation. fn oneliner(docs: &str) -> EcoString { let paragraph = docs.split("\n\n").next().unwrap_or_default();