mirror of
https://github.com/typst/typst
synced 2025-07-27 06:17:53 +08:00
docs: Ignore variation selectors for math class and accent
This commit is contained in:
parent
5e202843c1
commit
e48fe5e301
@ -720,24 +720,24 @@ fn symbols_model(resolver: &dyn Resolver, group: &GroupData) -> SymbolsModel {
|
|||||||
|
|
||||||
for (variant, value, deprecation) in symbol.variants() {
|
for (variant, value, deprecation) in symbol.variants() {
|
||||||
let value_char = value.parse::<char>().ok();
|
let value_char = value.parse::<char>().ok();
|
||||||
|
|
||||||
let shorthand = |list: &[(&'static str, char)]| {
|
let shorthand = |list: &[(&'static str, char)]| {
|
||||||
value_char.and_then(|c| {
|
value_char.and_then(|c| {
|
||||||
list.iter().copied().find(|&(_, x)| x == c).map(|(s, _)| s)
|
list.iter().copied().find(|&(_, x)| x == c).map(|(s, _)| s)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let base_char = base_char(value);
|
||||||
let name = complete(variant);
|
let name = complete(variant);
|
||||||
|
|
||||||
list.push(SymbolModel {
|
list.push(SymbolModel {
|
||||||
name,
|
name,
|
||||||
markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST),
|
markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST),
|
||||||
math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST),
|
math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST),
|
||||||
math_class: value_char.and_then(|c| {
|
math_class: base_char.and_then(|c| {
|
||||||
typst_utils::default_math_class(c).map(math_class_name)
|
typst_utils::default_math_class(c).map(math_class_name)
|
||||||
}),
|
}),
|
||||||
value: value.into(),
|
value: value.into(),
|
||||||
accent: value_char
|
accent: base_char
|
||||||
.is_some_and(|c| typst::math::Accent::combine(c).is_some()),
|
.is_some_and(|c| typst::math::Accent::combine(c).is_some()),
|
||||||
alternates: symbol
|
alternates: symbol
|
||||||
.variants()
|
.variants()
|
||||||
@ -778,6 +778,13 @@ pub fn urlify(title: &str) -> EcoString {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert a string to a `char`, ignoring any suffixed variation selectors.
|
||||||
|
fn base_char(value: &str) -> Option<char> {
|
||||||
|
value.trim_end_matches(|c: char| {
|
||||||
|
matches!(c, '\u{180B}'..='\u{180D}' | '\u{180F}' | '\u{FE00}'..='\u{FE0F}' | '\u{E0100}'..='\u{E01EF}')
|
||||||
|
}).parse::<char>().ok()
|
||||||
|
}
|
||||||
|
|
||||||
/// Extract the first line of documentation.
|
/// Extract the first line of documentation.
|
||||||
fn oneliner(docs: &str) -> EcoString {
|
fn oneliner(docs: &str) -> EcoString {
|
||||||
let paragraph = docs.split("\n\n").next().unwrap_or_default();
|
let paragraph = docs.split("\n\n").next().unwrap_or_default();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user