summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/mod.rs26
-rw-r--r--src/eval/styles.rs13
2 files changed, 18 insertions, 21 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;
diff --git a/src/eval/styles.rs b/src/eval/styles.rs
index bdc01f1f..508996a1 100644
--- a/src/eval/styles.rs
+++ b/src/eval/styles.rs
@@ -87,19 +87,6 @@ impl StyleMap {
}
}
- /// Toggle a boolean style property, removing it if it exists and inserting
- /// it with `true` if it doesn't.
- pub fn toggle<P: Property<Value = bool>>(&mut self, key: P) {
- for (i, entry) in self.0.iter_mut().enumerate() {
- if entry.is::<P>() {
- self.0.swap_remove(i);
- return;
- }
- }
-
- self.0.push(Entry::new(key, true));
- }
-
/// Mark all contained properties as _scoped_. This means that they only
/// apply to the first descendant node (of their type) in the hierarchy and
/// not its children, too. This is used by class constructors.