summaryrefslogtreecommitdiff
path: root/src/library
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/library
parentc3a387b8f7086fc6d58a4175e8408fbbf375f5f2 (diff)
Introduce `NodeKind::Quote`
Diffstat (limited to 'src/library')
-rw-r--r--src/library/text/par.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/library/text/par.rs b/src/library/text/par.rs
index 6eb3da66..65bc5224 100644
--- a/src/library/text/par.rs
+++ b/src/library/text/par.rs
@@ -19,6 +19,8 @@ pub struct ParNode(pub StyleVec<ParChild>);
pub enum ParChild {
/// A chunk of text.
Text(EcoString),
+ /// A smart quote, may be single (`false`) or double (`true`).
+ Quote(bool),
/// Horizontal spacing between other children.
Spacing(Spacing),
/// An arbitrary inline-level node.
@@ -89,6 +91,7 @@ impl Debug for ParChild {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Self::Text(text) => write!(f, "Text({:?})", text),
+ Self::Quote(double) => write!(f, "Quote({})", double),
Self::Spacing(kind) => write!(f, "{:?}", kind),
Self::Node(node) => node.fmt(f),
}
@@ -397,6 +400,11 @@ fn collect<'a>(
}
Segment::Text(full.len() - prev)
}
+ ParChild::Quote(double) => {
+ let prev = full.len();
+ full.push(if *double { '"' } else { '\'' });
+ Segment::Text(full.len() - prev)
+ }
ParChild::Spacing(spacing) => {
full.push(SPACING_REPLACE);
Segment::Spacing(*spacing)