summaryrefslogtreecommitdiff
path: root/src/syntax
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2022-04-12 13:00:34 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-12 22:35:04 +0200
commit072543fc59582eacfd9446055639c4427e707941 (patch)
tree37cdefe123e24f1342fad0b385615d1e2e04a350 /src/syntax
parentc3a387b8f7086fc6d58a4175e8408fbbf375f5f2 (diff)
Introduce `NodeKind::Quote`
Diffstat (limited to 'src/syntax')
-rw-r--r--src/syntax/ast.rs3
-rw-r--r--src/syntax/highlight.rs1
-rw-r--r--src/syntax/mod.rs6
3 files changed, 10 insertions, 0 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index 1318852d..d629b1fd 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -68,6 +68,7 @@ impl Markup {
NodeKind::NonBreakingSpace => Some(MarkupNode::Text('\u{00A0}'.into())),
NodeKind::EnDash => Some(MarkupNode::Text('\u{2013}'.into())),
NodeKind::EmDash => Some(MarkupNode::Text('\u{2014}'.into())),
+ NodeKind::Quote(d) => Some(MarkupNode::Quote(*d)),
NodeKind::Strong => node.cast().map(MarkupNode::Strong),
NodeKind::Emph => node.cast().map(MarkupNode::Emph),
NodeKind::Raw(raw) => Some(MarkupNode::Raw(raw.as_ref().clone())),
@@ -91,6 +92,8 @@ pub enum MarkupNode {
Parbreak,
/// Plain text.
Text(EcoString),
+ /// A smart quote: `'` (`false`) or `"` (true).
+ Quote(bool),
/// Strong content: `*Strong*`.
Strong(StrongNode),
/// Emphasized content: `_Emphasized_`.
diff --git a/src/syntax/highlight.rs b/src/syntax/highlight.rs
index 25b458ef..1b884c6e 100644
--- a/src/syntax/highlight.rs
+++ b/src/syntax/highlight.rs
@@ -130,6 +130,7 @@ impl Category {
NodeKind::NonBreakingSpace => Some(Category::Shortcut),
NodeKind::EnDash => Some(Category::Shortcut),
NodeKind::EmDash => Some(Category::Shortcut),
+ NodeKind::Quote(_) => Some(Category::Shortcut),
NodeKind::Escape(_) => Some(Category::Escape),
NodeKind::Not => Some(Category::Keyword),
NodeKind::And => Some(Category::Keyword),
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs
index 5857940c..f0d3cdd4 100644
--- a/src/syntax/mod.rs
+++ b/src/syntax/mod.rs
@@ -596,6 +596,8 @@ pub enum NodeKind {
EnDash,
/// An em-dash: `---`.
EmDash,
+ /// A smart quote: `'` (`false`) or `"` (true).
+ Quote(bool),
/// A slash and the letter "u" followed by a hexadecimal unicode entity
/// enclosed in curly braces: `\u{1F5FA}`.
Escape(char),
@@ -769,6 +771,7 @@ impl NodeKind {
| Self::NonBreakingSpace
| Self::EnDash
| Self::EmDash
+ | Self::Quote(_)
| Self::Escape(_)
| Self::Strong
| Self::Emph
@@ -861,6 +864,8 @@ impl NodeKind {
Self::NonBreakingSpace => "non-breaking space",
Self::EnDash => "en dash",
Self::EmDash => "em dash",
+ Self::Quote(false) => "single quote",
+ Self::Quote(true) => "double quote",
Self::Escape(_) => "escape sequence",
Self::Strong => "strong content",
Self::Emph => "emphasized content",
@@ -981,6 +986,7 @@ impl Hash for NodeKind {
Self::NonBreakingSpace => {}
Self::EnDash => {}
Self::EmDash => {}
+ Self::Quote(d) => d.hash(state),
Self::Escape(c) => c.hash(state),
Self::Strong => {}
Self::Emph => {}