summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-13 13:52:52 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-13 13:52:52 +0200
commit11f1f0818b990be1ed4a16652b7f30bf11159237 (patch)
treeb52fc6063d8bdec3937ec384cc44ee7a616e51e4 /src/model
parent3e9c63d685a6ff05a72e5a07d40216ff0ac6ae32 (diff)
Pass language to raw show rule
Diffstat (limited to 'src/model')
-rw-r--r--src/model/recipe.rs5
-rw-r--r--src/model/show.rs6
-rw-r--r--src/model/styles.rs2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/model/recipe.rs b/src/model/recipe.rs
index 48e7a22e..905e035e 100644
--- a/src/model/recipe.rs
+++ b/src/model/recipe.rs
@@ -1,6 +1,6 @@
use std::fmt::{self, Debug, Formatter};
-use super::{Content, Interruption, NodeId, Show, ShowNode, StyleEntry};
+use super::{Content, Interruption, NodeId, Show, ShowNode, StyleChain, StyleEntry};
use crate::diag::{At, TypResult};
use crate::eval::{Args, Func, Regex, Value};
use crate::library::structure::{EnumNode, ListNode};
@@ -32,6 +32,7 @@ impl Recipe {
pub fn apply(
&self,
ctx: &mut Context,
+ styles: StyleChain,
sel: Selector,
target: Target,
) -> TypResult<Option<Content>> {
@@ -39,7 +40,7 @@ impl Recipe {
(Target::Node(node), &Pattern::Node(id)) if node.id() == id => {
let node = node.unguard(sel);
self.call(ctx, || {
- let dict = node.encode();
+ let dict = node.encode(styles);
Value::Content(Content::Show(node, Some(dict)))
})?
}
diff --git a/src/model/show.rs b/src/model/show.rs
index af87d930..ac73cb76 100644
--- a/src/model/show.rs
+++ b/src/model/show.rs
@@ -14,7 +14,7 @@ pub trait Show: 'static {
fn unguard(&self, sel: Selector) -> ShowNode;
/// Encode this node into a dictionary.
- fn encode(&self) -> Dict;
+ fn encode(&self, styles: StyleChain) -> Dict;
/// The base recipe for this node that is executed if there is no
/// user-defined show rule.
@@ -70,8 +70,8 @@ impl Show for ShowNode {
self.0.unguard(sel)
}
- fn encode(&self) -> Dict {
- self.0.encode()
+ fn encode(&self, styles: StyleChain) -> Dict {
+ self.0.encode(styles)
}
fn realize(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
diff --git a/src/model/styles.rs b/src/model/styles.rs
index 3c25971c..928133c7 100644
--- a/src/model/styles.rs
+++ b/src/model/styles.rs
@@ -306,7 +306,7 @@ impl<'a> StyleChain<'a> {
let sel = Selector::Nth(n);
if self.guarded(sel) {
guarded = true;
- } else if let Some(content) = recipe.apply(ctx, sel, target)? {
+ } else if let Some(content) = recipe.apply(ctx, self, sel, target)? {
realized = Some(content);
break;
}