diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-05 12:25:37 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-05 12:25:37 +0100 |
| commit | c2e458a133772a94009733040b39d58e781af977 (patch) | |
| tree | 9404ef8f4982a068f046cb772166fdb8af7c3a0b /src/syntax/ast.rs | |
| parent | 1d324235bd80fe8d1fb21b1e73ae9e3dfe918078 (diff) | |
Symbol notation
Diffstat (limited to 'src/syntax/ast.rs')
| -rw-r--r-- | src/syntax/ast.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 3c60acbb..c44fa2a0 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -85,6 +85,8 @@ pub enum MarkupNode { /// A shorthand for a unicode codepoint. For example, `~` for non-breaking /// space or `-?` for a soft hyphen. Shorthand(Shorthand), + /// Symbol notation: `:arrow:l:`. + Symbol(Symbol), /// A smart quote: `'` or `"`. SmartQuote(SmartQuote), /// Strong content: `*Strong*`. @@ -119,6 +121,7 @@ impl AstNode for MarkupNode { SyntaxKind::Text(_) => node.cast().map(Self::Text), SyntaxKind::Escape(_) => node.cast().map(Self::Escape), SyntaxKind::Shorthand(_) => node.cast().map(Self::Shorthand), + SyntaxKind::Symbol(_) => node.cast().map(Self::Symbol), SyntaxKind::SmartQuote { .. } => node.cast().map(Self::SmartQuote), SyntaxKind::Strong => node.cast().map(Self::Strong), SyntaxKind::Emph => node.cast().map(Self::Emph), @@ -141,6 +144,7 @@ impl AstNode for MarkupNode { Self::Text(v) => v.as_untyped(), Self::Escape(v) => v.as_untyped(), Self::Shorthand(v) => v.as_untyped(), + Self::Symbol(v) => v.as_untyped(), Self::SmartQuote(v) => v.as_untyped(), Self::Strong(v) => v.as_untyped(), Self::Emph(v) => v.as_untyped(), @@ -224,6 +228,21 @@ impl Shorthand { } node! { + /// Symbol notation: `:arrow:l:`. + Symbol +} + +impl Symbol { + /// Get the symbol's notation. + pub fn get(&self) -> &EcoString { + match self.0.kind() { + SyntaxKind::Symbol(v) => v, + _ => panic!("symbol is of wrong kind"), + } + } +} + +node! { /// A smart quote: `'` or `"`. SmartQuote } |
