summaryrefslogtreecommitdiff
path: root/library/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/math')
-rw-r--r--library/src/math/matrix.rs8
-rw-r--r--library/src/math/mod.rs40
-rw-r--r--library/src/math/style.rs32
3 files changed, 60 insertions, 20 deletions
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs
index bc5e542a..2d32f4b5 100644
--- a/library/src/math/matrix.rs
+++ b/library/src/math/matrix.rs
@@ -1,10 +1,12 @@
use super::*;
/// A column vector.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct VecNode(Vec<Content>);
-#[node(Texify)]
+#[node]
impl VecNode {
/// The kind of delimiter.
pub const DELIM: Delimiter = Delimiter::Paren;
@@ -61,10 +63,12 @@ castable! {
}
/// A case distinction.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct CasesNode(Vec<Content>);
-#[node(Texify)]
+#[node]
impl CasesNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.all()?).pack())
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 317bc1d4..59c621e8 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -15,6 +15,8 @@ use crate::prelude::*;
use crate::text::{FontFamily, LinebreakNode, SpaceNode, SymbolNode, TextNode};
/// A piece of a mathematical formula.
+#[func]
+#[capable(Show, Layout, Inline, Texify)]
#[derive(Debug, Clone, Hash)]
pub struct MathNode {
/// Whether the formula is display-level.
@@ -23,7 +25,7 @@ pub struct MathNode {
pub children: Vec<Content>,
}
-#[node(Show, Layout, Inline, Texify)]
+#[node]
impl MathNode {
fn field(&self, name: &str) -> Option<Value> {
match name {
@@ -242,10 +244,12 @@ impl Texify for Content {
}
/// An atom in a math formula: `x`, `+`, `12`.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct AtomNode(pub EcoString);
-#[node(Texify)]
+#[node]
impl AtomNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("text")?).pack())
@@ -279,6 +283,8 @@ impl Texify for AtomNode {
}
/// An accented node.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct AccNode {
/// The accent base.
@@ -287,7 +293,7 @@ pub struct AccNode {
pub accent: char,
}
-#[node(Texify)]
+#[node]
impl AccNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
let base = args.expect("base")?;
@@ -352,6 +358,8 @@ impl Texify for AccNode {
}
/// A fraction.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct FracNode {
/// The numerator.
@@ -360,7 +368,7 @@ pub struct FracNode {
pub denom: Content,
}
-#[node(Texify)]
+#[node]
impl FracNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
let num = args.expect("numerator")?;
@@ -381,6 +389,8 @@ impl Texify for FracNode {
}
/// A binomial.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct BinomNode {
/// The upper index.
@@ -389,7 +399,7 @@ pub struct BinomNode {
pub lower: Content,
}
-#[node(Texify)]
+#[node]
impl BinomNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
let upper = args.expect("upper index")?;
@@ -410,6 +420,8 @@ impl Texify for BinomNode {
}
/// A sub- and/or superscript.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct ScriptNode {
/// The base.
@@ -420,7 +432,7 @@ pub struct ScriptNode {
pub sup: Option<Content>,
}
-#[node(Texify)]
+#[node]
impl ScriptNode {}
impl Texify for ScriptNode {
@@ -444,10 +456,12 @@ impl Texify for ScriptNode {
}
/// A math alignment point: `&`, `&&`.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct AlignPointNode(pub usize);
-#[node(Texify)]
+#[node]
impl AlignPointNode {}
impl Texify for AlignPointNode {
@@ -457,10 +471,12 @@ impl Texify for AlignPointNode {
}
/// A square root.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct SqrtNode(pub Content);
-#[node(Texify)]
+#[node]
impl SqrtNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -477,10 +493,12 @@ impl Texify for SqrtNode {
}
/// A floored expression.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct FloorNode(pub Content);
-#[node(Texify)]
+#[node]
impl FloorNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -497,10 +515,12 @@ impl Texify for FloorNode {
}
/// A ceiled expression.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct CeilNode(pub Content);
-#[node(Texify)]
+#[node]
impl CeilNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
diff --git a/library/src/math/style.rs b/library/src/math/style.rs
index 9e81a549..0fdff740 100644
--- a/library/src/math/style.rs
+++ b/library/src/math/style.rs
@@ -1,10 +1,12 @@
use super::*;
/// Serif (roman) font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct SerifNode(pub Content);
-#[node(Texify)]
+#[node]
impl SerifNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -21,10 +23,12 @@ impl Texify for SerifNode {
}
/// Sans-serif font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct SansNode(pub Content);
-#[node(Texify)]
+#[node]
impl SansNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -41,10 +45,12 @@ impl Texify for SansNode {
}
/// Bold font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct BoldNode(pub Content);
-#[node(Texify)]
+#[node]
impl BoldNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -61,10 +67,12 @@ impl Texify for BoldNode {
}
/// Italic font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct ItalNode(pub Content);
-#[node(Texify)]
+#[node]
impl ItalNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -81,10 +89,12 @@ impl Texify for ItalNode {
}
/// Calligraphic font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct CalNode(pub Content);
-#[node(Texify)]
+#[node]
impl CalNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -101,10 +111,12 @@ impl Texify for CalNode {
}
/// Fraktur font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct FrakNode(pub Content);
-#[node(Texify)]
+#[node]
impl FrakNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -121,10 +133,12 @@ impl Texify for FrakNode {
}
/// Monospace font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct MonoNode(pub Content);
-#[node(Texify)]
+#[node]
impl MonoNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())
@@ -141,10 +155,12 @@ impl Texify for MonoNode {
}
/// Blackboard bold (double-struck) font style.
+#[func]
+#[capable(Texify)]
#[derive(Debug, Hash)]
pub struct BbNode(pub Content);
-#[node(Texify)]
+#[node]
impl BbNode {
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.expect("body")?).pack())