diff options
Diffstat (limited to 'src/library/text')
| -rw-r--r-- | src/library/text/deco.rs | 10 | ||||
| -rw-r--r-- | src/library/text/link.rs | 12 | ||||
| -rw-r--r-- | src/library/text/mod.rs | 22 | ||||
| -rw-r--r-- | src/library/text/par.rs | 12 | ||||
| -rw-r--r-- | src/library/text/raw.rs | 28 |
5 files changed, 42 insertions, 42 deletions
diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs index a288c995..608ebb18 100644 --- a/src/library/text/deco.rs +++ b/src/library/text/deco.rs @@ -7,7 +7,7 @@ use crate::library::prelude::*; /// Typeset underline, stricken-through or overlined text. #[derive(Debug, Hash)] -pub struct DecoNode<const L: DecoLine>(pub Template); +pub struct DecoNode<const L: DecoLine>(pub Content); /// Typeset underlined text. pub type UnderlineNode = DecoNode<UNDERLINE>; @@ -37,15 +37,15 @@ impl<const L: DecoLine> DecoNode<L> { /// with the glyphs. Does not apply to strikethrough. pub const EVADE: bool = true; - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self(args.expect::<Template>("body")?))) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::show(Self(args.expect::<Content>("body")?))) } } impl<const L: DecoLine> Show for DecoNode<L> { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { + fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { Ok(styles - .show(self, ctx, [Value::Template(self.0.clone())])? + .show(self, ctx, [Value::Content(self.0.clone())])? .unwrap_or_else(|| { self.0.clone().styled(TextNode::LINES, vec![Decoration { line: L, diff --git a/src/library/text/link.rs b/src/library/text/link.rs index 29f41927..e0041df5 100644 --- a/src/library/text/link.rs +++ b/src/library/text/link.rs @@ -8,7 +8,7 @@ pub struct LinkNode { /// The url the link points to. pub url: EcoString, /// How the link is represented. - pub body: Option<Template>, + pub body: Option<Content>, } #[class] @@ -19,8 +19,8 @@ impl LinkNode { /// Whether to underline link. pub const UNDERLINE: bool = true; - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::show(Self { url: args.expect::<EcoString>("url")?, body: args.find()?, })) @@ -28,12 +28,12 @@ impl LinkNode { } impl Show for LinkNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { + fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { let mut body = styles .show(self, ctx, [ Value::Str(self.url.clone()), match &self.body { - Some(body) => Value::Template(body.clone()), + Some(body) => Value::Content(body.clone()), None => Value::None, }, ])? @@ -45,7 +45,7 @@ impl Show for LinkNode { text = text.trim_start_matches(prefix); } let shorter = text.len() < url.len(); - Template::Text(if shorter { text.into() } else { url.clone() }) + Content::Text(if shorter { text.into() } else { url.clone() }) }); let mut map = StyleMap::new(); diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs index 197971d0..dbc486fb 100644 --- a/src/library/text/mod.rs +++ b/src/library/text/mod.rs @@ -110,7 +110,7 @@ impl TextNode { #[skip] pub const LINK: Option<EcoString> = None; - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { // The text constructor is special: It doesn't create a text node. // Instead, it leaves the passed argument structurally unchanged, but // styles all text in it. @@ -120,38 +120,38 @@ impl TextNode { /// Strong text, rendered in boldface. #[derive(Debug, Hash)] -pub struct StrongNode(pub Template); +pub struct StrongNode(pub Content); #[class] impl StrongNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self(args.expect("body")?))) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::show(Self(args.expect("body")?))) } } impl Show for StrongNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { + fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { Ok(styles - .show(self, ctx, [Value::Template(self.0.clone())])? + .show(self, ctx, [Value::Content(self.0.clone())])? .unwrap_or_else(|| self.0.clone().styled(TextNode::STRONG, true))) } } /// Emphasized text, rendered with an italic face. #[derive(Debug, Hash)] -pub struct EmphNode(pub Template); +pub struct EmphNode(pub Content); #[class] impl EmphNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self(args.expect("body")?))) + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::show(Self(args.expect("body")?))) } } impl Show for EmphNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { + fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { Ok(styles - .show(self, ctx, [Value::Template(self.0.clone())])? + .show(self, ctx, [Value::Content(self.0.clone())])? .unwrap_or_else(|| self.0.clone().styled(TextNode::EMPH, true))) } } diff --git a/src/library/text/par.rs b/src/library/text/par.rs index 70cac1be..dc888637 100644 --- a/src/library/text/par.rs +++ b/src/library/text/par.rs @@ -45,12 +45,12 @@ impl ParNode { /// The indent the first line of a consecutive paragraph should have. pub const INDENT: Linear = Linear::zero(); - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { // The paragraph constructor is special: It doesn't create a paragraph // since that happens automatically through markup. Instead, it just // lifts the passed body to the block level so that it won't merge with // adjacent stuff and it styles the contained paragraphs. - Ok(Template::Block(args.expect("body")?)) + Ok(Content::Block(args.expect("body")?)) } fn set(args: &mut Args, styles: &mut StyleMap) -> TypResult<()> { @@ -185,8 +185,8 @@ pub struct ParbreakNode; #[class] impl ParbreakNode { - fn construct(_: &mut Context, _: &mut Args) -> TypResult<Template> { - Ok(Template::Parbreak) + fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> { + Ok(Content::Parbreak) } } @@ -195,8 +195,8 @@ pub struct LinebreakNode; #[class] impl LinebreakNode { - fn construct(_: &mut Context, _: &mut Args) -> TypResult<Template> { - Ok(Template::Linebreak) + fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> { + Ok(Content::Linebreak) } } diff --git a/src/library/text/raw.rs b/src/library/text/raw.rs index 97857f11..988bd04e 100644 --- a/src/library/text/raw.rs +++ b/src/library/text/raw.rs @@ -29,8 +29,8 @@ impl RawNode { /// The language to syntax-highlight in. pub const LANG: Option<EcoString> = None; - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::show(Self { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::show(Self { text: args.expect("text")?, block: args.named("block")?.unwrap_or(false), })) @@ -38,10 +38,10 @@ impl RawNode { } impl Show for RawNode { - fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Template> { + fn show(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> { let lang = styles.get_ref(Self::LANG).as_ref(); - if let Some(template) = styles.show(self, ctx, [ + if let Some(content) = styles.show(self, ctx, [ Value::Str(self.text.clone()), match lang { Some(lang) => Value::Str(lang.clone()), @@ -49,7 +49,7 @@ impl Show for RawNode { }, Value::Bool(self.block), ])? { - return Ok(template); + return Ok(content); } let foreground = THEME @@ -59,7 +59,7 @@ impl Show for RawNode { .unwrap_or(Color::BLACK) .into(); - let mut template = if matches!( + let mut content = if matches!( lang.map(|s| s.to_lowercase()).as_deref(), Some("typ" | "typst") ) { @@ -72,7 +72,7 @@ impl Show for RawNode { seq.push(styled(&self.text[range], foreground, style)); }); - Template::sequence(seq) + Content::sequence(seq) } else if let Some(syntax) = lang.and_then(|token| SYNTAXES.find_syntax_by_token(&token)) { @@ -80,7 +80,7 @@ impl Show for RawNode { let mut highlighter = HighlightLines::new(syntax, &THEME); for (i, line) in self.text.lines().enumerate() { if i != 0 { - seq.push(Template::Linebreak); + seq.push(Content::Linebreak); } for (style, piece) in highlighter.highlight(line, &SYNTAXES) { @@ -88,23 +88,23 @@ impl Show for RawNode { } } - Template::sequence(seq) + Content::sequence(seq) } else { - Template::Text(self.text.clone()) + Content::Text(self.text.clone()) }; if self.block { - template = Template::Block(template.pack()); + content = Content::Block(content.pack()); } - Ok(template.monospaced()) + Ok(content.monospaced()) } } /// Style a piece of text with a syntect style. -fn styled(piece: &str, foreground: Paint, style: Style) -> Template { +fn styled(piece: &str, foreground: Paint, style: Style) -> Content { let mut styles = StyleMap::new(); - let mut body = Template::Text(piece.into()); + let mut body = Content::Text(piece.into()); let paint = style.foreground.into(); if paint != foreground { |
