Dissolve utility category
This commit is contained in:
parent
f60d344621
commit
67b4540397
@ -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
|
||||
}
|
||||
|
@ -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::*;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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};
|
||||
|
@ -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::*;
|
||||
|
@ -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")?;
|
@ -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()))
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
BIN
tests/ref/meta/numbering.png
Normal file
BIN
tests/ref/meta/numbering.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
tests/ref/text/lorem.png
Normal file
BIN
tests/ref/text/lorem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
18
tests/typ/meta/numbering.typ
Normal file
18
tests/typ/meta/numbering.typ
Normal file
@ -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)
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user