summaryrefslogtreecommitdiff
path: root/crates/typst-syntax/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-08-03 16:33:17 +0200
committerLaurenz <laurmaedje@gmail.com>2023-08-03 16:33:17 +0200
commit028d2f53085022c39945b1a99c9dc78eb8069d4a (patch)
treec220f3fed751c3e3b5e3c07d6246a1378b0519cb /crates/typst-syntax/src
parent53a896f049d45a8e9a225ceacd56da07854aa973 (diff)
Split markup and math shorthands for docs
Diffstat (limited to 'crates/typst-syntax/src')
-rw-r--r--crates/typst-syntax/src/ast.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs
index c2755d0c..2ea318a7 100644
--- a/crates/typst-syntax/src/ast.rs
+++ b/crates/typst-syntax/src/ast.rs
@@ -435,16 +435,18 @@ node! {
}
impl Shorthand {
- /// A list of all shorthands.
- pub const LIST: &[(&'static str, char)] = &[
- // Both.
+ /// A list of all shorthands in markup mode.
+ pub const MARKUP_LIST: &[(&'static str, char)] = &[
("...", '…'),
- // Text only.
("~", '\u{00A0}'),
("--", '\u{2013}'),
("---", '\u{2014}'),
("-?", '\u{00AD}'),
- // Math only.
+ ];
+
+ /// A list of all shorthands in math mode.
+ pub const MATH_LIST: &[(&'static str, char)] = &[
+ ("...", '…'),
("-", '\u{2212}'),
("'", '′'),
("*", '∗'),
@@ -487,8 +489,7 @@ impl Shorthand {
/// Get the shorthanded character.
pub fn get(&self) -> char {
let text = self.0.text();
- Self::LIST
- .iter()
+ (Self::MARKUP_LIST.iter().chain(Self::MATH_LIST))
.find(|&&(s, _)| s == text)
.map_or_else(char::default, |&(_, c)| c)
}