summaryrefslogtreecommitdiff
path: root/src/library/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-03-12 14:24:24 +0100
committerLaurenz <laurmaedje@gmail.com>2022-03-12 14:24:24 +0100
commit2890a156d27c02a101137bf01dc2046597110bd1 (patch)
treec6bdeb48242c0fbd5b5e13120ca3c8f502d41b75 /src/library/text
parent5ac7eb3860ebd3247f6486c227e816894cb8fd91 (diff)
Remove classes and improve naming
Diffstat (limited to 'src/library/text')
-rw-r--r--src/library/text/deco.rs2
-rw-r--r--src/library/text/link.rs2
-rw-r--r--src/library/text/mod.rs6
-rw-r--r--src/library/text/par.rs23
-rw-r--r--src/library/text/raw.rs2
5 files changed, 18 insertions, 17 deletions
diff --git a/src/library/text/deco.rs b/src/library/text/deco.rs
index 608ebb18..29c04b2d 100644
--- a/src/library/text/deco.rs
+++ b/src/library/text/deco.rs
@@ -18,7 +18,7 @@ pub type StrikethroughNode = DecoNode<STRIKETHROUGH>;
/// Typeset overlined text.
pub type OverlineNode = DecoNode<OVERLINE>;
-#[class]
+#[node(showable)]
impl<const L: DecoLine> DecoNode<L> {
/// Stroke color of the line, defaults to the text color if `None`.
#[shorthand]
diff --git a/src/library/text/link.rs b/src/library/text/link.rs
index e0041df5..4c2b5e7b 100644
--- a/src/library/text/link.rs
+++ b/src/library/text/link.rs
@@ -11,7 +11,7 @@ pub struct LinkNode {
pub body: Option<Content>,
}
-#[class]
+#[node(showable)]
impl LinkNode {
/// The fill color of text in the link. Just the surrounding text color
/// if `auto`.
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index dbc486fb..8939a8c1 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -25,7 +25,7 @@ use crate::util::EcoString;
#[derive(Hash)]
pub struct TextNode;
-#[class]
+#[node]
impl TextNode {
/// A prioritized sequence of font families.
#[variadic]
@@ -122,7 +122,7 @@ impl TextNode {
#[derive(Debug, Hash)]
pub struct StrongNode(pub Content);
-#[class]
+#[node(showable)]
impl StrongNode {
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self(args.expect("body")?)))
@@ -141,7 +141,7 @@ impl Show for StrongNode {
#[derive(Debug, Hash)]
pub struct EmphNode(pub Content);
-#[class]
+#[node(showable)]
impl EmphNode {
fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self(args.expect("body")?)))
diff --git a/src/library/text/par.rs b/src/library/text/par.rs
index dc888637..be4e8096 100644
--- a/src/library/text/par.rs
+++ b/src/library/text/par.rs
@@ -6,7 +6,7 @@ use xi_unicode::LineBreakIterator;
use super::{shape, ShapedText, TextNode};
use crate::font::FontStore;
-use crate::library::layout::SpacingKind;
+use crate::library::layout::Spacing;
use crate::library::prelude::*;
use crate::util::{ArcExt, EcoString, RangeExt, SliceExt};
@@ -20,12 +20,12 @@ pub enum ParChild {
/// A chunk of text.
Text(EcoString),
/// Horizontal spacing between other children.
- Spacing(SpacingKind),
+ Spacing(Spacing),
/// An arbitrary inline-level node.
Node(LayoutNode),
}
-#[class]
+#[node]
impl ParNode {
/// An ISO 639-1 language code.
pub const LANG: Option<EcoString> = None;
@@ -53,9 +53,10 @@ impl ParNode {
Ok(Content::Block(args.expect("body")?))
}
- fn set(args: &mut Args, styles: &mut StyleMap) -> TypResult<()> {
- let lang = args.named::<Option<EcoString>>("lang")?;
+ fn set(args: &mut Args) -> TypResult<StyleMap> {
+ let mut styles = StyleMap::new();
+ let lang = args.named::<Option<EcoString>>("lang")?;
let mut dir =
lang.clone().flatten().map(|iso| match iso.to_lowercase().as_str() {
"ar" | "dv" | "fa" | "he" | "ks" | "pa" | "ps" | "sd" | "ug" | "ur"
@@ -89,7 +90,7 @@ impl ParNode {
styles.set_opt(Self::SPACING, args.named("spacing")?);
styles.set_opt(Self::INDENT, args.named("indent")?);
- Ok(())
+ Ok(styles)
}
}
@@ -183,7 +184,7 @@ impl Merge for ParChild {
/// A paragraph break.
pub struct ParbreakNode;
-#[class]
+#[node]
impl ParbreakNode {
fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> {
Ok(Content::Parbreak)
@@ -193,7 +194,7 @@ impl ParbreakNode {
/// A line break.
pub struct LinebreakNode;
-#[class]
+#[node]
impl LinebreakNode {
fn construct(_: &mut Context, _: &mut Args) -> TypResult<Content> {
Ok(Content::Linebreak)
@@ -256,13 +257,13 @@ impl<'a> ParLayout<'a> {
ranges.push(subrange);
}
}
- ParChild::Spacing(kind) => match *kind {
- SpacingKind::Linear(v) => {
+ ParChild::Spacing(spacing) => match *spacing {
+ Spacing::Linear(v) => {
let resolved = v.resolve(regions.first.x);
items.push(ParItem::Absolute(resolved));
ranges.push(range);
}
- SpacingKind::Fractional(v) => {
+ Spacing::Fractional(v) => {
items.push(ParItem::Fractional(v));
ranges.push(range);
}
diff --git a/src/library/text/raw.rs b/src/library/text/raw.rs
index 988bd04e..e225803f 100644
--- a/src/library/text/raw.rs
+++ b/src/library/text/raw.rs
@@ -24,7 +24,7 @@ pub struct RawNode {
pub block: bool,
}
-#[class]
+#[node(showable)]
impl RawNode {
/// The language to syntax-highlight in.
pub const LANG: Option<EcoString> = None;