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