diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-16 14:43:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-16 14:43:38 +0100 |
| commit | 67b45403975ba89150d17356dfbcad3e2ed18391 (patch) | |
| tree | d7818f69fcb3922949122a98070dd5617e59897e | |
| parent | f60d344621a47726da7b9fbe7163b2a3fbc3f9ff (diff) | |
Dissolve utility category
| -rw-r--r-- | docs/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/src/compute/mod.rs | 2 | ||||
| -rw-r--r-- | library/src/layout/enum.rs | 2 | ||||
| -rw-r--r-- | library/src/lib.rs | 4 | ||||
| -rw-r--r-- | library/src/meta/heading.rs | 2 | ||||
| -rw-r--r-- | library/src/meta/mod.rs | 2 | ||||
| -rw-r--r-- | library/src/meta/numbering.rs (renamed from library/src/compute/utility.rs) | 33 | ||||
| -rw-r--r-- | library/src/text/misc.rs | 31 | ||||
| -rw-r--r-- | tests/ref/compute/utility.png | bin | 34604 -> 0 bytes | |||
| -rw-r--r-- | tests/ref/meta/numbering.png | bin | 0 -> 7276 bytes | |||
| -rw-r--r-- | tests/ref/text/lorem.png | bin | 0 -> 27326 bytes | |||
| -rw-r--r-- | tests/typ/meta/numbering.typ | 18 | ||||
| -rw-r--r-- | tests/typ/text/lorem.typ (renamed from tests/typ/compute/utility.typ) | 19 |
13 files changed, 57 insertions, 57 deletions
diff --git a/docs/src/lib.rs b/docs/src/lib.rs index 57f8657e..1989970e 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -136,7 +136,6 @@ fn reference_page(resolver: &dyn Resolver) -> PageModel { category_page(resolver, "calculate"), category_page(resolver, "construct"), category_page(resolver, "data-loading"), - category_page(resolver, "utility"), ]; page } diff --git a/library/src/compute/mod.rs b/library/src/compute/mod.rs index 5cfbe158..cf0486db 100644 --- a/library/src/compute/mod.rs +++ b/library/src/compute/mod.rs @@ -4,10 +4,8 @@ mod calc; mod construct; mod data; mod foundations; -mod utility; pub use self::calc::*; pub use self::construct::*; pub use self::data::*; pub use self::foundations::*; -pub use self::utility::*; diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs index 866a6195..53fc3327 100644 --- a/library/src/layout/enum.rs +++ b/library/src/layout/enum.rs @@ -1,7 +1,7 @@ use std::str::FromStr; -use crate::compute::{Numbering, NumberingPattern}; use crate::layout::{BlockNode, GridNode, ParNode, Sizing, Spacing}; +use crate::meta::{Numbering, NumberingPattern}; use crate::prelude::*; use crate::text::TextNode; diff --git a/library/src/lib.rs b/library/src/lib.rs index 412ebd41..8a231531 100644 --- a/library/src/lib.rs +++ b/library/src/lib.rs @@ -42,6 +42,7 @@ fn global(math: Module, calc: Module) -> Module { global.def_func::<text::StrikeNode>("strike"); global.def_func::<text::OverlineNode>("overline"); global.def_func::<text::RawNode>("raw"); + global.def_func::<text::LoremFunc>("lorem"); // Math. global.define("math", math); @@ -86,6 +87,7 @@ fn global(math: Module, calc: Module) -> Module { global.def_func::<meta::LinkNode>("link"); global.def_func::<meta::OutlineNode>("outline"); global.def_func::<meta::HeadingNode>("heading"); + global.def_func::<meta::NumberingFunc>("numbering"); // Symbols. global.define("sym", symbols::sym()); @@ -110,8 +112,6 @@ fn global(math: Module, calc: Module) -> Module { global.def_func::<compute::CsvFunc>("csv"); global.def_func::<compute::JsonFunc>("json"); global.def_func::<compute::XmlFunc>("xml"); - global.def_func::<compute::LoremFunc>("lorem"); - global.def_func::<compute::NumberingFunc>("numbering"); // Calc. global.define("calc", calc); diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs index b5b0fd9e..c9032e88 100644 --- a/library/src/meta/heading.rs +++ b/library/src/meta/heading.rs @@ -1,6 +1,6 @@ use typst::font::FontWeight; -use crate::compute::Numbering; +use super::Numbering; use crate::layout::{BlockNode, VNode}; use crate::prelude::*; use crate::text::{SpaceNode, TextNode, TextSize}; diff --git a/library/src/meta/mod.rs b/library/src/meta/mod.rs index fd72a8cb..07f449a4 100644 --- a/library/src/meta/mod.rs +++ b/library/src/meta/mod.rs @@ -3,11 +3,13 @@ mod document; mod heading; mod link; +mod numbering; mod outline; mod reference; pub use self::document::*; pub use self::heading::*; pub use self::link::*; +pub use self::numbering::*; pub use self::outline::*; pub use self::reference::*; diff --git a/library/src/compute/utility.rs b/library/src/meta/numbering.rs index 2220c890..c187c18d 100644 --- a/library/src/compute/utility.rs +++ b/library/src/meta/numbering.rs @@ -3,37 +3,6 @@ use std::str::FromStr; use crate::prelude::*; use crate::text::Case; -/// # Blind Text -/// Create blind text. -/// -/// This function yields a Latin-like _Lorem Ipsum_ blind text with the given -/// number of words. The sequence of words generated by the function is always -/// the same but randomly chosen. As usual for blind texts, it does not make any -/// sense. Use it as a placeholder to try layouts. -/// -/// ## Example -/// ```example -/// = Blind Text -/// #lorem(30) -/// -/// = More Blind Text -/// #lorem(15) -/// ``` -/// -/// ## Parameters -/// - words: `usize` (positional, required) -/// The length of the blind text in words. -/// -/// - returns: string -/// -/// ## Category -/// utility -#[func] -pub fn lorem(args: &mut Args) -> SourceResult<Value> { - let words: usize = args.expect("number of words")?; - Ok(Value::Str(lipsum::lipsum(words).into())) -} - /// # Numbering /// Apply a numbering to a sequence of numbers. /// @@ -93,7 +62,7 @@ pub fn lorem(args: &mut Args) -> SourceResult<Value> { /// - returns: any /// /// ## Category -/// utility +/// meta #[func] pub fn numbering(vm: &Vm, args: &mut Args) -> SourceResult<Value> { let numbering = args.expect::<Numbering>("pattern or function")?; diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index 184294d4..43aea021 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -345,3 +345,34 @@ pub fn smallcaps(args: &mut Args) -> SourceResult<Value> { let body: Content = args.expect("content")?; Ok(Value::Content(body.styled(TextNode::SMALLCAPS, true))) } + +/// # Blind Text +/// Create blind text. +/// +/// This function yields a Latin-like _Lorem Ipsum_ blind text with the given +/// number of words. The sequence of words generated by the function is always +/// the same but randomly chosen. As usual for blind texts, it does not make any +/// sense. Use it as a placeholder to try layouts. +/// +/// ## Example +/// ```example +/// = Blind Text +/// #lorem(30) +/// +/// = More Blind Text +/// #lorem(15) +/// ``` +/// +/// ## Parameters +/// - words: `usize` (positional, required) +/// The length of the blind text in words. +/// +/// - returns: string +/// +/// ## Category +/// text +#[func] +pub fn lorem(args: &mut Args) -> SourceResult<Value> { + let words: usize = args.expect("number of words")?; + Ok(Value::Str(lipsum::lipsum(words).into())) +} diff --git a/tests/ref/compute/utility.png b/tests/ref/compute/utility.png Binary files differdeleted file mode 100644 index 79e3096d..00000000 --- a/tests/ref/compute/utility.png +++ /dev/null diff --git a/tests/ref/meta/numbering.png b/tests/ref/meta/numbering.png Binary files differnew file mode 100644 index 00000000..ed97d891 --- /dev/null +++ b/tests/ref/meta/numbering.png diff --git a/tests/ref/text/lorem.png b/tests/ref/text/lorem.png Binary files differnew file mode 100644 index 00000000..ded76330 --- /dev/null +++ b/tests/ref/text/lorem.png diff --git a/tests/typ/meta/numbering.typ b/tests/typ/meta/numbering.typ new file mode 100644 index 00000000..63e45362 --- /dev/null +++ b/tests/typ/meta/numbering.typ @@ -0,0 +1,18 @@ +// Test integrated numbering patterns. + +--- +#for i in range(1, 9) { + numbering("*", i) + [ and ] + numbering("I.a", i, i) + [ for #i] + parbreak() +} + +--- +// Error: 17-18 number must be positive +#numbering("1", 0) + +--- +// Error: 17-19 number must be positive +#numbering("1", -1) diff --git a/tests/typ/compute/utility.typ b/tests/typ/text/lorem.typ index 73bb2e2d..944fd5be 100644 --- a/tests/typ/compute/utility.typ +++ b/tests/typ/text/lorem.typ @@ -1,4 +1,4 @@ -// Test integrated numbering patterns. +// Test blind text. --- // Test basic call. @@ -30,20 +30,3 @@ --- // Error: 7-9 missing argument: number of words #lorem() - ---- -#for i in range(1, 9) { - numbering("*", i) - [ and ] - numbering("I.a", i, i) - [ for #i] - parbreak() -} - ---- -// Error: 17-18 number must be positive -#numbering("1", 0) - ---- -// Error: 17-19 number must be positive -#numbering("1", -1) |
