summaryrefslogtreecommitdiff
path: root/src/eval/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-01-30 12:50:58 +0100
committerLaurenz <laurmaedje@gmail.com>2022-01-30 22:46:59 +0100
commit8d1ce390e21ce0a5812a4211c893ec359906d6f1 (patch)
tree5dbe1ad96af8ce8f9f01887340fe06025462e959 /src/eval/mod.rs
parentd7072f378fef733ae994fd9a1e767df4e4dd878e (diff)
Rework strong and emph
- Star and underscore not parsed as strong/emph inside of words - Stars/underscores must be balanced and they cannot go over paragraph break - New `strong` and `emph` classes
Diffstat (limited to 'src/eval/mod.rs')
-rw-r--r--src/eval/mod.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 2fa07d49..a453a357 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -213,15 +213,9 @@ impl Eval for MarkupNode {
Self::Space => Node::Space,
Self::Linebreak => Node::Linebreak,
Self::Parbreak => Node::Parbreak,
- Self::Strong => {
- ctx.styles.toggle(TextNode::STRONG);
- Node::new()
- }
- Self::Emph => {
- ctx.styles.toggle(TextNode::EMPH);
- Node::new()
- }
Self::Text(text) => Node::Text(text.clone()),
+ Self::Strong(strong) => strong.eval(ctx)?,
+ Self::Emph(emph) => emph.eval(ctx)?,
Self::Raw(raw) => raw.eval(ctx)?,
Self::Math(math) => math.eval(ctx)?,
Self::Heading(heading) => heading.eval(ctx)?,
@@ -232,6 +226,22 @@ impl Eval for MarkupNode {
}
}
+impl Eval for StrongNode {
+ type Output = Node;
+
+ fn eval(&self, ctx: &mut EvalContext) -> TypResult<Self::Output> {
+ Ok(self.body().eval(ctx)?.styled(TextNode::STRONG, true))
+ }
+}
+
+impl Eval for EmphNode {
+ type Output = Node;
+
+ fn eval(&self, ctx: &mut EvalContext) -> TypResult<Self::Output> {
+ Ok(self.body().eval(ctx)?.styled(TextNode::EMPH, true))
+ }
+}
+
impl Eval for RawNode {
type Output = Node;