summaryrefslogtreecommitdiff
path: root/src/eval
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/eval
parentc3a387b8f7086fc6d58a4175e8408fbbf375f5f2 (diff)
Introduce `NodeKind::Quote`
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/content.rs8
-rw-r--r--src/eval/mod.rs1
2 files changed, 8 insertions, 1 deletions
diff --git a/src/eval/content.rs b/src/eval/content.rs
index d9685891..274b64b0 100644
--- a/src/eval/content.rs
+++ b/src/eval/content.rs
@@ -45,6 +45,8 @@ pub enum Content {
Horizontal(Spacing),
/// Plain text.
Text(EcoString),
+ /// A smart quote, may be single (`false`) or double (`true`).
+ Quote(bool),
/// An inline-level node.
Inline(LayoutNode),
/// A paragraph break.
@@ -214,6 +216,7 @@ impl Debug for Content {
Self::Linebreak => f.pad("Linebreak"),
Self::Horizontal(kind) => write!(f, "Horizontal({kind:?})"),
Self::Text(text) => write!(f, "Text({text:?})"),
+ Self::Quote(double) => write!(f, "Quote({double:?})"),
Self::Inline(node) => {
f.write_str("Inline(")?;
node.fmt(f)?;
@@ -384,6 +387,9 @@ impl<'a> Builder<'a> {
self.par.ignorant(child, styles);
}
}
+ Content::Quote(double) => {
+ self.par.supportive(ParChild::Quote(*double), styles);
+ }
Content::Text(text) => {
self.par.supportive(ParChild::Text(text.clone()), styles);
}
@@ -496,7 +502,7 @@ impl<'a> Builder<'a> {
.items()
.find_map(|child| match child {
ParChild::Spacing(_) => None,
- ParChild::Text(_) => Some(true),
+ ParChild::Text(_) | ParChild::Quote(_) => Some(true),
ParChild::Node(_) => Some(false),
})
.unwrap_or_default()
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 9e5a8555..f2c03c0f 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -111,6 +111,7 @@ impl Eval for MarkupNode {
Self::Linebreak => Content::Linebreak,
Self::Parbreak => Content::Parbreak,
Self::Text(text) => Content::Text(text.clone()),
+ Self::Quote(double) => Content::Quote(*double),
Self::Strong(strong) => strong.eval(ctx, scp)?,
Self::Emph(emph) => emph.eval(ctx, scp)?,
Self::Raw(raw) => raw.eval(ctx, scp)?,