More restructuring
@ -9,7 +9,8 @@ use crate::diag::TypResult;
|
||||
use crate::eval::StyleChain;
|
||||
use crate::frame::{Element, Frame, Geometry, Shape, Stroke};
|
||||
use crate::geom::{Align, Length, Linear, Paint, Point, Sides, Size, Spec, Transform};
|
||||
use crate::library::layout::{AlignNode, MoveNode, PadNode};
|
||||
use crate::library::graphics::MoveNode;
|
||||
use crate::library::layout::{AlignNode, PadNode};
|
||||
use crate::util::Prehashed;
|
||||
use crate::Context;
|
||||
|
||||
|
@ -155,7 +155,7 @@ impl Eval for MathNode {
|
||||
type Output = Template;
|
||||
|
||||
fn eval(&self, _: &mut Context, _: &mut Scopes) -> EvalResult<Self::Output> {
|
||||
Ok(Template::show(library::elements::MathNode {
|
||||
Ok(Template::show(library::math::MathNode {
|
||||
formula: self.formula.clone(),
|
||||
display: self.display,
|
||||
}))
|
||||
@ -166,7 +166,7 @@ impl Eval for HeadingNode {
|
||||
type Output = Template;
|
||||
|
||||
fn eval(&self, ctx: &mut Context, scp: &mut Scopes) -> EvalResult<Self::Output> {
|
||||
Ok(Template::show(library::elements::HeadingNode {
|
||||
Ok(Template::show(library::structure::HeadingNode {
|
||||
body: self.body().eval(ctx, scp)?,
|
||||
level: self.level(),
|
||||
}))
|
||||
@ -177,7 +177,7 @@ impl Eval for ListNode {
|
||||
type Output = Template;
|
||||
|
||||
fn eval(&self, ctx: &mut Context, scp: &mut Scopes) -> EvalResult<Self::Output> {
|
||||
Ok(Template::List(library::elements::ListItem {
|
||||
Ok(Template::List(library::structure::ListItem {
|
||||
number: None,
|
||||
body: Box::new(self.body().eval(ctx, scp)?),
|
||||
}))
|
||||
@ -188,7 +188,7 @@ impl Eval for EnumNode {
|
||||
type Output = Template;
|
||||
|
||||
fn eval(&self, ctx: &mut Context, scp: &mut Scopes) -> EvalResult<Self::Output> {
|
||||
Ok(Template::Enum(library::elements::ListItem {
|
||||
Ok(Template::Enum(library::structure::ListItem {
|
||||
number: self.number(),
|
||||
body: Box::new(self.body().eval(ctx, scp)?),
|
||||
}))
|
||||
|
@ -10,9 +10,9 @@ use super::{
|
||||
StyleMap, StyleVecBuilder,
|
||||
};
|
||||
use crate::diag::StrResult;
|
||||
use crate::library::elements::{ListItem, ListKind, ListNode, ORDERED, UNORDERED};
|
||||
use crate::library::layout::{FlowChild, FlowNode, PageNode, PlaceNode, SpacingKind};
|
||||
use crate::library::prelude::*;
|
||||
use crate::library::structure::{ListItem, ListKind, ListNode, ORDERED, UNORDERED};
|
||||
use crate::library::text::{DecoNode, ParChild, ParNode, TextNode, UNDERLINE};
|
||||
use crate::util::EcoString;
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
//! Primitive and semantic elements.
|
||||
|
||||
mod heading;
|
||||
mod image;
|
||||
mod list;
|
||||
mod math;
|
||||
mod shape;
|
||||
mod table;
|
||||
|
||||
pub use self::image::*;
|
||||
pub use heading::*;
|
||||
pub use list::*;
|
||||
pub use math::*;
|
||||
pub use shape::*;
|
||||
pub use table::*;
|
11
src/library/graphics/mod.rs
Normal file
@ -0,0 +1,11 @@
|
||||
//! Graphical elements and effects.
|
||||
|
||||
mod hide;
|
||||
mod image;
|
||||
mod shape;
|
||||
mod transform;
|
||||
|
||||
pub use self::image::*;
|
||||
pub use hide::*;
|
||||
pub use shape::*;
|
||||
pub use transform::*;
|
@ -5,23 +5,19 @@ mod columns;
|
||||
mod container;
|
||||
mod flow;
|
||||
mod grid;
|
||||
mod hide;
|
||||
mod pad;
|
||||
mod page;
|
||||
mod place;
|
||||
mod spacing;
|
||||
mod stack;
|
||||
mod transform;
|
||||
|
||||
pub use align::*;
|
||||
pub use columns::*;
|
||||
pub use container::*;
|
||||
pub use flow::*;
|
||||
pub use grid::*;
|
||||
pub use hide::*;
|
||||
pub use pad::*;
|
||||
pub use page::*;
|
||||
pub use place::*;
|
||||
pub use spacing::*;
|
||||
pub use stack::*;
|
||||
pub use transform::*;
|
||||
|
@ -3,9 +3,11 @@
|
||||
//! Call [`new`] to obtain a [`Scope`] containing all standard library
|
||||
//! definitions.
|
||||
|
||||
pub mod elements;
|
||||
pub mod graphics;
|
||||
pub mod layout;
|
||||
pub mod math;
|
||||
pub mod prelude;
|
||||
pub mod structure;
|
||||
pub mod text;
|
||||
pub mod utility;
|
||||
|
||||
@ -18,8 +20,8 @@ pub fn new() -> Scope {
|
||||
// Text.
|
||||
std.def_class::<text::TextNode>("text");
|
||||
std.def_class::<text::ParNode>("par");
|
||||
std.def_class::<text::ParbreakNode>("parbreak");
|
||||
std.def_class::<text::LinebreakNode>("linebreak");
|
||||
std.def_class::<text::ParbreakNode>("parbreak");
|
||||
std.def_class::<text::StrongNode>("strong");
|
||||
std.def_class::<text::EmphNode>("emph");
|
||||
std.def_class::<text::RawNode>("raw");
|
||||
@ -28,17 +30,11 @@ pub fn new() -> Scope {
|
||||
std.def_class::<text::OverlineNode>("overline");
|
||||
std.def_class::<text::LinkNode>("link");
|
||||
|
||||
// Elements.
|
||||
std.def_class::<elements::MathNode>("math");
|
||||
std.def_class::<elements::HeadingNode>("heading");
|
||||
std.def_class::<elements::ListNode>("list");
|
||||
std.def_class::<elements::EnumNode>("enum");
|
||||
std.def_class::<elements::TableNode>("table");
|
||||
std.def_class::<elements::ImageNode>("image");
|
||||
std.def_class::<elements::RectNode>("rect");
|
||||
std.def_class::<elements::SquareNode>("square");
|
||||
std.def_class::<elements::EllipseNode>("ellipse");
|
||||
std.def_class::<elements::CircleNode>("circle");
|
||||
// Structure.
|
||||
std.def_class::<structure::HeadingNode>("heading");
|
||||
std.def_class::<structure::ListNode>("list");
|
||||
std.def_class::<structure::EnumNode>("enum");
|
||||
std.def_class::<structure::TableNode>("table");
|
||||
|
||||
// Layout.
|
||||
std.def_class::<layout::PageNode>("page");
|
||||
@ -54,10 +50,20 @@ pub fn new() -> Scope {
|
||||
std.def_class::<layout::ColumnsNode>("columns");
|
||||
std.def_class::<layout::ColbreakNode>("colbreak");
|
||||
std.def_class::<layout::PlaceNode>("place");
|
||||
std.def_class::<layout::MoveNode>("move");
|
||||
std.def_class::<layout::ScaleNode>("scale");
|
||||
std.def_class::<layout::RotateNode>("rotate");
|
||||
std.def_class::<layout::HideNode>("hide");
|
||||
|
||||
// Graphics.
|
||||
std.def_class::<graphics::ImageNode>("image");
|
||||
std.def_class::<graphics::RectNode>("rect");
|
||||
std.def_class::<graphics::SquareNode>("square");
|
||||
std.def_class::<graphics::EllipseNode>("ellipse");
|
||||
std.def_class::<graphics::CircleNode>("circle");
|
||||
std.def_class::<graphics::MoveNode>("move");
|
||||
std.def_class::<graphics::ScaleNode>("scale");
|
||||
std.def_class::<graphics::RotateNode>("rotate");
|
||||
std.def_class::<graphics::HideNode>("hide");
|
||||
|
||||
// Math.
|
||||
std.def_class::<math::MathNode>("math");
|
||||
|
||||
// Utility functions.
|
||||
std.def_func("assert", utility::assert);
|
||||
|
9
src/library/structure/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
//! Document structuring.
|
||||
|
||||
mod heading;
|
||||
mod list;
|
||||
mod table;
|
||||
|
||||
pub use heading::*;
|
||||
pub use list::*;
|
||||
pub use table::*;
|
Before Width: | Height: | Size: 936 B After Width: | Height: | Size: 936 B |
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 179 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@ -16,6 +16,17 @@
|
||||
// Error: 6-10 expected string, array or dictionary, found length
|
||||
#len(12pt)
|
||||
|
||||
---
|
||||
// Test the `upper` and `lower` functions.
|
||||
#let memes = "ArE mEmEs gReAt?";
|
||||
#test(lower(memes), "are memes great?")
|
||||
#test(upper(memes), "ARE MEMES GREAT?")
|
||||
#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ")
|
||||
|
||||
---
|
||||
// Error: 8-9 expected string or template, found integer
|
||||
#upper(1)
|
||||
|
||||
---
|
||||
// Test the `sorted` function.
|
||||
#test(sorted(()), ())
|
||||
|
19
tests/typ/utility/numbering.typ
Normal file
@ -0,0 +1,19 @@
|
||||
// Test numbering formatting functions.
|
||||
|
||||
---
|
||||
#upper("Abc 8")
|
||||
#upper[def]
|
||||
|
||||
#lower("SCREAMING MUST BE SILENCED in " + roman(1672) + " years")
|
||||
|
||||
#for i in range(9) {
|
||||
symbol(i)
|
||||
[ and ]
|
||||
roman(i)
|
||||
[ for #i]
|
||||
parbreak()
|
||||
}
|
||||
|
||||
---
|
||||
// Error: 9-11 must be at least zero
|
||||
#symbol(-1)
|
@ -1,34 +0,0 @@
|
||||
// Test string handling functions.
|
||||
// Ref: false
|
||||
|
||||
---
|
||||
// Test the `upper`, `lower`, and number formatting functions.
|
||||
#let memes = "ArE mEmEs gReAt?";
|
||||
#test(lower(memes), "are memes great?")
|
||||
#test(upper(memes), "ARE MEMES GREAT?")
|
||||
#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ")
|
||||
|
||||
---
|
||||
// Test numbering formatting functions.
|
||||
// Ref: true
|
||||
|
||||
#upper("Abc 8")
|
||||
#upper[def]
|
||||
|
||||
#lower("SCREAMING MUST BE SILENCED in " + roman(1672) + " years")
|
||||
|
||||
#for i in range(9) {
|
||||
symbol(i)
|
||||
[ and ]
|
||||
roman(i)
|
||||
[ for #i]
|
||||
parbreak()
|
||||
}
|
||||
|
||||
---
|
||||
// Error: 8-9 expected string or template, found integer
|
||||
#upper(1)
|
||||
|
||||
---
|
||||
// Error: 9-11 must be at least zero
|
||||
#symbol(-1)
|