summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/src')
-rw-r--r--library/src/compute/foundations.rs21
-rw-r--r--library/src/layout/align.rs2
-rw-r--r--library/src/layout/flow.rs10
-rw-r--r--library/src/layout/hide.rs2
-rw-r--r--library/src/layout/mod.rs26
-rw-r--r--library/src/layout/par.rs8
-rw-r--r--library/src/layout/stack.rs2
-rw-r--r--library/src/lib.rs92
-rw-r--r--library/src/math/mod.rs69
-rw-r--r--library/src/meta/document.rs6
-rw-r--r--library/src/meta/heading.rs23
-rw-r--r--library/src/meta/link.rs2
-rw-r--r--library/src/meta/outline.rs19
-rw-r--r--library/src/meta/reference.rs2
-rw-r--r--library/src/text/deco.rs6
-rw-r--r--library/src/text/misc.rs4
-rw-r--r--library/src/text/raw.rs15
-rw-r--r--library/src/text/shift.rs14
18 files changed, 148 insertions, 175 deletions
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs
index 41a6bc35..8b148c85 100644
--- a/library/src/compute/foundations.rs
+++ b/library/src/compute/foundations.rs
@@ -53,7 +53,7 @@ pub fn repr(
/// Fail with an error.
///
/// ## Example
-/// The code below produces the error `panicked at: "this is wrong"`.
+/// The code below produces the error `panicked with: "this is wrong"`.
/// ```typ
/// #panic("this is wrong")
/// ```
@@ -63,14 +63,21 @@ pub fn repr(
/// Returns:
#[func]
pub fn panic(
- /// The value (or message) to panic with.
- #[default]
- payload: Option<Value>,
+ /// The values to panic with.
+ #[variadic]
+ values: Vec<Value>,
) -> Value {
- match payload {
- Some(v) => bail!(args.span, "panicked with: {}", v.repr()),
- None => bail!(args.span, "panicked"),
+ let mut msg = EcoString::from("panicked");
+ if !values.is_empty() {
+ msg.push_str(" with: ");
+ for (i, value) in values.iter().enumerate() {
+ if i > 0 {
+ msg.push_str(", ");
+ }
+ msg.push_str(&value.repr());
+ }
}
+ bail!(args.span, msg);
}
/// Ensure that a condition is fulfilled.
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index cf6d08f2..2a3998bf 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -58,7 +58,7 @@ pub struct AlignNode {
}
impl Show for AlignNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
Ok(self
.body()
.styled(Self::set_alignment(self.alignment(styles).map(Some))))
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index 7a063bce..2671b983 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -32,7 +32,7 @@ impl Layout for FlowNode {
let outer = styles;
let mut styles = outer;
if let Some(node) = child.to::<StyledNode>() {
- map = node.map();
+ map = node.styles();
styles = outer.chain(&map);
child = node.body();
}
@@ -48,15 +48,15 @@ impl Layout for FlowNode {
|| child.is::<ImageNode>()
{
layouter.layout_single(vt, &child, styles)?;
- } else if child.has::<dyn Layout>() {
+ } else if child.can::<dyn Layout>() {
layouter.layout_multiple(vt, &child, styles)?;
} else if child.is::<ColbreakNode>() {
if !layouter.regions.backlog.is_empty() || layouter.regions.last.is_some()
{
layouter.finish_region();
}
- } else if let Some(span) = child.span() {
- bail!(span, "unexpected flow child");
+ } else {
+ bail!(child.span(), "unexpected flow child");
}
}
@@ -207,7 +207,7 @@ impl<'a> FlowLayouter<'a> {
let aligns = if let Some(align) = block.to::<AlignNode>() {
align.alignment(styles)
} else if let Some(styled) = block.to::<StyledNode>() {
- AlignNode::alignment_in(styles.chain(&styled.map()))
+ AlignNode::alignment_in(styles.chain(&styled.styles()))
} else {
AlignNode::alignment_in(styles)
}
diff --git a/library/src/layout/hide.rs b/library/src/layout/hide.rs
index 62628445..e939e6c3 100644
--- a/library/src/layout/hide.rs
+++ b/library/src/layout/hide.rs
@@ -23,7 +23,7 @@ pub struct HideNode {
}
impl Show for HideNode {
- fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(MetaNode::set_data(vec![Meta::Hidden])))
}
}
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index e846f6f0..dc373ff5 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -148,7 +148,7 @@ fn realize_root<'a>(
content: &'a Content,
styles: StyleChain<'a>,
) -> SourceResult<(Content, StyleChain<'a>)> {
- if content.has::<dyn LayoutRoot>() && !applicable(content, styles) {
+ if content.can::<dyn LayoutRoot>() && !applicable(content, styles) {
return Ok((content.clone(), styles));
}
@@ -166,7 +166,7 @@ fn realize_block<'a>(
content: &'a Content,
styles: StyleChain<'a>,
) -> SourceResult<(Content, StyleChain<'a>)> {
- if content.has::<dyn Layout>()
+ if content.can::<dyn Layout>()
&& !content.is::<RectNode>()
&& !content.is::<SquareNode>()
&& !content.is::<EllipseNode>()
@@ -227,16 +227,20 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
mut content: &'a Content,
styles: StyleChain<'a>,
) -> SourceResult<()> {
- if content.has::<dyn LayoutMath>() && !content.is::<FormulaNode>() {
+ if content.can::<dyn LayoutMath>() && !content.is::<FormulaNode>() {
content =
self.scratch.content.alloc(FormulaNode::new(content.clone()).pack());
}
// Prepare only if this is the first application for this node.
- if let Some(node) = content.with::<dyn Prepare>() {
+ if content.can::<dyn Prepare>() {
if !content.is_prepared() {
- let prepared =
- node.prepare(self.vt, content.clone().prepared(), styles)?;
+ let prepared = content
+ .clone()
+ .prepared()
+ .with::<dyn Prepare>()
+ .unwrap()
+ .prepare(self.vt, styles)?;
let stored = self.scratch.content.alloc(prepared);
return self.accept(stored, styles);
}
@@ -291,11 +295,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
}
}
- if let Some(span) = content.span() {
- bail!(span, "not allowed here");
- }
-
- Ok(())
+ bail!(content.span(), "not allowed here");
}
fn styled(
@@ -303,7 +303,7 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
styled: &'a StyledNode,
styles: StyleChain<'a>,
) -> SourceResult<()> {
- let map = self.scratch.maps.alloc(styled.map());
+ let map = self.scratch.maps.alloc(styled.styles());
let stored = self.scratch.styles.alloc(styles);
let content = self.scratch.content.alloc(styled.body());
let styles = stored.chain(map);
@@ -436,7 +436,7 @@ impl<'a> FlowBuilder<'a> {
return true;
}
- if content.has::<dyn Layout>() || content.is::<ParNode>() {
+ if content.can::<dyn Layout>() || content.is::<ParNode>() {
let is_tight_list = if let Some(node) = content.to::<ListNode>() {
node.tight(styles)
} else if let Some(node) = content.to::<EnumNode>() {
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index e5644a2e..8dd81d29 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -519,7 +519,7 @@ fn collect<'a>(
let mut styles = *styles;
if let Some(node) = child.to::<StyledNode>() {
child = Box::leak(Box::new(node.body()));
- styles = outer.chain(Box::leak(Box::new(node.map())));
+ styles = outer.chain(Box::leak(Box::new(node.styles())));
}
let segment = if child.is::<SpaceNode>() {
@@ -570,10 +570,8 @@ fn collect<'a>(
let frac = node.width(styles).is_fractional();
full.push(if frac { SPACING_REPLACE } else { NODE_REPLACE });
Segment::Box(node, frac)
- } else if let Some(span) = child.span() {
- bail!(span, "unexpected document child");
} else {
- continue;
+ bail!(child.span(), "unexpected paragraph child");
};
if let Some(last) = full.chars().last() {
@@ -730,7 +728,7 @@ fn shared_get<'a, T: PartialEq>(
children
.iter()
.filter_map(|child| child.to::<StyledNode>())
- .all(|node| getter(styles.chain(&node.map())) == value)
+ .all(|node| getter(styles.chain(&node.styles())) == value)
.then(|| value)
}
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index c21fa884..1dd81a60 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -201,7 +201,7 @@ impl<'a> StackLayouter<'a> {
let aligns = if let Some(align) = block.to::<AlignNode>() {
align.alignment(styles)
} else if let Some(styled) = block.to::<StyledNode>() {
- AlignNode::alignment_in(styles.chain(&styled.map()))
+ AlignNode::alignment_in(styles.chain(&styled.styles()))
} else {
AlignNode::alignment_in(styles)
}
diff --git a/library/src/lib.rs b/library/src/lib.rs
index ad8a2ac4..94b3e0c4 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -29,65 +29,65 @@ fn global(math: Module, calc: Module) -> Module {
let mut global = Scope::deduplicating();
// Text.
- global.define("text", text::TextNode::func());
- global.define("linebreak", text::LinebreakNode::func());
- global.define("smartquote", text::SmartQuoteNode::func());
- global.define("strong", text::StrongNode::func());
- global.define("emph", text::EmphNode::func());
+ global.define("text", text::TextNode::id());
+ global.define("linebreak", text::LinebreakNode::id());
+ global.define("smartquote", text::SmartQuoteNode::id());
+ global.define("strong", text::StrongNode::id());
+ global.define("emph", text::EmphNode::id());
global.define("lower", text::lower);
global.define("upper", text::upper);
global.define("smallcaps", text::smallcaps);
- global.define("sub", text::SubNode::func());
- global.define("super", text::SuperNode::func());
- global.define("underline", text::UnderlineNode::func());
- global.define("strike", text::StrikeNode::func());
- global.define("overline", text::OverlineNode::func());
- global.define("raw", text::RawNode::func());
+ global.define("sub", text::SubNode::id());
+ global.define("super", text::SuperNode::id());
+ global.define("underline", text::UnderlineNode::id());
+ global.define("strike", text::StrikeNode::id());
+ global.define("overline", text::OverlineNode::id());
+ global.define("raw", text::RawNode::id());
global.define("lorem", text::lorem);
// Math.
global.define("math", math);
// Layout.
- global.define("page", layout::PageNode::func());
- global.define("pagebreak", layout::PagebreakNode::func());
- global.define("v", layout::VNode::func());
- global.define("par", layout::ParNode::func());
- global.define("parbreak", layout::ParbreakNode::func());
- global.define("h", layout::HNode::func());
- global.define("box", layout::BoxNode::func());
- global.define("block", layout::BlockNode::func());
- global.define("list", layout::ListNode::func());
- global.define("enum", layout::EnumNode::func());
- global.define("terms", layout::TermsNode::func());
- global.define("table", layout::TableNode::func());
- global.define("stack", layout::StackNode::func());
- global.define("grid", layout::GridNode::func());
- global.define("columns", layout::ColumnsNode::func());
- global.define("colbreak", layout::ColbreakNode::func());
- global.define("place", layout::PlaceNode::func());
- global.define("align", layout::AlignNode::func());
- global.define("pad", layout::PadNode::func());
- global.define("repeat", layout::RepeatNode::func());
- global.define("move", layout::MoveNode::func());
- global.define("scale", layout::ScaleNode::func());
- global.define("rotate", layout::RotateNode::func());
- global.define("hide", layout::HideNode::func());
+ global.define("page", layout::PageNode::id());
+ global.define("pagebreak", layout::PagebreakNode::id());
+ global.define("v", layout::VNode::id());
+ global.define("par", layout::ParNode::id());
+ global.define("parbreak", layout::ParbreakNode::id());
+ global.define("h", layout::HNode::id());
+ global.define("box", layout::BoxNode::id());
+ global.define("block", layout::BlockNode::id());
+ global.define("list", layout::ListNode::id());
+ global.define("enum", layout::EnumNode::id());
+ global.define("terms", layout::TermsNode::id());
+ global.define("table", layout::TableNode::id());
+ global.define("stack", layout::StackNode::id());
+ global.define("grid", layout::GridNode::id());
+ global.define("columns", layout::ColumnsNode::id());
+ global.define("colbreak", layout::ColbreakNode::id());
+ global.define("place", layout::PlaceNode::id());
+ global.define("align", layout::AlignNode::id());
+ global.define("pad", layout::PadNode::id());
+ global.define("repeat", layout::RepeatNode::id());
+ global.define("move", layout::MoveNode::id());
+ global.define("scale", layout::ScaleNode::id());
+ global.define("rotate", layout::RotateNode::id());
+ global.define("hide", layout::HideNode::id());
// Visualize.
- global.define("image", visualize::ImageNode::func());
- global.define("line", visualize::LineNode::func());
- global.define("rect", visualize::RectNode::func());
- global.define("square", visualize::SquareNode::func());
- global.define("ellipse", visualize::EllipseNode::func());
- global.define("circle", visualize::CircleNode::func());
+ global.define("image", visualize::ImageNode::id());
+ global.define("line", visualize::LineNode::id());
+ global.define("rect", visualize::RectNode::id());
+ global.define("square", visualize::SquareNode::id());
+ global.define("ellipse", visualize::EllipseNode::id());
+ global.define("circle", visualize::CircleNode::id());
// Meta.
- global.define("document", meta::DocumentNode::func());
- global.define("ref", meta::RefNode::func());
- global.define("link", meta::LinkNode::func());
- global.define("outline", meta::OutlineNode::func());
- global.define("heading", meta::HeadingNode::func());
+ global.define("document", meta::DocumentNode::id());
+ global.define("ref", meta::RefNode::id());
+ global.define("link", meta::LinkNode::id());
+ global.define("outline", meta::OutlineNode::id());
+ global.define("heading", meta::HeadingNode::id());
global.define("numbering", meta::numbering);
// Symbols.
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 8f89e028..c11bea79 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -47,52 +47,52 @@ use crate::text::{
/// Create a module with all math definitions.
pub fn module() -> Module {
let mut math = Scope::deduplicating();
- math.define("formula", FormulaNode::func());
- math.define("text", TextNode::func());
+ math.define("formula", FormulaNode::id());
+ math.define("text", TextNode::id());
// Grouping.
- math.define("lr", LrNode::func());
+ math.define("lr", LrNode::id());
math.define("abs", abs);
math.define("norm", norm);
math.define("floor", floor);
math.define("ceil", ceil);
// Attachments and accents.
- math.define("attach", AttachNode::func());
- math.define("scripts", ScriptsNode::func());
- math.define("limits", LimitsNode::func());
- math.define("accent", AccentNode::func());
- math.define("underline", UnderlineNode::func());
- math.define("overline", OverlineNode::func());
- math.define("underbrace", UnderbraceNode::func());
- math.define("overbrace", OverbraceNode::func());
- math.define("underbracket", UnderbracketNode::func());
- math.define("overbracket", OverbracketNode::func());
+ math.define("attach", AttachNode::id());
+ math.define("scripts", ScriptsNode::id());
+ math.define("limits", LimitsNode::id());
+ math.define("accent", AccentNode::id());
+ math.define("underline", UnderlineNode::id());
+ math.define("overline", OverlineNode::id());
+ math.define("underbrace", UnderbraceNode::id());
+ math.define("overbrace", OverbraceNode::id());
+ math.define("underbracket", UnderbracketNode::id());
+ math.define("overbracket", OverbracketNode::id());
// Fractions and matrix-likes.
- math.define("frac", FracNode::func());
- math.define("binom", BinomNode::func());
- math.define("vec", VecNode::func());
- math.define("mat", MatNode::func());
- math.define("cases", CasesNode::func());
+ math.define("frac", FracNode::id());
+ math.define("binom", BinomNode::id());
+ math.define("vec", VecNode::id());
+ math.define("mat", MatNode::id());
+ math.define("cases", CasesNode::id());
// Roots.
- math.define("sqrt", SqrtNode::func());
- math.define("root", RootNode::func());
+ math.define("sqrt", SqrtNode::id());
+ math.define("root", RootNode::id());
// Styles.
- math.define("upright", UprightNode::func());
- math.define("bold", BoldNode::func());
- math.define("italic", ItalicNode::func());
- math.define("serif", SerifNode::func());
- math.define("sans", SansNode::func());
- math.define("cal", CalNode::func());
- math.define("frak", FrakNode::func());
- math.define("mono", MonoNode::func());
- math.define("bb", BbNode::func());
+ math.define("upright", UprightNode::id());
+ math.define("bold", BoldNode::id());
+ math.define("italic", ItalicNode::id());
+ math.define("serif", SerifNode::id());
+ math.define("sans", SansNode::id());
+ math.define("cal", CalNode::id());
+ math.define("frak", FrakNode::id());
+ math.define("mono", MonoNode::id());
+ math.define("bb", BbNode::id());
// Text operators.
- math.define("op", OpNode::func());
+ math.define("op", OpNode::id());
op::define(&mut math);
// Spacings.
@@ -144,7 +144,7 @@ pub struct FormulaNode {
}
impl Show for FormulaNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let mut realized = self.clone().pack().guarded(Guard::Base(NodeId::of::<Self>()));
if self.block(styles) {
realized = realized.aligned(Axes::with_x(Some(Align::Center.into())))
@@ -183,10 +183,7 @@ impl Layout for FormulaNode {
Some(font)
})
else {
- if let Some(span) = self.span() {
- bail!(span, "current font does not support math");
- }
- return Ok(Fragment::frame(Frame::new(Size::zero())))
+ bail!(self.span(), "current font does not support math");
};
let mut ctx = MathContext::new(vt, styles, regions, &font, block);
@@ -228,7 +225,7 @@ impl LayoutMath for Content {
}
if let Some(styled) = self.to::<StyledNode>() {
- let map = styled.map();
+ let map = styled.styles();
if TextNode::font_in(ctx.styles().chain(&map))
!= TextNode::font_in(ctx.styles())
{
diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs
index 8da3c731..ae29e7a8 100644
--- a/library/src/meta/document.rs
+++ b/library/src/meta/document.rs
@@ -39,7 +39,7 @@ impl LayoutRoot for DocumentNode {
let outer = styles;
let mut styles = outer;
if let Some(node) = child.to::<StyledNode>() {
- map = node.map();
+ map = node.styles();
styles = outer.chain(&map);
child = node.body();
}
@@ -48,8 +48,8 @@ impl LayoutRoot for DocumentNode {
let number = 1 + pages.len();
let fragment = page.layout(vt, number, styles)?;
pages.extend(fragment);
- } else if let Some(span) = child.span() {
- bail!(span, "unexpected document child");
+ } else {
+ bail!(child.span(), "unexpected document child");
}
}
diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs
index 3a8d811c..8677aa55 100644
--- a/library/src/meta/heading.rs
+++ b/library/src/meta/heading.rs
@@ -79,13 +79,8 @@ pub struct HeadingNode {
}
impl Prepare for HeadingNode {
- fn prepare(
- &self,
- vt: &mut Vt,
- mut this: Content,
- styles: StyleChain,
- ) -> SourceResult<Content> {
- let my_id = vt.identify(&this);
+ fn prepare(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
+ let my_id = vt.identify(self);
let mut counter = HeadingCounter::new();
for (node_id, node) in vt.locate(Selector::node::<HeadingNode>()) {
@@ -105,18 +100,18 @@ impl Prepare for HeadingNode {
numbers = numbering.apply(vt.world(), counter.advance(self))?;
}
- this.push_field("outlined", Value::Bool(self.outlined(styles)));
- this.push_field("numbers", numbers);
-
- let meta = Meta::Node(my_id, this.clone());
- Ok(this.styled(MetaNode::set_data(vec![meta])))
+ let mut node = self.clone().pack();
+ node.push_field("outlined", Value::Bool(self.outlined(styles)));
+ node.push_field("numbers", numbers);
+ let meta = Meta::Node(my_id, node.clone());
+ Ok(node.styled(MetaNode::set_data(vec![meta])))
}
}
impl Show for HeadingNode {
- fn show(&self, _: &mut Vt, this: &Content, _: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
let mut realized = self.body();
- let numbers = this.field("numbers").unwrap();
+ let numbers = self.0.field("numbers").unwrap();
if *numbers != Value::None {
realized = numbers.clone().display()
+ HNode::new(Em::new(0.3).into()).with_weak(true).pack()
diff --git a/library/src/meta/link.rs b/library/src/meta/link.rs
index 572c55b4..4aba3697 100644
--- a/library/src/meta/link.rs
+++ b/library/src/meta/link.rs
@@ -78,7 +78,7 @@ impl LinkNode {
}
impl Show for LinkNode {
- fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
Ok(self.body())
}
}
diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs
index 9e5614aa..d66a573d 100644
--- a/library/src/meta/outline.rs
+++ b/library/src/meta/outline.rs
@@ -70,12 +70,7 @@ pub struct OutlineNode {
}
impl Prepare for OutlineNode {
- fn prepare(
- &self,
- vt: &mut Vt,
- mut this: Content,
- _: StyleChain,
- ) -> SourceResult<Content> {
+ fn prepare(&self, vt: &mut Vt, _: StyleChain) -> SourceResult<Content> {
let headings = vt
.locate(Selector::node::<HeadingNode>())
.into_iter()
@@ -84,18 +79,14 @@ impl Prepare for OutlineNode {
.map(|node| Value::Content(node.clone()))
.collect();
- this.push_field("headings", Value::Array(Array::from_vec(headings)));
- Ok(this)
+ let mut node = self.clone().pack();
+ node.push_field("headings", Value::Array(Array::from_vec(headings)));
+ Ok(node)
}
}
impl Show for OutlineNode {
- fn show(
- &self,
- vt: &mut Vt,
- _: &Content,
- styles: StyleChain,
- ) -> SourceResult<Content> {
+ fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let mut seq = vec![ParbreakNode::new().pack()];
if let Some(title) = self.title(styles) {
let title = title.clone().unwrap_or_else(|| {
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index 20354556..bfc31785 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -25,7 +25,7 @@ pub struct RefNode {
}
impl Show for RefNode {
- fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
Ok(TextNode::packed(eco_format!("@{}", self.target())))
}
}
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index 4dadf45a..27d30286 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -66,7 +66,7 @@ pub struct UnderlineNode {
}
impl Show for UnderlineNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(TextNode::set_deco(Decoration {
line: DecoLine::Underline,
stroke: self.stroke(styles).unwrap_or_default(),
@@ -145,7 +145,7 @@ pub struct OverlineNode {
}
impl Show for OverlineNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(TextNode::set_deco(Decoration {
line: DecoLine::Overline,
stroke: self.stroke(styles).unwrap_or_default(),
@@ -209,7 +209,7 @@ pub struct StrikeNode {
}
impl Show for StrikeNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(TextNode::set_deco(Decoration {
line: DecoLine::Strikethrough,
stroke: self.stroke(styles).unwrap_or_default(),
diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs
index 60521f12..029e15f4 100644
--- a/library/src/text/misc.rs
+++ b/library/src/text/misc.rs
@@ -99,7 +99,7 @@ pub struct StrongNode {
}
impl Show for StrongNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(TextNode::set_delta(Delta(self.delta(styles)))))
}
}
@@ -159,7 +159,7 @@ pub struct EmphNode {
}
impl Show for EmphNode {
- fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
Ok(self.body().styled(TextNode::set_emph(Toggle)))
}
}
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs
index 3768e65e..72dd1782 100644
--- a/library/src/text/raw.rs
+++ b/library/src/text/raw.rs
@@ -104,19 +104,15 @@ pub struct RawNode {
}
impl Prepare for RawNode {
- fn prepare(
- &self,
- _: &mut Vt,
- mut this: Content,
- styles: StyleChain,
- ) -> SourceResult<Content> {
- this.push_field("lang", self.lang(styles).clone());
- Ok(this)
+ fn prepare(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
+ let mut node = self.clone().pack();
+ node.push_field("lang", self.lang(styles).clone());
+ Ok(node)
}
}
impl Show for RawNode {
- fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> SourceResult<Content> {
+ fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let text = self.text();
let lang = self.lang(styles).as_ref().map(|s| s.to_lowercase());
let foreground = THEME
@@ -279,7 +275,6 @@ pub static THEME: Lazy<synt::Theme> = Lazy::new(|| synt::Theme {
item("support.macro", Some("#16718d"), None),
item("meta.annotation", Some("#301414"), None),
item("entity.other, meta.interpolation", Some("#8b41b1"), None),
- item("invalid", Some("#ff0000"), None),
],
});
diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs
index acd46d4e..20cfaa49 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -47,12 +47,7 @@ pub struct SubNode {
}
impl Show for SubNode {
- fn show(
- &self,
- vt: &mut Vt,
- _: &Content,
- styles: StyleChain,
- ) -> SourceResult<Content> {
+ fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let body = self.body();
let mut transformed = None;
if self.typographic(styles) {
@@ -114,12 +109,7 @@ pub struct SuperNode {
}
impl Show for SuperNode {
- fn show(
- &self,
- vt: &mut Vt,
- _: &Content,
- styles: StyleChain,
- ) -> SourceResult<Content> {
+ fn show(&self, vt: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let body = self.body();
let mut transformed = None;
if self.typographic(styles) {