mirror of
https://github.com/typst/typst
synced 2025-05-13 12:36:23 +08:00
Print function for debugging
This commit is contained in:
parent
9950a69d23
commit
ae68a15a46
@ -70,7 +70,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
styles.set(TextNode::SIZE, TextSize(Length::pt(10.0).into()));
|
styles.set(TextNode::SIZE, TextSize(Length::pt(10.0).into()));
|
||||||
|
|
||||||
// Hook up two more colors and an assert function into the global scope.
|
// Hook up helpers into the global scope.
|
||||||
let mut std = typst::library::new();
|
let mut std = typst::library::new();
|
||||||
std.define("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF));
|
std.define("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF));
|
||||||
std.define("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF));
|
std.define("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF));
|
||||||
@ -82,6 +82,17 @@ fn main() {
|
|||||||
}
|
}
|
||||||
Ok(Value::None)
|
Ok(Value::None)
|
||||||
});
|
});
|
||||||
|
std.def_fn("print", move |_, args| {
|
||||||
|
print!("> ");
|
||||||
|
for (i, value) in args.all::<Value>()?.into_iter().enumerate() {
|
||||||
|
if i > 0 {
|
||||||
|
print!(", ")
|
||||||
|
}
|
||||||
|
print!("{value:?}");
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
Ok(Value::None)
|
||||||
|
});
|
||||||
|
|
||||||
// Create loader and context.
|
// Create loader and context.
|
||||||
let loader = FsLoader::new().with_path(FONT_DIR);
|
let loader = FsLoader::new().with_path(FONT_DIR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user