summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-18 19:27:31 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-18 19:27:31 +0100
commita69b5874558eb50c96293813cbe67aac38174644 (patch)
treec59e671a4f73b467fc1f7f4de1d01ed6cfe24afe /library/src
parenta16726ae6652a795ff24f368ca25f93bae673366 (diff)
Rename formula to equation
Diffstat (limited to 'library/src')
-rw-r--r--library/src/layout/container.rs2
-rw-r--r--library/src/layout/mod.rs8
-rw-r--r--library/src/layout/par.rs16
-rw-r--r--library/src/lib.rs2
-rw-r--r--library/src/math/mod.rs22
-rw-r--r--library/src/math/op.rs2
-rw-r--r--library/src/math/style.rs22
7 files changed, 37 insertions, 37 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index 0b7f7eb1..bdc147c3 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -261,7 +261,7 @@ pub struct BlockNode {
///
/// ```example
/// #set align(center)
- /// #show math.formula: set block(above: 8pt, below: 16pt)
+ /// #show math.equation: set block(above: 8pt, below: 16pt)
///
/// This sum of $x$ and $y$:
/// $ x + y = z $
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index 4a38acb6..0ce292aa 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -50,7 +50,7 @@ use typst::diag::SourceResult;
use typst::eval::Tracer;
use typst::model::{applicable, realize, SequenceNode, StyleVecBuilder, StyledNode};
-use crate::math::{FormulaNode, LayoutMath};
+use crate::math::{EquationNode, LayoutMath};
use crate::meta::DocumentNode;
use crate::prelude::*;
use crate::shared::BehavedBuilder;
@@ -245,9 +245,9 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
mut content: &'a Content,
styles: StyleChain<'a>,
) -> SourceResult<()> {
- if content.can::<dyn LayoutMath>() && !content.is::<FormulaNode>() {
+ if content.can::<dyn LayoutMath>() && !content.is::<EquationNode>() {
content =
- self.scratch.content.alloc(FormulaNode::new(content.clone()).pack());
+ self.scratch.content.alloc(EquationNode::new(content.clone()).pack());
}
if let Some(styled) = content.to::<StyledNode>() {
@@ -491,7 +491,7 @@ impl<'a> ParBuilder<'a> {
|| content.is::<HNode>()
|| content.is::<LinebreakNode>()
|| content.is::<SmartQuoteNode>()
- || content.to::<FormulaNode>().map_or(false, |node| !node.block(styles))
+ || content.to::<EquationNode>().map_or(false, |node| !node.block(styles))
|| content.is::<BoxNode>()
{
self.0.push(content.clone(), styles);
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index 8657d7fb..cef0d11c 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -7,7 +7,7 @@ use typst::model::StyledNode;
use super::{BoxNode, HNode, Sizing, Spacing};
use crate::layout::AlignNode;
-use crate::math::FormulaNode;
+use crate::math::EquationNode;
use crate::prelude::*;
use crate::text::{
shape, LinebreakNode, Quoter, Quotes, ShapedText, SmartQuoteNode, SpaceNode, TextNode,
@@ -324,8 +324,8 @@ enum Segment<'a> {
Text(usize),
/// Horizontal spacing between other segments.
Spacing(Spacing),
- /// A math formula.
- Formula(&'a FormulaNode),
+ /// A mathematical equation.
+ Equation(&'a EquationNode),
/// A box with arbitrary content.
Box(&'a BoxNode, bool),
/// Metadata.
@@ -339,7 +339,7 @@ impl Segment<'_> {
Self::Text(len) => len,
Self::Spacing(_) => SPACING_REPLACE.len_utf8(),
Self::Box(_, true) => SPACING_REPLACE.len_utf8(),
- Self::Formula(_) | Self::Box(_, _) | Self::Meta => NODE_REPLACE.len_utf8(),
+ Self::Equation(_) | Self::Box(_, _) | Self::Meta => NODE_REPLACE.len_utf8(),
}
}
}
@@ -597,9 +597,9 @@ fn collect<'a>(
full.push(if node.double(styles) { '"' } else { '\'' });
}
Segment::Text(full.len() - prev)
- } else if let Some(node) = child.to::<FormulaNode>() {
+ } else if let Some(node) = child.to::<EquationNode>() {
full.push(NODE_REPLACE);
- Segment::Formula(node)
+ Segment::Equation(node)
} else if let Some(node) = child.to::<BoxNode>() {
let frac = node.width(styles).is_fractional();
full.push(if frac { SPACING_REPLACE } else { NODE_REPLACE });
@@ -671,9 +671,9 @@ fn prepare<'a>(
items.push(Item::Fractional(v, None));
}
},
- Segment::Formula(formula) => {
+ Segment::Equation(equation) => {
let pod = Regions::one(region, Axes::splat(false));
- let mut frame = formula.layout(vt, styles, pod)?.into_frame();
+ let mut frame = equation.layout(vt, styles, pod)?.into_frame();
frame.translate(Point::with_y(TextNode::baseline_in(styles)));
items.push(Item::Frame(frame));
}
diff --git a/library/src/lib.rs b/library/src/lib.rs
index 0850faf4..14fea66d 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -211,7 +211,7 @@ fn items() -> LangItems {
node.pack()
},
term_item: |term, description| layout::TermItem::new(term, description).pack(),
- formula: |body, block| math::FormulaNode::new(body).with_block(block).pack(),
+ equation: |body, block| math::EquationNode::new(body).with_block(block).pack(),
math_align_point: || math::AlignPointNode::new().pack(),
math_delimited: |open, body, close| math::LrNode::new(open + body + close).pack(),
math_attach: |base, bottom, top| {
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 6df1d87a..c1e352d1 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -47,7 +47,7 @@ use crate::text::{
/// Create a module with all math definitions.
pub fn module() -> Module {
let mut math = Scope::deduplicating();
- math.define("formula", FormulaNode::id());
+ math.define("equation", EquationNode::id());
math.define("text", TextNode::id());
// Grouping.
@@ -106,7 +106,7 @@ pub fn module() -> Module {
Module::new("math").with_scope(math)
}
-/// A mathematical formula.
+/// A mathematical equation.
///
/// Can be displayed inline with text or as a separate block.
///
@@ -125,25 +125,25 @@ pub fn module() -> Module {
///
/// ## Syntax
/// This function also has dedicated syntax: Write mathematical markup within
-/// dollar signs to create a formula. Starting and ending the formula with at
+/// dollar signs to create an equation. Starting and ending the equation with at
/// least one space lifts it into a separate block that is centered
/// horizontally. For more details about math syntax, see the
/// [main math page]($category/math).
///
-/// Display: Formula
+/// Display: Equation
/// Category: math
#[node(Show, Finalize, Layout, LayoutMath)]
-pub struct FormulaNode {
- /// Whether the formula is displayed as a separate block.
+pub struct EquationNode {
+ /// Whether the equation is displayed as a separate block.
#[default(false)]
pub block: bool,
- /// The content of the formula.
+ /// The contents of the equation.
#[required]
pub body: Content,
}
-impl Show for FormulaNode {
+impl Show for EquationNode {
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) {
@@ -153,7 +153,7 @@ impl Show for FormulaNode {
}
}
-impl Finalize for FormulaNode {
+impl Finalize for EquationNode {
fn finalize(&self, realized: Content, _: StyleChain) -> Content {
realized
.styled(TextNode::set_weight(FontWeight::from_number(450)))
@@ -163,7 +163,7 @@ impl Finalize for FormulaNode {
}
}
-impl Layout for FormulaNode {
+impl Layout for EquationNode {
fn layout(
&self,
vt: &mut Vt,
@@ -209,7 +209,7 @@ pub trait LayoutMath {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()>;
}
-impl LayoutMath for FormulaNode {
+impl LayoutMath for EquationNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
self.body().layout_math(ctx)
}
diff --git a/library/src/math/op.rs b/library/src/math/op.rs
index bd81aa0e..dae43c3a 100644
--- a/library/src/math/op.rs
+++ b/library/src/math/op.rs
@@ -2,7 +2,7 @@ use typst::eval::Scope;
use super::*;
-/// A text operator in a math formula.
+/// A text operator in an equation.
///
/// ## Example
/// ```example
diff --git a/library/src/math/style.rs b/library/src/math/style.rs
index 60bad6a5..a3383a0c 100644
--- a/library/src/math/style.rs
+++ b/library/src/math/style.rs
@@ -11,7 +11,7 @@ use super::*;
/// Category: math
#[node(LayoutMath)]
pub struct BoldNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -36,7 +36,7 @@ impl LayoutMath for BoldNode {
/// Category: math
#[node(LayoutMath)]
pub struct UprightNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -58,7 +58,7 @@ impl LayoutMath for UprightNode {
/// Category: math
#[node(LayoutMath)]
pub struct ItalicNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -80,7 +80,7 @@ impl LayoutMath for ItalicNode {
/// Category: math
#[node(LayoutMath)]
pub struct SerifNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -105,7 +105,7 @@ impl LayoutMath for SerifNode {
/// Category: math
#[node(LayoutMath)]
pub struct SansNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -130,7 +130,7 @@ impl LayoutMath for SansNode {
/// Category: math
#[node(LayoutMath)]
pub struct CalNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -155,7 +155,7 @@ impl LayoutMath for CalNode {
/// Category: math
#[node(LayoutMath)]
pub struct FrakNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -180,7 +180,7 @@ impl LayoutMath for FrakNode {
/// Category: math
#[node(LayoutMath)]
pub struct MonoNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -210,7 +210,7 @@ impl LayoutMath for MonoNode {
/// Category: math
#[node(LayoutMath)]
pub struct BbNode {
- /// The piece of formula to style.
+ /// The content to style.
#[required]
pub body: Content,
}
@@ -224,7 +224,7 @@ impl LayoutMath for BbNode {
}
}
-/// Text properties in a formula.
+/// Text properties in math.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MathStyle {
/// The style variant to select.
@@ -298,7 +298,7 @@ impl MathStyle {
}
}
-/// The size of elements in a formula.
+/// The size of elements in an equation.
///
/// See the TeXbook p. 141.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]