summaryrefslogtreecommitdiff
path: root/library/src/text
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/text')
-rw-r--r--library/src/text/deco.rs4
-rw-r--r--library/src/text/misc.rs25
-rw-r--r--library/src/text/mod.rs2
-rw-r--r--library/src/text/quotes.rs2
-rw-r--r--library/src/text/raw.rs4
-rw-r--r--library/src/text/shift.rs4
-rw-r--r--library/src/text/symbol.rs4
7 files changed, 34 insertions, 11 deletions
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index a6fa490f..fceb4cfd 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -5,6 +5,8 @@ use super::TextNode;
use crate::prelude::*;
/// Typeset underline, stricken-through or overlined text.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct DecoNode<const L: DecoLine>(pub Content);
@@ -17,7 +19,7 @@ pub type StrikeNode = DecoNode<STRIKETHROUGH>;
/// Typeset overlined text.
pub type OverlineNode = DecoNode<OVERLINE>;
-#[node(Show)]
+#[node]
impl<const L: DecoLine> DecoNode<L> {
/// How to stroke the line. The text color and thickness are read from the
/// font tables if `auto`.
diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs
index 896c03ac..1c5a32b4 100644
--- a/library/src/text/misc.rs
+++ b/library/src/text/misc.rs
@@ -2,10 +2,12 @@ use super::TextNode;
use crate::prelude::*;
/// A text space.
+#[func]
+#[capable(Unlabellable, Behave)]
#[derive(Debug, Hash)]
pub struct SpaceNode;
-#[node(Unlabellable, Behave)]
+#[node]
impl SpaceNode {
fn construct(_: &Vm, _: &mut Args) -> SourceResult<Content> {
Ok(Self.pack())
@@ -21,12 +23,14 @@ impl Behave for SpaceNode {
}
/// A line break.
+#[func]
+#[capable(Behave)]
#[derive(Debug, Hash)]
pub struct LinebreakNode {
pub justify: bool,
}
-#[node(Behave)]
+#[node]
impl LinebreakNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
let justify = args.named("justify")?.unwrap_or(false);
@@ -41,10 +45,12 @@ impl Behave for LinebreakNode {
}
/// Strongly emphasizes content by increasing the font weight.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct StrongNode(pub Content);
-#[node(Show)]
+#[node]
impl StrongNode {
/// The delta to apply on the font weight.
pub const DELTA: i64 = 300;
@@ -86,10 +92,12 @@ impl Fold for Delta {
}
/// Emphasizes content by flipping the italicness.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct EmphNode(pub Content);
-#[node(Show)]
+#[node]
impl EmphNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -122,12 +130,14 @@ impl Fold for Toggle {
}
/// Convert a string or content to lowercase.
-pub fn lower(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+#[func]
+pub fn lower(args: &mut Args) -> SourceResult<Value> {
case(Case::Lower, args)
}
/// Convert a string or content to uppercase.
-pub fn upper(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+#[func]
+pub fn upper(args: &mut Args) -> SourceResult<Value> {
case(Case::Upper, args)
}
@@ -161,7 +171,8 @@ impl Case {
}
/// Display text in small capitals.
-pub fn smallcaps(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+#[func]
+pub fn smallcaps(args: &mut Args) -> SourceResult<Value> {
let body: Content = args.expect("content")?;
Ok(Value::Content(body.styled(TextNode::SMALLCAPS, true)))
}
diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs
index 5466637e..d09d8f28 100644
--- a/library/src/text/mod.rs
+++ b/library/src/text/mod.rs
@@ -26,6 +26,8 @@ use crate::layout::ParNode;
use crate::prelude::*;
/// A single run of text with the same style.
+#[func]
+#[capable]
#[derive(Clone, Hash)]
pub struct TextNode(pub EcoString);
diff --git a/library/src/text/quotes.rs b/library/src/text/quotes.rs
index 95cf1ad9..0f678de3 100644
--- a/library/src/text/quotes.rs
+++ b/library/src/text/quotes.rs
@@ -3,6 +3,8 @@ use typst::syntax::is_newline;
use crate::prelude::*;
/// A smart quote.
+#[func]
+#[capable]
#[derive(Debug, Hash)]
pub struct SmartQuoteNode {
pub double: bool,
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs
index 21a0531a..4ad70654 100644
--- a/library/src/text/raw.rs
+++ b/library/src/text/raw.rs
@@ -7,6 +7,8 @@ use crate::layout::BlockNode;
use crate::prelude::*;
/// Raw text with optional syntax highlighting.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct RawNode {
/// The raw text.
@@ -15,7 +17,7 @@ pub struct RawNode {
pub block: bool,
}
-#[node(Show)]
+#[node]
impl RawNode {
/// The language to syntax-highlight in.
#[property(referenced)]
diff --git a/library/src/text/shift.rs b/library/src/text/shift.rs
index 92e963e8..65adc027 100644
--- a/library/src/text/shift.rs
+++ b/library/src/text/shift.rs
@@ -10,6 +10,8 @@ use crate::prelude::*;
/// typography possible, we first try to transform the text to superscript
/// codepoints. If that fails, we fall back to rendering shrunk normal letters
/// in a raised way.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct ShiftNode<const S: ShiftKind>(pub Content);
@@ -19,7 +21,7 @@ pub type SuperNode = ShiftNode<SUPERSCRIPT>;
/// Shift the text into subscript.
pub type SubNode = ShiftNode<SUBSCRIPT>;
-#[node(Show)]
+#[node]
impl<const S: ShiftKind> ShiftNode<S> {
/// Whether to prefer the dedicated sub- and superscript characters of the
/// font.
diff --git a/library/src/text/symbol.rs b/library/src/text/symbol.rs
index cc12afb9..fc746eb2 100644
--- a/library/src/text/symbol.rs
+++ b/library/src/text/symbol.rs
@@ -2,10 +2,12 @@ use crate::prelude::*;
use crate::text::TextNode;
/// A symbol identified by symmie notation.
+#[func]
+#[capable(Show)]
#[derive(Debug, Hash)]
pub struct SymbolNode(pub EcoString);
-#[node(Show)]
+#[node]
impl SymbolNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("notation")?).pack())