mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Make shorthand list inspectable
This commit is contained in:
parent
9d715fd11c
commit
5f4f507ecf
@ -424,35 +424,41 @@ node! {
|
||||
}
|
||||
|
||||
impl Shorthand {
|
||||
/// A list of all shorthands.
|
||||
pub const LIST: &[(&'static str, char)] = &[
|
||||
("~", '\u{00A0}'),
|
||||
("--", '\u{2013}'),
|
||||
("---", '\u{2014}'),
|
||||
("-?", '\u{00AD}'),
|
||||
("...", '…'),
|
||||
("*", '∗'),
|
||||
("!=", '≠'),
|
||||
("<<", '≪'),
|
||||
("<<<", '⋘'),
|
||||
(">>", '≫'),
|
||||
(">>>", '⋙'),
|
||||
("<=", '≤'),
|
||||
(">=", '≥'),
|
||||
("<-", '←'),
|
||||
("->", '→'),
|
||||
("=>", '⇒'),
|
||||
("|->", '↦'),
|
||||
("|=>", '⤇'),
|
||||
("<->", '↔'),
|
||||
("<=>", '⇔'),
|
||||
(":=", '≔'),
|
||||
("[|", '⟦'),
|
||||
("|]", '⟧'),
|
||||
("||", '‖'),
|
||||
];
|
||||
|
||||
/// Get the shorthanded character.
|
||||
pub fn get(&self) -> char {
|
||||
match self.0.text().as_str() {
|
||||
"~" => '\u{00A0}',
|
||||
"--" => '\u{2013}',
|
||||
"---" => '\u{2014}',
|
||||
"-?" => '\u{00AD}',
|
||||
"..." => '…',
|
||||
"*" => '∗',
|
||||
"!=" => '≠',
|
||||
"<<" => '≪',
|
||||
"<<<" => '⋘',
|
||||
">>" => '≫',
|
||||
">>>" => '⋙',
|
||||
"<=" => '≤',
|
||||
">=" => '≥',
|
||||
"<-" => '←',
|
||||
"->" => '→',
|
||||
"=>" => '⇒',
|
||||
"|->" => '↦',
|
||||
"|=>" => '⤇',
|
||||
"<->" => '↔',
|
||||
"<=>" => '⇔',
|
||||
":=" => '≔',
|
||||
"[|" => '⟦',
|
||||
"|]" => '⟧',
|
||||
"||" => '‖',
|
||||
_ => char::default(),
|
||||
}
|
||||
let text = self.0.text().as_str();
|
||||
Self::LIST
|
||||
.iter()
|
||||
.find(|&&(s, _)| s == text)
|
||||
.map_or_else(char::default, |&(_, c)| c)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user