summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/src/main.rs2
-rw-r--r--library/src/basics/heading.rs (renamed from library/src/structure/heading.rs)0
-rw-r--r--library/src/basics/list.rs (renamed from library/src/structure/list.rs)6
-rw-r--r--library/src/basics/mod.rs9
-rw-r--r--library/src/basics/table.rs (renamed from library/src/structure/table.rs)0
-rw-r--r--library/src/compute/calc.rs (renamed from library/src/base/calc.rs)0
-rw-r--r--library/src/compute/create.rs (renamed from library/src/base/create.rs)6
-rw-r--r--library/src/compute/data.rs (renamed from library/src/base/data.rs)0
-rw-r--r--library/src/compute/foundations.rs (renamed from library/src/base/mod.rs)19
-rw-r--r--library/src/compute/mod.rs13
-rw-r--r--library/src/compute/utility.rs (renamed from library/src/base/numbering.rs)18
-rw-r--r--library/src/layout/align.rs2
-rw-r--r--library/src/layout/flow.rs3
-rw-r--r--library/src/layout/hide.rs (renamed from library/src/graphics/hide.rs)0
-rw-r--r--library/src/layout/mod.rs15
-rw-r--r--library/src/layout/par.rs (renamed from library/src/text/par.rs)33
-rw-r--r--library/src/layout/repeat.rs25
-rw-r--r--library/src/layout/stack.rs3
-rw-r--r--library/src/lib.rs164
-rw-r--r--library/src/meta/document.rs (renamed from library/src/structure/document.rs)2
-rw-r--r--library/src/meta/link.rs (renamed from library/src/text/link.rs)2
-rw-r--r--library/src/meta/mod.rs9
-rw-r--r--library/src/meta/reference.rs (renamed from library/src/structure/reference.rs)0
-rw-r--r--library/src/structure/mod.rs13
-rw-r--r--library/src/text/deco.rs4
-rw-r--r--library/src/text/misc.rs146
-rw-r--r--library/src/text/mod.rs179
-rw-r--r--library/src/text/quotes.rs20
-rw-r--r--library/src/text/shaping.rs7
-rw-r--r--library/src/visualize/image.rs (renamed from library/src/graphics/image.rs)2
-rw-r--r--library/src/visualize/line.rs (renamed from library/src/graphics/line.rs)0
-rw-r--r--library/src/visualize/mod.rs (renamed from library/src/graphics/mod.rs)4
-rw-r--r--library/src/visualize/shape.rs (renamed from library/src/graphics/shape.rs)2
-rw-r--r--src/model/mod.rs2
-rw-r--r--tests/README.md4
-rw-r--r--tests/ref/base/blind.pngbin27575 -> 0 bytes
-rw-r--r--tests/ref/base/color.pngbin595 -> 0 bytes
-rw-r--r--tests/ref/base/data.pngbin8603 -> 0 bytes
-rw-r--r--tests/ref/base/eval.pngbin5429 -> 0 bytes
-rw-r--r--tests/ref/base/numbering.pngbin7112 -> 0 bytes
-rw-r--r--tests/ref/basics/desc.pngbin0 -> 16887 bytes
-rw-r--r--tests/ref/basics/enum.pngbin0 -> 27690 bytes
-rw-r--r--tests/ref/basics/heading.png (renamed from tests/ref/structure/heading.png)bin24767 -> 24767 bytes
-rw-r--r--tests/ref/basics/list-attach.png (renamed from tests/ref/structure/attach.png)bin11016 -> 11016 bytes
-rw-r--r--tests/ref/basics/list.png (renamed from tests/ref/structure/list.png)bin20656 -> 20656 bytes
-rw-r--r--tests/ref/basics/table.png (renamed from tests/ref/structure/table.png)bin4295 -> 4295 bytes
-rw-r--r--tests/ref/code/block.pngbin2005 -> 0 bytes
-rw-r--r--tests/ref/code/if.pngbin2336 -> 0 bytes
-rw-r--r--tests/ref/code/import.pngbin4675 -> 0 bytes
-rw-r--r--tests/ref/code/include.pngbin47545 -> 0 bytes
-rw-r--r--tests/ref/code/let.pngbin3170 -> 0 bytes
-rw-r--r--tests/ref/code/ops.pngbin977 -> 0 bytes
-rw-r--r--tests/ref/code/return.pngbin2946 -> 0 bytes
-rw-r--r--tests/ref/code/while.pngbin1058 -> 0 bytes
-rw-r--r--tests/ref/coma.pngbin88639 -> 88737 bytes
-rw-r--r--tests/ref/compiler/array.png (renamed from tests/ref/code/array.png)bin6191 -> 6191 bytes
-rw-r--r--tests/ref/compiler/bench.pngbin0 -> 40303 bytes
-rw-r--r--tests/ref/compiler/block.pngbin0 -> 1982 bytes
-rw-r--r--tests/ref/compiler/break-continue.png (renamed from tests/ref/code/break-continue.png)bin7268 -> 7268 bytes
-rw-r--r--tests/ref/compiler/call.png (renamed from tests/ref/code/call.png)bin2337 -> 2337 bytes
-rw-r--r--tests/ref/compiler/closure.png (renamed from tests/ref/code/closure.png)bin520 -> 520 bytes
-rw-r--r--tests/ref/compiler/comment.png (renamed from tests/ref/code/comment.png)bin797 -> 797 bytes
-rw-r--r--tests/ref/compiler/construct.png (renamed from tests/ref/style/construct.png)bin6024 -> 6024 bytes
-rw-r--r--tests/ref/compiler/dict.png (renamed from tests/ref/code/dict.png)bin4584 -> 4584 bytes
-rw-r--r--tests/ref/compiler/for.png (renamed from tests/ref/code/for.png)bin3521 -> 3521 bytes
-rw-r--r--tests/ref/compiler/if.pngbin0 -> 2244 bytes
-rw-r--r--tests/ref/compiler/import.pngbin0 -> 4538 bytes
-rw-r--r--tests/ref/compiler/include.pngbin0 -> 47551 bytes
-rw-r--r--tests/ref/compiler/label.png (renamed from tests/ref/style/label.png)bin20873 -> 20873 bytes
-rw-r--r--tests/ref/compiler/let.pngbin0 -> 3073 bytes
-rw-r--r--tests/ref/compiler/methods-collection.png (renamed from tests/ref/base/collection.png)bin1384 -> 1384 bytes
-rw-r--r--tests/ref/compiler/methods-color.pngbin0 -> 506 bytes
-rw-r--r--tests/ref/compiler/ops.pngbin0 -> 972 bytes
-rw-r--r--tests/ref/compiler/repr.png (renamed from tests/ref/code/repr.png)bin29799 -> 29799 bytes
-rw-r--r--tests/ref/compiler/return.pngbin0 -> 2907 bytes
-rw-r--r--tests/ref/compiler/set.png (renamed from tests/ref/style/set.png)bin24744 -> 24744 bytes
-rw-r--r--tests/ref/compiler/shorthand.png (renamed from tests/ref/text/shorthands.png)bin4842 -> 4842 bytes
-rw-r--r--tests/ref/compiler/show-bare.png (renamed from tests/ref/style/show-bare.png)bin25853 -> 25853 bytes
-rw-r--r--tests/ref/compiler/show-node.png (renamed from tests/ref/style/show-node.png)bin23443 -> 23443 bytes
-rw-r--r--tests/ref/compiler/show-recursive.png (renamed from tests/ref/style/show-recursive.png)bin15653 -> 15653 bytes
-rw-r--r--tests/ref/compiler/show-selector.png (renamed from tests/ref/style/show-selector.png)bin12923 -> 12923 bytes
-rw-r--r--tests/ref/compiler/show-text.png (renamed from tests/ref/style/show-text.png)bin43571 -> 43571 bytes
-rw-r--r--tests/ref/compiler/while.pngbin0 -> 995 bytes
-rw-r--r--tests/ref/compute/create.pngbin0 -> 155 bytes
-rw-r--r--tests/ref/compute/data.pngbin0 -> 8602 bytes
-rw-r--r--tests/ref/compute/utility.pngbin0 -> 34441 bytes
-rw-r--r--tests/ref/empty.pngbin94 -> 92 bytes
-rw-r--r--tests/ref/graphics/hide.pngbin936 -> 0 bytes
-rw-r--r--tests/ref/graphics/shape-circle.pngbin40653 -> 0 bytes
-rw-r--r--tests/ref/graphics/shape-ellipse.pngbin24571 -> 0 bytes
-rw-r--r--tests/ref/graphics/shape-fill-stroke.pngbin6371 -> 0 bytes
-rw-r--r--tests/ref/graphics/shape-rect.pngbin16266 -> 0 bytes
-rw-r--r--tests/ref/graphics/shape-square.pngbin18777 -> 0 bytes
-rw-r--r--tests/ref/layout/columns.pngbin106624 -> 122708 bytes
-rw-r--r--tests/ref/layout/container.pngbin7628 -> 7512 bytes
-rw-r--r--tests/ref/layout/flow-orphan.pngbin0 -> 89335 bytes
-rw-r--r--tests/ref/layout/grid-1.pngbin8863 -> 8663 bytes
-rw-r--r--tests/ref/layout/grid-2.pngbin16566 -> 16352 bytes
-rw-r--r--tests/ref/layout/grid-4.pngbin430 -> 423 bytes
-rw-r--r--tests/ref/layout/grid-5.pngbin3814 -> 3699 bytes
-rw-r--r--tests/ref/layout/hide.pngbin0 -> 911 bytes
-rw-r--r--tests/ref/layout/locate-break.pngbin122 -> 0 bytes
-rw-r--r--tests/ref/layout/locate-group.pngbin42394 -> 0 bytes
-rw-r--r--tests/ref/layout/locate.pngbin2795 -> 0 bytes
-rw-r--r--tests/ref/layout/orphan-heading.pngbin8239 -> 0 bytes
-rw-r--r--tests/ref/layout/orphan-widow.pngbin71274 -> 0 bytes
-rw-r--r--tests/ref/layout/page-margin.pngbin2998 -> 2957 bytes
-rw-r--r--tests/ref/layout/page-style.pngbin1313 -> 1294 bytes
-rw-r--r--tests/ref/layout/page.pngbin7401 -> 7221 bytes
-rw-r--r--tests/ref/layout/par-bidi.png (renamed from tests/ref/text/bidi.png)bin26171 -> 26171 bytes
-rw-r--r--tests/ref/layout/par-indent.pngbin0 -> 46125 bytes
-rw-r--r--tests/ref/layout/par-justify.png (renamed from tests/ref/text/justify.png)bin30128 -> 30128 bytes
-rw-r--r--tests/ref/layout/par-knuth.pngbin0 -> 69406 bytes
-rw-r--r--tests/ref/layout/par-simple.pngbin0 -> 58353 bytes
-rw-r--r--tests/ref/layout/par.png (renamed from tests/ref/text/par.png)bin25788 -> 25788 bytes
-rw-r--r--tests/ref/layout/repeat.pngbin0 -> 9344 bytes
-rw-r--r--tests/ref/layout/stack-2.pngbin8673 -> 8430 bytes
-rw-r--r--tests/ref/layout/transform.png (renamed from tests/ref/graphics/transform.png)bin52123 -> 52123 bytes
-rw-r--r--tests/ref/math/simple.png (renamed from tests/ref/layout/math.png)bin6554 -> 6554 bytes
-rw-r--r--tests/ref/meta/document.pngbin0 -> 68 bytes
-rw-r--r--tests/ref/meta/link.pngbin0 -> 49384 bytes
-rw-r--r--tests/ref/structure/desc.pngbin16889 -> 0 bytes
-rw-r--r--tests/ref/structure/enum.pngbin27684 -> 0 bytes
-rw-r--r--tests/ref/style/closure.pngbin7567 -> 0 bytes
-rw-r--r--tests/ref/text/baseline.pngbin6204 -> 6168 bytes
-rw-r--r--tests/ref/text/chinese.pngbin22527 -> 21925 bytes
-rw-r--r--tests/ref/text/emph-strong.pngbin6988 -> 0 bytes
-rw-r--r--tests/ref/text/emphasis.pngbin0 -> 6900 bytes
-rw-r--r--tests/ref/text/features.pngbin10734 -> 10673 bytes
-rw-r--r--tests/ref/text/hyphenate.pngbin22150 -> 22158 bytes
-rw-r--r--tests/ref/text/indent.pngbin46139 -> 0 bytes
-rw-r--r--tests/ref/text/knuth.pngbin69313 -> 0 bytes
-rw-r--r--tests/ref/text/link.pngbin49393 -> 0 bytes
-rw-r--r--tests/ref/text/microtype.pngbin10904 -> 10903 bytes
-rw-r--r--tests/ref/text/plain.pngbin58344 -> 0 bytes
-rw-r--r--tests/ref/text/quotes.pngbin65503 -> 65498 bytes
-rw-r--r--tests/ref/text/raw-highlight.png (renamed from tests/ref/text/code.png)bin40777 -> 40777 bytes
-rw-r--r--tests/ref/text/raw.pngbin18137 -> 18101 bytes
-rw-r--r--tests/ref/text/repeat.pngbin9342 -> 0 bytes
-rw-r--r--tests/ref/text/shift.png (renamed from tests/ref/text/shifts.png)bin7781 -> 7781 bytes
-rw-r--r--tests/ref/text/space.pngbin0 -> 5941 bytes
-rw-r--r--tests/ref/text/tracking-spacing.pngbin6479 -> 6467 bytes
-rw-r--r--tests/ref/text/whitespace.pngbin6273 -> 0 bytes
-rw-r--r--tests/ref/visualize/image.png (renamed from tests/ref/graphics/image.png)bin176635 -> 176635 bytes
-rw-r--r--tests/ref/visualize/line.png (renamed from tests/ref/graphics/line.png)bin1562 -> 1562 bytes
-rw-r--r--tests/ref/visualize/shape-aspect.png (renamed from tests/ref/graphics/shape-aspect.png)bin4501 -> 4501 bytes
-rw-r--r--tests/ref/visualize/shape-circle.pngbin0 -> 39277 bytes
-rw-r--r--tests/ref/visualize/shape-ellipse.pngbin0 -> 23989 bytes
-rw-r--r--tests/ref/visualize/shape-fill-stroke.pngbin0 -> 6192 bytes
-rw-r--r--tests/ref/visualize/shape-rect.pngbin0 -> 16269 bytes
-rw-r--r--tests/ref/visualize/shape-square.pngbin0 -> 18290 bytes
-rw-r--r--tests/src/benches.rs4
-rw-r--r--tests/src/tests.rs2
-rw-r--r--tests/typ/base/assert.typ23
-rw-r--r--tests/typ/base/numbering.typ13
-rw-r--r--tests/typ/base/type.typ7
-rw-r--r--tests/typ/basics/desc.typ (renamed from tests/typ/structure/desc.typ)0
-rw-r--r--tests/typ/basics/enum.typ (renamed from tests/typ/structure/enum.typ)0
-rw-r--r--tests/typ/basics/heading.typ (renamed from tests/typ/structure/heading.typ)0
-rw-r--r--tests/typ/basics/list-attach.typ (renamed from tests/typ/structure/attach.typ)0
-rw-r--r--tests/typ/basics/list.typ (renamed from tests/typ/structure/list.typ)0
-rw-r--r--tests/typ/basics/table.typ (renamed from tests/typ/structure/table.typ)0
-rw-r--r--tests/typ/compiler/array.typ (renamed from tests/typ/code/array.typ)0
-rw-r--r--tests/typ/compiler/bench.typ (renamed from tests/typ/benches/bench.typ)0
-rw-r--r--tests/typ/compiler/block.typ (renamed from tests/typ/code/block.typ)2
-rw-r--r--tests/typ/compiler/break-continue.typ (renamed from tests/typ/code/break-continue.typ)0
-rw-r--r--tests/typ/compiler/call.typ (renamed from tests/typ/code/call.typ)0
-rw-r--r--tests/typ/compiler/closure.typ (renamed from tests/typ/code/closure.typ)2
-rw-r--r--tests/typ/compiler/comment.typ (renamed from tests/typ/code/comment.typ)0
-rw-r--r--tests/typ/compiler/construct.typ (renamed from tests/typ/style/construct.typ)0
-rw-r--r--tests/typ/compiler/dict.typ (renamed from tests/typ/code/dict.typ)0
-rw-r--r--tests/typ/compiler/field.typ (renamed from tests/typ/code/field.typ)0
-rw-r--r--tests/typ/compiler/for.typ (renamed from tests/typ/code/for.typ)0
-rw-r--r--tests/typ/compiler/if.typ (renamed from tests/typ/code/if.typ)0
-rw-r--r--tests/typ/compiler/import.typ (renamed from tests/typ/code/import.typ)36
-rw-r--r--tests/typ/compiler/include.typ (renamed from tests/typ/code/include.typ)10
-rw-r--r--tests/typ/compiler/label.typ (renamed from tests/typ/style/label.typ)0
-rw-r--r--tests/typ/compiler/let.typ (renamed from tests/typ/code/let.typ)0
-rw-r--r--tests/typ/compiler/methods-collection.typ (renamed from tests/typ/base/collection.typ)2
-rw-r--r--tests/typ/compiler/methods-color.typ22
-rw-r--r--tests/typ/compiler/methods-str.typ (renamed from tests/typ/base/string.typ)25
-rw-r--r--tests/typ/compiler/methods.typ (renamed from tests/typ/code/methods.typ)4
-rw-r--r--tests/typ/compiler/module.typ (renamed from tests/typ/code/target.typ)0
-rw-r--r--tests/typ/compiler/modules/chap1.typ (renamed from tests/typ/code/importable/chap1.typ)0
-rw-r--r--tests/typ/compiler/modules/chap2.typ (renamed from tests/typ/code/importable/chap2.typ)0
-rw-r--r--tests/typ/compiler/modules/cycle1.typ (renamed from tests/typ/code/importable/cycle1.typ)0
-rw-r--r--tests/typ/compiler/modules/cycle2.typ (renamed from tests/typ/code/importable/cycle2.typ)0
-rw-r--r--tests/typ/compiler/ops-assoc.typ (renamed from tests/typ/code/ops-assoc.typ)0
-rw-r--r--tests/typ/compiler/ops-invalid.typ (renamed from tests/typ/code/ops-invalid.typ)0
-rw-r--r--tests/typ/compiler/ops-prec.typ (renamed from tests/typ/code/ops-prec.typ)0
-rw-r--r--tests/typ/compiler/ops.typ (renamed from tests/typ/code/ops.typ)4
-rw-r--r--tests/typ/compiler/repr.typ (renamed from tests/typ/code/repr.typ)0
-rw-r--r--tests/typ/compiler/return.typ (renamed from tests/typ/code/return.typ)0
-rw-r--r--tests/typ/compiler/set.typ (renamed from tests/typ/style/set.typ)0
-rw-r--r--tests/typ/compiler/shorthand.typ (renamed from tests/typ/text/shorthands.typ)0
-rw-r--r--tests/typ/compiler/show-bare.typ (renamed from tests/typ/style/show-bare.typ)0
-rw-r--r--tests/typ/compiler/show-node.typ (renamed from tests/typ/style/show-node.typ)0
-rw-r--r--tests/typ/compiler/show-recursive.typ (renamed from tests/typ/style/show-recursive.typ)0
-rw-r--r--tests/typ/compiler/show-selector.typ (renamed from tests/typ/style/show-selector.typ)0
-rw-r--r--tests/typ/compiler/show-text.typ (renamed from tests/typ/style/show-text.typ)0
-rw-r--r--tests/typ/compiler/spread.typ (renamed from tests/typ/code/spread.typ)0
-rw-r--r--tests/typ/compiler/while.typ (renamed from tests/typ/code/while.typ)0
-rw-r--r--tests/typ/compute/calc.typ (renamed from tests/typ/base/calc.typ)0
-rw-r--r--tests/typ/compute/create.typ (renamed from tests/typ/base/color.typ)36
-rw-r--r--tests/typ/compute/data.typ (renamed from tests/typ/base/data.typ)2
-rw-r--r--tests/typ/compute/foundations.typ (renamed from tests/typ/base/eval.typ)28
-rw-r--r--tests/typ/compute/utility.typ (renamed from tests/typ/base/blind.typ)14
-rw-r--r--tests/typ/layout/flow-orphan.typ (renamed from tests/typ/layout/orphan-widow.typ)9
-rw-r--r--tests/typ/layout/hide.typ (renamed from tests/typ/graphics/hide.typ)0
-rw-r--r--tests/typ/layout/orphan-heading.typ8
-rw-r--r--tests/typ/layout/par-bidi.typ (renamed from tests/typ/text/bidi.typ)0
-rw-r--r--tests/typ/layout/par-indent.typ (renamed from tests/typ/text/indent.typ)0
-rw-r--r--tests/typ/layout/par-justify.typ (renamed from tests/typ/text/justify.typ)0
-rw-r--r--tests/typ/layout/par-knuth.typ (renamed from tests/typ/text/knuth.typ)0
-rw-r--r--tests/typ/layout/par-simple.typ (renamed from tests/typ/text/plain.typ)0
-rw-r--r--tests/typ/layout/par.typ (renamed from tests/typ/text/par.typ)0
-rw-r--r--tests/typ/layout/repeat.typ (renamed from tests/typ/text/repeat.typ)0
-rw-r--r--tests/typ/layout/transform.typ (renamed from tests/typ/graphics/transform.typ)0
-rw-r--r--tests/typ/math/simple.typ (renamed from tests/typ/layout/math.typ)0
-rw-r--r--tests/typ/meta/document.typ (renamed from tests/typ/style/document.typ)0
-rw-r--r--tests/typ/meta/link.typ (renamed from tests/typ/text/link.typ)0
-rw-r--r--tests/typ/text/case.typ12
-rw-r--r--tests/typ/text/emphasis.typ (renamed from tests/typ/text/emph-strong.typ)0
-rw-r--r--tests/typ/text/raw-highlight.typ (renamed from tests/typ/text/code.typ)0
-rw-r--r--tests/typ/text/shift.typ (renamed from tests/typ/text/shifts.typ)0
-rw-r--r--tests/typ/text/space.typ (renamed from tests/typ/text/whitespace.typ)0
-rw-r--r--tests/typ/visualize/image.typ (renamed from tests/typ/graphics/image.typ)2
-rw-r--r--tests/typ/visualize/line.typ (renamed from tests/typ/graphics/line.typ)0
-rw-r--r--tests/typ/visualize/shape-aspect.typ (renamed from tests/typ/graphics/shape-aspect.typ)0
-rw-r--r--tests/typ/visualize/shape-circle.typ (renamed from tests/typ/graphics/shape-circle.typ)0
-rw-r--r--tests/typ/visualize/shape-ellipse.typ (renamed from tests/typ/graphics/shape-ellipse.typ)0
-rw-r--r--tests/typ/visualize/shape-fill-stroke.typ (renamed from tests/typ/graphics/shape-fill-stroke.typ)0
-rw-r--r--tests/typ/visualize/shape-rect.typ (renamed from tests/typ/graphics/shape-rect.typ)0
-rw-r--r--tests/typ/visualize/shape-square.typ (renamed from tests/typ/graphics/shape-square.typ)0
234 files changed, 500 insertions, 481 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index cdbd5926..7b961183 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -395,7 +395,7 @@ impl SystemWorld {
Self {
root,
- library: Prehashed::new(typst_library::new()),
+ library: Prehashed::new(typst_library::build()),
book: Prehashed::new(searcher.book),
fonts: searcher.fonts,
hashes: RefCell::default(),
diff --git a/library/src/structure/heading.rs b/library/src/basics/heading.rs
index b251f27b..b251f27b 100644
--- a/library/src/structure/heading.rs
+++ b/library/src/basics/heading.rs
diff --git a/library/src/structure/list.rs b/library/src/basics/list.rs
index b51284a8..c73ffea6 100644
--- a/library/src/structure/list.rs
+++ b/library/src/basics/list.rs
@@ -1,7 +1,7 @@
-use crate::base::NumberingPattern;
-use crate::layout::{BlockNode, GridNode, HNode, Spacing, TrackSizing};
+use crate::compute::NumberingPattern;
+use crate::layout::{BlockNode, GridNode, HNode, ParNode, Spacing, TrackSizing};
use crate::prelude::*;
-use crate::text::{ParNode, SpaceNode, TextNode};
+use crate::text::{SpaceNode, TextNode};
/// An unordered (bulleted) or ordered (numbered) list.
#[derive(Debug, Hash)]
diff --git a/library/src/basics/mod.rs b/library/src/basics/mod.rs
new file mode 100644
index 00000000..5916df6b
--- /dev/null
+++ b/library/src/basics/mod.rs
@@ -0,0 +1,9 @@
+//! Common document elements.
+
+mod heading;
+mod list;
+mod table;
+
+pub use self::heading::*;
+pub use self::list::*;
+pub use self::table::*;
diff --git a/library/src/structure/table.rs b/library/src/basics/table.rs
index bb900f3d..bb900f3d 100644
--- a/library/src/structure/table.rs
+++ b/library/src/basics/table.rs
diff --git a/library/src/base/calc.rs b/library/src/compute/calc.rs
index 3541e08c..3541e08c 100644
--- a/library/src/base/calc.rs
+++ b/library/src/compute/calc.rs
diff --git a/library/src/base/create.rs b/library/src/compute/create.rs
index be8e822f..4fd27499 100644
--- a/library/src/base/create.rs
+++ b/library/src/compute/create.rs
@@ -106,12 +106,6 @@ pub fn str(_: &Vm, args: &mut Args) -> SourceResult<Value> {
}))
}
-/// Create a blind text string.
-pub fn lorem(_: &Vm, args: &mut Args) -> SourceResult<Value> {
- let words: usize = args.expect("number of words")?;
- Ok(Value::Str(lipsum::lipsum(words).into()))
-}
-
/// Create a label from a string.
pub fn label(_: &Vm, args: &mut Args) -> SourceResult<Value> {
Ok(Value::Label(Label(args.expect("string")?)))
diff --git a/library/src/base/data.rs b/library/src/compute/data.rs
index 4f6e3b67..4f6e3b67 100644
--- a/library/src/base/data.rs
+++ b/library/src/compute/data.rs
diff --git a/library/src/base/mod.rs b/library/src/compute/foundations.rs
index 501edd71..3e410185 100644
--- a/library/src/base/mod.rs
+++ b/library/src/compute/foundations.rs
@@ -1,20 +1,9 @@
-//! Foundational functions.
-
-mod calc;
-mod create;
-mod data;
-mod numbering;
-
-pub use self::calc::*;
-pub use self::create::*;
-pub use self::data::*;
-pub use self::numbering::*;
+use crate::prelude::*;
use comemo::Track;
-use typst::model::{self, Route, Vm};
-use typst::syntax::Source;
-use crate::prelude::*;
+use typst::model;
+use typst::syntax::Source;
/// The name of a value's type.
pub fn type_(_: &Vm, args: &mut Args) -> SourceResult<Value> {
@@ -39,7 +28,7 @@ pub fn assert(_: &Vm, args: &mut Args) -> SourceResult<Value> {
pub fn eval(vm: &Vm, args: &mut Args) -> SourceResult<Value> {
let Spanned { v: text, span } = args.expect::<Spanned<String>>("source")?;
let source = Source::synthesized(text, span);
- let route = Route::default();
+ let route = model::Route::default();
let module = model::eval(vm.world(), route.track(), &source)?;
Ok(Value::Content(module.content))
}
diff --git a/library/src/compute/mod.rs b/library/src/compute/mod.rs
new file mode 100644
index 00000000..70690d44
--- /dev/null
+++ b/library/src/compute/mod.rs
@@ -0,0 +1,13 @@
+//! Computational functions.
+
+mod calc;
+mod create;
+mod data;
+mod foundations;
+mod utility;
+
+pub use self::calc::*;
+pub use self::create::*;
+pub use self::data::*;
+pub use self::foundations::*;
+pub use self::utility::*;
diff --git a/library/src/base/numbering.rs b/library/src/compute/utility.rs
index ea45fbc6..2b04dfd6 100644
--- a/library/src/base/numbering.rs
+++ b/library/src/compute/utility.rs
@@ -4,6 +4,12 @@ use unscanny::Scanner;
use crate::prelude::*;
+/// Create a blind text string.
+pub fn lorem(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+ let words: usize = args.expect("number of words")?;
+ Ok(Value::Str(lipsum::lipsum(words).into()))
+}
+
/// Apply a numbering pattern to a number.
pub fn numbering(_: &Vm, args: &mut Args) -> SourceResult<Value> {
let number = args.expect::<usize>("number")?;
@@ -11,7 +17,15 @@ pub fn numbering(_: &Vm, args: &mut Args) -> SourceResult<Value> {
Ok(Value::Str(pattern.apply(number).into()))
}
-/// A numbering pattern for lists or headings.
+/// How to turn a number into text.
+///
+/// A pattern consists of a prefix, followed by one of `1`, `a`, `A`, `i`, `I`
+/// or `*`, and then a suffix.
+///
+/// Examples of valid patterns:
+/// - `1)`
+/// - `a.`
+/// - `(I)`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct NumberingPattern {
prefix: EcoString,
@@ -60,7 +74,7 @@ castable! {
/// Different kinds of numberings.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
-pub enum NumberingKind {
+enum NumberingKind {
Arabic,
Letter,
Roman,
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs
index d8b6d92e..a06f7edb 100644
--- a/library/src/layout/align.rs
+++ b/library/src/layout/align.rs
@@ -1,5 +1,5 @@
+use super::{HorizontalAlign, ParNode};
use crate::prelude::*;
-use crate::text::{HorizontalAlign, ParNode};
/// Align content along the layouting axes.
#[derive(Debug, Hash)]
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index 07c3e012..b644d73f 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -1,8 +1,7 @@
use typst::model::Style;
-use super::{AlignNode, BlockNode, ColbreakNode, PlaceNode, Spacing, VNode};
+use super::{AlignNode, BlockNode, ColbreakNode, ParNode, PlaceNode, Spacing, VNode};
use crate::prelude::*;
-use crate::text::ParNode;
/// Arrange spacing, paragraphs and block-level nodes into a flow.
///
diff --git a/library/src/graphics/hide.rs b/library/src/layout/hide.rs
index 64cbee64..64cbee64 100644
--- a/library/src/graphics/hide.rs
+++ b/library/src/layout/hide.rs
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs
index 7edc88ad..8f9337ba 100644
--- a/library/src/layout/mod.rs
+++ b/library/src/layout/mod.rs
@@ -5,9 +5,12 @@ mod columns;
mod container;
mod flow;
mod grid;
+mod hide;
mod pad;
mod page;
+mod par;
mod place;
+mod repeat;
mod spacing;
mod stack;
mod transform;
@@ -17,9 +20,12 @@ pub use self::columns::*;
pub use self::container::*;
pub use self::flow::*;
pub use self::grid::*;
+pub use self::hide::*;
pub use self::pad::*;
pub use self::page::*;
+pub use self::par::*;
pub use self::place::*;
+pub use self::repeat::*;
pub use self::spacing::*;
pub use self::stack::*;
pub use self::transform::*;
@@ -36,14 +42,11 @@ use typst::model::{
};
use typst::World;
+use crate::basics::{DescNode, EnumNode, ListItem, ListNode, DESC, ENUM, LIST};
+use crate::meta::DocumentNode;
use crate::prelude::*;
use crate::shared::BehavedBuilder;
-use crate::structure::{
- DescNode, DocumentNode, EnumNode, ListItem, ListNode, DESC, ENUM, LIST,
-};
-use crate::text::{
- LinebreakNode, ParNode, ParbreakNode, SmartQuoteNode, SpaceNode, TextNode,
-};
+use crate::text::{LinebreakNode, SmartQuoteNode, SpaceNode, TextNode};
/// Root-level layout.
#[capability]
diff --git a/library/src/text/par.rs b/library/src/layout/par.rs
index 3c722d84..82bea1b5 100644
--- a/library/src/text/par.rs
+++ b/library/src/layout/par.rs
@@ -4,12 +4,11 @@ use xi_unicode::LineBreakIterator;
use typst::model::Key;
-use super::{
- shape, Lang, LinebreakNode, Quoter, Quotes, ShapedText, SmartQuoteNode, SpaceNode,
- TextNode,
-};
-use crate::layout::{HNode, Spacing};
+use super::{HNode, RepeatNode, Spacing};
use crate::prelude::*;
+use crate::text::{
+ shape, LinebreakNode, Quoter, Quotes, ShapedText, SmartQuoteNode, SpaceNode, TextNode,
+};
/// Arrange text, spacing and inline-level nodes into a paragraph.
#[derive(Hash)]
@@ -129,30 +128,6 @@ impl ParbreakNode {
impl Unlabellable for ParbreakNode {}
-/// Repeats content to fill a line.
-#[derive(Debug, Hash)]
-pub struct RepeatNode(pub Content);
-
-#[node(Layout, Inline)]
-impl RepeatNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- Ok(Self(args.expect("body")?).pack())
- }
-}
-
-impl Layout for RepeatNode {
- fn layout(
- &self,
- world: Tracked<dyn World>,
- styles: StyleChain,
- regions: &Regions,
- ) -> SourceResult<Fragment> {
- self.0.layout(world, styles, regions)
- }
-}
-
-impl Inline for RepeatNode {}
-
/// Range of a substring of text.
type Range = std::ops::Range<usize>;
diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs
new file mode 100644
index 00000000..d9323e1d
--- /dev/null
+++ b/library/src/layout/repeat.rs
@@ -0,0 +1,25 @@
+use crate::prelude::*;
+
+/// Repeats content to fill a line.
+#[derive(Debug, Hash)]
+pub struct RepeatNode(pub Content);
+
+#[node(Layout, Inline)]
+impl RepeatNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ Ok(Self(args.expect("body")?).pack())
+ }
+}
+
+impl Layout for RepeatNode {
+ fn layout(
+ &self,
+ world: Tracked<dyn World>,
+ styles: StyleChain,
+ regions: &Regions,
+ ) -> SourceResult<Fragment> {
+ self.0.layout(world, styles, regions)
+ }
+}
+
+impl Inline for RepeatNode {}
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index 7de1d34a..c1073b26 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -1,8 +1,7 @@
use typst::model::StyledNode;
-use super::{AlignNode, Spacing};
+use super::{AlignNode, ParNode, Spacing};
use crate::prelude::*;
-use crate::text::ParNode;
/// Arrange content and spacing along an axis.
#[derive(Debug, Hash)]
diff --git a/library/src/lib.rs b/library/src/lib.rs
index cf8cb490..e1540133 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -1,13 +1,14 @@
//! Typst's standard library.
-pub mod base;
-pub mod graphics;
+pub mod basics;
+pub mod compute;
pub mod layout;
pub mod math;
+pub mod meta;
pub mod prelude;
pub mod shared;
-pub mod structure;
pub mod text;
+pub mod visualize;
use typst::geom::{Align, Color, Dir, GenAlign};
use typst::model::{LangItems, Library, Node, NodeId, Scope, StyleMap};
@@ -15,7 +16,7 @@ use typst::model::{LangItems, Library, Node, NodeId, Scope, StyleMap};
use self::layout::LayoutRoot;
/// Construct the standard library.
-pub fn new() -> Library {
+pub fn build() -> Library {
Library { scope: scope(), styles: styles(), items: items() }
}
@@ -23,97 +24,102 @@ pub fn new() -> Library {
fn scope() -> Scope {
let mut std = Scope::new();
+ // Basics.
+ std.def_node::<basics::HeadingNode>("heading");
+ std.def_node::<basics::ListNode>("list");
+ std.def_node::<basics::EnumNode>("enum");
+ std.def_node::<basics::DescNode>("desc");
+ std.def_node::<basics::TableNode>("table");
+
// Text.
+ std.def_node::<text::TextNode>("text");
std.def_node::<text::LinebreakNode>("linebreak");
std.def_node::<text::SmartQuoteNode>("smartquote");
- std.def_node::<text::TextNode>("text");
- std.def_node::<text::ParNode>("par");
- std.def_node::<text::ParbreakNode>("parbreak");
std.def_node::<text::StrongNode>("strong");
std.def_node::<text::EmphNode>("emph");
- std.def_node::<text::RawNode>("raw");
- std.def_node::<text::UnderlineNode>("underline");
- std.def_node::<text::StrikethroughNode>("strike");
- std.def_node::<text::OverlineNode>("overline");
- std.def_node::<text::SuperNode>("super");
- std.def_node::<text::SubNode>("sub");
- std.def_node::<text::LinkNode>("link");
- std.def_node::<text::RepeatNode>("repeat");
std.def_fn("lower", text::lower);
std.def_fn("upper", text::upper);
std.def_fn("smallcaps", text::smallcaps);
+ std.def_node::<text::SubNode>("sub");
+ std.def_node::<text::SuperNode>("super");
+ std.def_node::<text::UnderlineNode>("underline");
+ std.def_node::<text::StrikeNode>("strike");
+ std.def_node::<text::OverlineNode>("overline");
+ std.def_node::<text::RawNode>("raw");
- // Structure.
- std.def_node::<structure::DocumentNode>("document");
- std.def_node::<structure::RefNode>("ref");
- std.def_node::<structure::HeadingNode>("heading");
- std.def_node::<structure::ListNode>("list");
- std.def_node::<structure::EnumNode>("enum");
- std.def_node::<structure::DescNode>("desc");
- std.def_node::<structure::TableNode>("table");
+ // Math.
+ std.def_node::<math::MathNode>("math");
+ std.def_node::<math::AtomNode>("atom");
+ std.def_node::<math::FracNode>("frac");
+ std.define("sum", "∑");
+ std.define("in", "∈");
+ std.define("arrow", "→");
+ std.define("NN", "ℕ");
+ std.define("RR", "ℝ");
// Layout.
std.def_node::<layout::PageNode>("page");
std.def_node::<layout::PagebreakNode>("pagebreak");
- std.def_node::<layout::HNode>("h");
+ std.def_node::<layout::FlowNode>("flow");
std.def_node::<layout::VNode>("v");
+ std.def_node::<layout::ParNode>("par");
+ std.def_node::<layout::ParbreakNode>("parbreak");
+ std.def_node::<layout::HNode>("h");
std.def_node::<layout::BoxNode>("box");
std.def_node::<layout::BlockNode>("block");
- std.def_node::<layout::AlignNode>("align");
- std.def_node::<layout::PadNode>("pad");
std.def_node::<layout::StackNode>("stack");
std.def_node::<layout::GridNode>("grid");
std.def_node::<layout::ColumnsNode>("columns");
std.def_node::<layout::ColbreakNode>("colbreak");
std.def_node::<layout::PlaceNode>("place");
+ std.def_node::<layout::AlignNode>("align");
+ std.def_node::<layout::PadNode>("pad");
+ std.def_node::<layout::RepeatNode>("repeat");
std.def_node::<layout::MoveNode>("move");
std.def_node::<layout::ScaleNode>("scale");
std.def_node::<layout::RotateNode>("rotate");
-
- // Graphics.
- std.def_node::<graphics::ImageNode>("image");
- std.def_node::<graphics::LineNode>("line");
- std.def_node::<graphics::RectNode>("rect");
- std.def_node::<graphics::SquareNode>("square");
- std.def_node::<graphics::EllipseNode>("ellipse");
- std.def_node::<graphics::CircleNode>("circle");
- std.def_node::<graphics::HideNode>("hide");
-
- // Math.
- std.def_node::<math::MathNode>("math");
- std.define("sum", "∑");
- std.define("in", "∈");
- std.define("arrow", "→");
- std.define("NN", "ℕ");
- std.define("RR", "ℝ");
-
- // Base.
- std.def_fn("type", base::type_);
- std.def_fn("repr", base::repr);
- std.def_fn("assert", base::assert);
- std.def_fn("eval", base::eval);
- std.def_fn("int", base::int);
- std.def_fn("float", base::float);
- std.def_fn("luma", base::luma);
- std.def_fn("rgb", base::rgb);
- std.def_fn("cmyk", base::cmyk);
- std.def_fn("str", base::str);
- std.def_fn("lorem", base::lorem);
- std.def_fn("label", base::label);
- std.def_fn("regex", base::regex);
- std.def_fn("range", base::range);
- std.def_fn("numbering", base::numbering);
- std.def_fn("abs", base::abs);
- std.def_fn("min", base::min);
- std.def_fn("max", base::max);
- std.def_fn("even", base::even);
- std.def_fn("odd", base::odd);
- std.def_fn("mod", base::mod_);
- std.def_fn("csv", base::csv);
- std.def_fn("json", base::json);
- std.def_fn("xml", base::xml);
-
- // Predefined colors.
+ std.def_node::<layout::HideNode>("hide");
+
+ // Visualize.
+ std.def_node::<visualize::ImageNode>("image");
+ std.def_node::<visualize::LineNode>("line");
+ std.def_node::<visualize::RectNode>("rect");
+ std.def_node::<visualize::SquareNode>("square");
+ std.def_node::<visualize::EllipseNode>("ellipse");
+ std.def_node::<visualize::CircleNode>("circle");
+
+ // Meta.
+ std.def_node::<meta::DocumentNode>("document");
+ std.def_node::<meta::RefNode>("ref");
+ std.def_node::<meta::LinkNode>("link");
+
+ // Compute.
+ std.def_fn("type", compute::type_);
+ std.def_fn("repr", compute::repr);
+ std.def_fn("assert", compute::assert);
+ std.def_fn("eval", compute::eval);
+ std.def_fn("int", compute::int);
+ std.def_fn("float", compute::float);
+ std.def_fn("luma", compute::luma);
+ std.def_fn("rgb", compute::rgb);
+ std.def_fn("cmyk", compute::cmyk);
+ std.def_fn("str", compute::str);
+ std.def_fn("label", compute::label);
+ std.def_fn("regex", compute::regex);
+ std.def_fn("range", compute::range);
+ std.def_fn("abs", compute::abs);
+ std.def_fn("min", compute::min);
+ std.def_fn("max", compute::max);
+ std.def_fn("even", compute::even);
+ std.def_fn("odd", compute::odd);
+ std.def_fn("mod", compute::mod_);
+ std.def_fn("csv", compute::csv);
+ std.def_fn("json", compute::json);
+ std.def_fn("xml", compute::xml);
+ std.def_fn("lorem", compute::lorem);
+ std.def_fn("numbering", compute::numbering);
+
+ // Colors.
std.define("black", Color::BLACK);
std.define("gray", Color::GRAY);
std.define("silver", Color::SILVER);
@@ -167,7 +173,7 @@ fn items() -> LangItems {
text_id: NodeId::of::<text::TextNode>(),
text_str: |content| Some(&content.to::<text::TextNode>()?.0),
smart_quote: |double| text::SmartQuoteNode { double }.pack(),
- parbreak: || text::ParbreakNode.pack(),
+ parbreak: || layout::ParbreakNode.pack(),
strong: |body| text::StrongNode(body).pack(),
emph: |body| text::EmphNode(body).pack(),
raw: |text, lang, block| {
@@ -177,15 +183,13 @@ fn items() -> LangItems {
None => content,
}
},
- link: |url| text::LinkNode::from_url(url).pack(),
- ref_: |target| structure::RefNode(target).pack(),
- heading: |level, body| structure::HeadingNode { level, body }.pack(),
- list_item: |body| structure::ListItem::List(Box::new(body)).pack(),
- enum_item: |number, body| {
- structure::ListItem::Enum(number, Box::new(body)).pack()
- },
+ link: |url| meta::LinkNode::from_url(url).pack(),
+ ref_: |target| meta::RefNode(target).pack(),
+ heading: |level, body| basics::HeadingNode { level, body }.pack(),
+ list_item: |body| basics::ListItem::List(Box::new(body)).pack(),
+ enum_item: |number, body| basics::ListItem::Enum(number, Box::new(body)).pack(),
desc_item: |term, body| {
- structure::ListItem::Desc(Box::new(structure::DescItem { term, body })).pack()
+ basics::ListItem::Desc(Box::new(basics::DescItem { term, body })).pack()
},
math: |children, display| math::MathNode { children, display }.pack(),
math_atom: |atom| math::AtomNode(atom).pack(),
diff --git a/library/src/structure/document.rs b/library/src/meta/document.rs
index e52c92ad..309e1bda 100644
--- a/library/src/structure/document.rs
+++ b/library/src/meta/document.rs
@@ -1,7 +1,7 @@
use crate::layout::{LayoutRoot, PageNode};
use crate::prelude::*;
-/// The root node of the model.
+/// The root node that represents a full document.
#[derive(Hash)]
pub struct DocumentNode(pub StyleVec<PageNode>);
diff --git a/library/src/text/link.rs b/library/src/meta/link.rs
index 1b87def2..44da9c5d 100644
--- a/library/src/text/link.rs
+++ b/library/src/meta/link.rs
@@ -1,5 +1,5 @@
-use super::TextNode;
use crate::prelude::*;
+use crate::text::TextNode;
/// Link text and other elements to a destination.
#[derive(Debug, Hash)]
diff --git a/library/src/meta/mod.rs b/library/src/meta/mod.rs
new file mode 100644
index 00000000..31a69ccc
--- /dev/null
+++ b/library/src/meta/mod.rs
@@ -0,0 +1,9 @@
+//! Interaction between document parts.
+
+mod document;
+mod link;
+mod reference;
+
+pub use self::document::*;
+pub use self::link::*;
+pub use self::reference::*;
diff --git a/library/src/structure/reference.rs b/library/src/meta/reference.rs
index 948aa6f6..948aa6f6 100644
--- a/library/src/structure/reference.rs
+++ b/library/src/meta/reference.rs
diff --git a/library/src/structure/mod.rs b/library/src/structure/mod.rs
deleted file mode 100644
index a1c27eed..00000000
--- a/library/src/structure/mod.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-//! Document structuring.
-
-mod document;
-mod heading;
-mod list;
-mod reference;
-mod table;
-
-pub use self::document::*;
-pub use self::heading::*;
-pub use self::list::*;
-pub use self::reference::*;
-pub use self::table::*;
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs
index 33c13e90..e81b219c 100644
--- a/library/src/text/deco.rs
+++ b/library/src/text/deco.rs
@@ -12,7 +12,7 @@ pub struct DecoNode<const L: DecoLine>(pub Content);
pub type UnderlineNode = DecoNode<UNDERLINE>;
/// Typeset stricken-through text.
-pub type StrikethroughNode = DecoNode<STRIKETHROUGH>;
+pub type StrikeNode = DecoNode<STRIKETHROUGH>;
/// Typeset overlined text.
pub type OverlineNode = DecoNode<OVERLINE>;
@@ -65,7 +65,7 @@ impl<const L: DecoLine> Show for DecoNode<L> {
///
/// For more details, see [`DecoNode`].
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
-pub(super) struct Decoration {
+pub struct Decoration {
pub line: DecoLine,
pub stroke: PartialStroke<Abs>,
pub offset: Smart<Abs>,
diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs
new file mode 100644
index 00000000..15ef9a63
--- /dev/null
+++ b/library/src/text/misc.rs
@@ -0,0 +1,146 @@
+use super::TextNode;
+use crate::prelude::*;
+
+/// A text space.
+#[derive(Debug, Hash)]
+pub struct SpaceNode;
+
+#[node(Unlabellable, Behave)]
+impl SpaceNode {
+ fn construct(_: &Vm, _: &mut Args) -> SourceResult<Content> {
+ Ok(Self.pack())
+ }
+}
+
+impl Unlabellable for SpaceNode {}
+
+impl Behave for SpaceNode {
+ fn behaviour(&self) -> Behaviour {
+ Behaviour::Weak(2)
+ }
+}
+
+/// A line break.
+#[derive(Debug, Hash)]
+pub struct LinebreakNode {
+ pub justify: bool,
+}
+
+#[node(Behave)]
+impl LinebreakNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ let justify = args.named("justify")?.unwrap_or(false);
+ Ok(Self { justify }.pack())
+ }
+}
+
+impl Behave for LinebreakNode {
+ fn behaviour(&self) -> Behaviour {
+ Behaviour::Destructive
+ }
+}
+
+/// Strong content, rendered in boldface by default.
+#[derive(Debug, Hash)]
+pub struct StrongNode(pub Content);
+
+#[node(Show)]
+impl StrongNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ Ok(Self(args.expect("body")?).pack())
+ }
+
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
+ }
+}
+
+impl Show for StrongNode {
+ fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> Content {
+ self.0.clone().styled(TextNode::BOLD, Toggle)
+ }
+}
+
+/// Emphasized content, rendered with an italic font by default.
+#[derive(Debug, Hash)]
+pub struct EmphNode(pub Content);
+
+#[node(Show)]
+impl EmphNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ Ok(Self(args.expect("body")?).pack())
+ }
+
+ fn field(&self, name: &str) -> Option<Value> {
+ match name {
+ "body" => Some(Value::Content(self.0.clone())),
+ _ => None,
+ }
+ }
+}
+
+impl Show for EmphNode {
+ fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> Content {
+ self.0.clone().styled(TextNode::ITALIC, Toggle)
+ }
+}
+
+/// A toggle that turns on and off alternatingly if folded.
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
+pub struct Toggle;
+
+impl Fold for Toggle {
+ type Output = bool;
+
+ fn fold(self, outer: Self::Output) -> Self::Output {
+ !outer
+ }
+}
+
+/// Convert a string or content to lowercase.
+pub fn lower(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+ case(Case::Lower, args)
+}
+
+/// Convert a string or content to uppercase.
+pub fn upper(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+ case(Case::Upper, args)
+}
+
+/// Change the case of text.
+fn case(case: Case, args: &mut Args) -> SourceResult<Value> {
+ let Spanned { v, span } = args.expect("string or content")?;
+ Ok(match v {
+ Value::Str(v) => Value::Str(case.apply(&v).into()),
+ Value::Content(v) => Value::Content(v.styled(TextNode::CASE, Some(case))),
+ v => bail!(span, "expected string or content, found {}", v.type_name()),
+ })
+}
+
+/// A case transformation on text.
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
+pub enum Case {
+ /// Everything is lowercased.
+ Lower,
+ /// Everything is uppercased.
+ Upper,
+}
+
+impl Case {
+ /// Apply the case to a string.
+ pub fn apply(self, text: &str) -> String {
+ match self {
+ Self::Lower => text.to_lowercase(),
+ Self::Upper => text.to_uppercase(),
+ }
+ }
+}
+
+/// Display text in small capitals.
+pub fn smallcaps(_: &Vm, args: &mut Args) -> SourceResult<Value> {
+ let body: Content = args.expect("content")?;
+ Ok(Value::Content(body.styled(TextNode::SMALLCAPS, true)))
+}
diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs
index 3fd30e9e..c9298fee 100644
--- a/library/src/text/mod.rs
+++ b/library/src/text/mod.rs
@@ -1,16 +1,15 @@
-//! Text handling and paragraph layout.
+//! Text handling.
mod deco;
-mod link;
-mod par;
+mod misc;
mod quotes;
mod raw;
mod shaping;
mod shift;
pub use self::deco::*;
-pub use self::link::*;
-pub use self::par::*;
+pub use self::misc::*;
+pub use self::quotes::*;
pub use self::raw::*;
pub use self::shaping::*;
pub use self::shift::*;
@@ -21,7 +20,7 @@ use rustybuzz::Tag;
use typst::font::{FontMetrics, FontStretch, FontStyle, FontWeight, VerticalFontMetric};
use typst::util::EcoString;
-use self::quotes::*;
+use crate::layout::ParNode;
use crate::prelude::*;
/// A single run of text with the same style.
@@ -114,19 +113,19 @@ impl TextNode {
/// Whether the font weight should be increased by 300.
#[property(skip, fold)]
- const BOLD: Toggle = false;
+ pub const BOLD: Toggle = false;
/// Whether the font style should be inverted.
#[property(skip, fold)]
- const ITALIC: Toggle = false;
+ pub const ITALIC: Toggle = false;
/// A case transformation that should be applied to the text.
#[property(skip)]
- const CASE: Option<Case> = None;
+ pub const CASE: Option<Case> = None;
/// Whether small capital glyphs should be used. ("smcp")
#[property(skip)]
- const SMALLCAPS: bool = false;
+ pub const SMALLCAPS: bool = false;
/// Decorative lines.
#[property(skip, fold)]
- const DECO: Decoration = vec![];
+ pub const DECO: Decoration = vec![];
fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
// The text constructor is special: It doesn't create a text node.
@@ -409,161 +408,3 @@ impl Fold for FontFeatures {
self
}
}
-
-/// A text space.
-#[derive(Debug, Hash)]
-pub struct SpaceNode;
-
-#[node(Unlabellable, Behave)]
-impl SpaceNode {
- fn construct(_: &Vm, _: &mut Args) -> SourceResult<Content> {
- Ok(Self.pack())
- }
-}
-
-impl Unlabellable for SpaceNode {}
-
-impl Behave for SpaceNode {
- fn behaviour(&self) -> Behaviour {
- Behaviour::Weak(2)
- }
-}
-
-/// A line break.
-#[derive(Debug, Hash)]
-pub struct LinebreakNode {
- pub justify: bool,
-}
-
-#[node(Behave)]
-impl LinebreakNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- let justify = args.named("justify")?.unwrap_or(false);
- Ok(Self { justify }.pack())
- }
-}
-
-impl Behave for LinebreakNode {
- fn behaviour(&self) -> Behaviour {
- Behaviour::Destructive
- }
-}
-
-/// A smart quote.
-#[derive(Debug, Hash)]
-pub struct SmartQuoteNode {
- pub double: bool,
-}
-
-#[node]
-impl SmartQuoteNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- let double = args.named("double")?.unwrap_or(true);
- Ok(Self { double }.pack())
- }
-}
-
-/// Convert a string or content to lowercase.
-pub fn lower(_: &Vm, args: &mut Args) -> SourceResult<Value> {
- case(Case::Lower, args)
-}
-
-/// Convert a string or content to uppercase.
-pub fn upper(_: &Vm, args: &mut Args) -> SourceResult<Value> {
- case(Case::Upper, args)
-}
-
-/// Change the case of text.
-fn case(case: Case, args: &mut Args) -> SourceResult<Value> {
- let Spanned { v, span } = args.expect("string or content")?;
- Ok(match v {
- Value::Str(v) => Value::Str(case.apply(&v).into()),
- Value::Content(v) => Value::Content(v.styled(TextNode::CASE, Some(case))),
- v => bail!(span, "expected string or content, found {}", v.type_name()),
- })
-}
-
-/// A case transformation on text.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
-pub enum Case {
- /// Everything is uppercased.
- Upper,
- /// Everything is lowercased.
- Lower,
-}
-
-impl Case {
- /// Apply the case to a string.
- pub fn apply(self, text: &str) -> String {
- match self {
- Self::Upper => text.to_uppercase(),
- Self::Lower => text.to_lowercase(),
- }
- }
-}
-
-/// Display text in small capitals.
-pub fn smallcaps(_: &Vm, args: &mut Args) -> SourceResult<Value> {
- let body: Content = args.expect("content")?;
- Ok(Value::Content(body.styled(TextNode::SMALLCAPS, true)))
-}
-
-/// Strong content, rendered in boldface by default.
-#[derive(Debug, Hash)]
-pub struct StrongNode(pub Content);
-
-#[node(Show)]
-impl StrongNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- Ok(Self(args.expect("body")?).pack())
- }
-
- fn field(&self, name: &str) -> Option<Value> {
- match name {
- "body" => Some(Value::Content(self.0.clone())),
- _ => None,
- }
- }
-}
-
-impl Show for StrongNode {
- fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> Content {
- self.0.clone().styled(TextNode::BOLD, Toggle)
- }
-}
-
-/// Emphasized content, rendered with an italic font by default.
-#[derive(Debug, Hash)]
-pub struct EmphNode(pub Content);
-
-#[node(Show)]
-impl EmphNode {
- fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
- Ok(Self(args.expect("body")?).pack())
- }
-
- fn field(&self, name: &str) -> Option<Value> {
- match name {
- "body" => Some(Value::Content(self.0.clone())),
- _ => None,
- }
- }
-}
-
-impl Show for EmphNode {
- fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> Content {
- self.0.clone().styled(TextNode::ITALIC, Toggle)
- }
-}
-
-/// A toggle that turns on and off alternatingly if folded.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
-pub struct Toggle;
-
-impl Fold for Toggle {
- type Output = bool;
-
- fn fold(self, outer: Self::Output) -> Self::Output {
- !outer
- }
-}
diff --git a/library/src/text/quotes.rs b/library/src/text/quotes.rs
index 87a965af..95cf1ad9 100644
--- a/library/src/text/quotes.rs
+++ b/library/src/text/quotes.rs
@@ -1,10 +1,24 @@
use typst::syntax::is_newline;
-use super::{Lang, Region};
+use crate::prelude::*;
+
+/// A smart quote.
+#[derive(Debug, Hash)]
+pub struct SmartQuoteNode {
+ pub double: bool,
+}
+
+#[node]
+impl SmartQuoteNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ let double = args.named("double")?.unwrap_or(true);
+ Ok(Self { double }.pack())
+ }
+}
/// State machine for smart quote subtitution.
#[derive(Debug, Clone)]
-pub(super) struct Quoter {
+pub struct Quoter {
/// How many quotes have been opened.
quote_depth: usize,
/// Whether an opening quote might follow.
@@ -68,7 +82,7 @@ fn is_opening_bracket(c: char) -> bool {
}
/// Decides which quotes to subtitute smart quotes with.
-pub(super) struct Quotes<'s> {
+pub struct Quotes<'s> {
/// The opening single quote.
pub single_open: &'s str,
/// The closing single quote.
diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs
index 6ce4d671..687f2a87 100644
--- a/library/src/text/shaping.rs
+++ b/library/src/text/shaping.rs
@@ -6,6 +6,7 @@ use typst::font::{Font, FontVariant};
use typst::util::SliceExt;
use super::*;
+use crate::meta::LinkNode;
use crate::prelude::*;
/// The result of shaping text.
@@ -13,7 +14,7 @@ use crate::prelude::*;
/// This type contains owned or borrowed shaped text runs, which can be
/// measured, used to reshape substrings more quickly and converted into a
/// frame.
-pub(super) struct ShapedText<'a> {
+pub struct ShapedText<'a> {
/// The text that was shaped.
pub text: &'a str,
/// The text direction.
@@ -32,7 +33,7 @@ pub(super) struct ShapedText<'a> {
/// A single glyph resulting from shaping.
#[derive(Debug, Clone)]
-pub(super) struct ShapedGlyph {
+pub struct ShapedGlyph {
/// The font the glyph is contained in.
pub font: Font,
/// The glyph's index in the font.
@@ -314,7 +315,7 @@ struct ShapingContext<'a> {
}
/// Shape text into [`ShapedText`].
-pub(super) fn shape<'a>(
+pub fn shape<'a>(
world: Tracked<dyn World>,
text: &'a str,
styles: StyleChain<'a>,
diff --git a/library/src/graphics/image.rs b/library/src/visualize/image.rs
index 2c58496c..6e8b6147 100644
--- a/library/src/graphics/image.rs
+++ b/library/src/visualize/image.rs
@@ -2,8 +2,8 @@ use std::ffi::OsStr;
use typst::image::{Image, ImageFormat, RasterFormat, VectorFormat};
+use crate::meta::LinkNode;
use crate::prelude::*;
-use crate::text::LinkNode;
/// Show a raster or vector graphic.
#[derive(Debug, Hash)]
diff --git a/library/src/graphics/line.rs b/library/src/visualize/line.rs
index 8acf5bb6..8acf5bb6 100644
--- a/library/src/graphics/line.rs
+++ b/library/src/visualize/line.rs
diff --git a/library/src/graphics/mod.rs b/library/src/visualize/mod.rs
index d77dfe36..1c87eeb3 100644
--- a/library/src/graphics/mod.rs
+++ b/library/src/visualize/mod.rs
@@ -1,11 +1,9 @@
-//! Graphical elements and effects.
+//! Drawing and visualization.
-mod hide;
mod image;
mod line;
mod shape;
-pub use self::hide::*;
pub use self::image::*;
pub use self::line::*;
pub use self::shape::*;
diff --git a/library/src/graphics/shape.rs b/library/src/visualize/shape.rs
index 114182e5..daecd580 100644
--- a/library/src/graphics/shape.rs
+++ b/library/src/visualize/shape.rs
@@ -1,7 +1,7 @@
use std::f64::consts::SQRT_2;
+use crate::meta::LinkNode;
use crate::prelude::*;
-use crate::text::LinkNode;
/// A sizable and fillable shape with optional content.
#[derive(Debug, Hash)]
diff --git a/src/model/mod.rs b/src/model/mod.rs
index 6943217b..fa047746 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -1,4 +1,4 @@
-//! Document and computation model.
+//! Content and computation model.
#[macro_use]
mod library;
diff --git a/tests/README.md b/tests/README.md
index 7ad0535c..5356cf65 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -3,7 +3,9 @@
## Directory structure
Top level directory structure:
- `src`: Testing code.
-- `typ`: Input files.
+- `typ`: Input files. The tests in `compiler` specifically test the compiler
+ while the others test the standard library (but also the compiler
+ indirectly).
- `ref`: Reference images which the output is compared with to determine whether
a test passed or failed.
- `png`: PNG files produced by tests.
diff --git a/tests/ref/base/blind.png b/tests/ref/base/blind.png
deleted file mode 100644
index e972567e..00000000
--- a/tests/ref/base/blind.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/base/color.png b/tests/ref/base/color.png
deleted file mode 100644
index 496013bb..00000000
--- a/tests/ref/base/color.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/base/data.png b/tests/ref/base/data.png
deleted file mode 100644
index 69e0ae38..00000000
--- a/tests/ref/base/data.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/base/eval.png b/tests/ref/base/eval.png
deleted file mode 100644
index 38c1d64e..00000000
--- a/tests/ref/base/eval.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/base/numbering.png b/tests/ref/base/numbering.png
deleted file mode 100644
index aa34de29..00000000
--- a/tests/ref/base/numbering.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/basics/desc.png b/tests/ref/basics/desc.png
new file mode 100644
index 00000000..e186ec8c
--- /dev/null
+++ b/tests/ref/basics/desc.png
Binary files differ
diff --git a/tests/ref/basics/enum.png b/tests/ref/basics/enum.png
new file mode 100644
index 00000000..0c9c9487
--- /dev/null
+++ b/tests/ref/basics/enum.png
Binary files differ
diff --git a/tests/ref/structure/heading.png b/tests/ref/basics/heading.png
index 96ffcb80..96ffcb80 100644
--- a/tests/ref/structure/heading.png
+++ b/tests/ref/basics/heading.png
Binary files differ
diff --git a/tests/ref/structure/attach.png b/tests/ref/basics/list-attach.png
index 9b0e4c68..9b0e4c68 100644
--- a/tests/ref/structure/attach.png
+++ b/tests/ref/basics/list-attach.png
Binary files differ
diff --git a/tests/ref/structure/list.png b/tests/ref/basics/list.png
index 5d0f03c0..5d0f03c0 100644
--- a/tests/ref/structure/list.png
+++ b/tests/ref/basics/list.png
Binary files differ
diff --git a/tests/ref/structure/table.png b/tests/ref/basics/table.png
index f50f613b..f50f613b 100644
--- a/tests/ref/structure/table.png
+++ b/tests/ref/basics/table.png
Binary files differ
diff --git a/tests/ref/code/block.png b/tests/ref/code/block.png
deleted file mode 100644
index 9cd0ba36..00000000
--- a/tests/ref/code/block.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/if.png b/tests/ref/code/if.png
deleted file mode 100644
index 177e61bd..00000000
--- a/tests/ref/code/if.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/import.png b/tests/ref/code/import.png
deleted file mode 100644
index 00d3b2ee..00000000
--- a/tests/ref/code/import.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/include.png b/tests/ref/code/include.png
deleted file mode 100644
index d3d66032..00000000
--- a/tests/ref/code/include.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/let.png b/tests/ref/code/let.png
deleted file mode 100644
index 07afcb96..00000000
--- a/tests/ref/code/let.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/ops.png b/tests/ref/code/ops.png
deleted file mode 100644
index abcab137..00000000
--- a/tests/ref/code/ops.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/return.png b/tests/ref/code/return.png
deleted file mode 100644
index 50410887..00000000
--- a/tests/ref/code/return.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/code/while.png b/tests/ref/code/while.png
deleted file mode 100644
index 026f9943..00000000
--- a/tests/ref/code/while.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/coma.png b/tests/ref/coma.png
index 62edb5e0..8bfbc203 100644
--- a/tests/ref/coma.png
+++ b/tests/ref/coma.png
Binary files differ
diff --git a/tests/ref/code/array.png b/tests/ref/compiler/array.png
index cbda8aee..cbda8aee 100644
--- a/tests/ref/code/array.png
+++ b/tests/ref/compiler/array.png
Binary files differ
diff --git a/tests/ref/compiler/bench.png b/tests/ref/compiler/bench.png
new file mode 100644
index 00000000..cadc0914
--- /dev/null
+++ b/tests/ref/compiler/bench.png
Binary files differ
diff --git a/tests/ref/compiler/block.png b/tests/ref/compiler/block.png
new file mode 100644
index 00000000..c5782da5
--- /dev/null
+++ b/tests/ref/compiler/block.png
Binary files differ
diff --git a/tests/ref/code/break-continue.png b/tests/ref/compiler/break-continue.png
index 401b3940..401b3940 100644
--- a/tests/ref/code/break-continue.png
+++ b/tests/ref/compiler/break-continue.png
Binary files differ
diff --git a/tests/ref/code/call.png b/tests/ref/compiler/call.png
index f0f2e852..f0f2e852 100644
--- a/tests/ref/code/call.png
+++ b/tests/ref/compiler/call.png
Binary files differ
diff --git a/tests/ref/code/closure.png b/tests/ref/compiler/closure.png
index b4c83256..b4c83256 100644
--- a/tests/ref/code/closure.png
+++ b/tests/ref/compiler/closure.png
Binary files differ
diff --git a/tests/ref/code/comment.png b/tests/ref/compiler/comment.png
index 5928dc87..5928dc87 100644
--- a/tests/ref/code/comment.png
+++ b/tests/ref/compiler/comment.png
Binary files differ
diff --git a/tests/ref/style/construct.png b/tests/ref/compiler/construct.png
index 43cf5d79..43cf5d79 100644
--- a/tests/ref/style/construct.png
+++ b/tests/ref/compiler/construct.png
Binary files differ
diff --git a/tests/ref/code/dict.png b/tests/ref/compiler/dict.png
index 04a5dd7d..04a5dd7d 100644
--- a/tests/ref/code/dict.png
+++ b/tests/ref/compiler/dict.png
Binary files differ
diff --git a/tests/ref/code/for.png b/tests/ref/compiler/for.png
index 60c505ec..8c08ab04 100644
--- a/tests/ref/code/for.png
+++ b/tests/ref/compiler/for.png
Binary files differ
diff --git a/tests/ref/compiler/if.png b/tests/ref/compiler/if.png
new file mode 100644
index 00000000..cca9a570
--- /dev/null
+++ b/tests/ref/compiler/if.png
Binary files differ
diff --git a/tests/ref/compiler/import.png b/tests/ref/compiler/import.png
new file mode 100644
index 00000000..dddbe408
--- /dev/null
+++ b/tests/ref/compiler/import.png
Binary files differ
diff --git a/tests/ref/compiler/include.png b/tests/ref/compiler/include.png
new file mode 100644
index 00000000..09ff7498
--- /dev/null
+++ b/tests/ref/compiler/include.png
Binary files differ
diff --git a/tests/ref/style/label.png b/tests/ref/compiler/label.png
index ffad978c..ffad978c 100644
--- a/tests/ref/style/label.png
+++ b/tests/ref/compiler/label.png
Binary files differ
diff --git a/tests/ref/compiler/let.png b/tests/ref/compiler/let.png
new file mode 100644
index 00000000..7a45eca1
--- /dev/null
+++ b/tests/ref/compiler/let.png
Binary files differ
diff --git a/tests/ref/base/collection.png b/tests/ref/compiler/methods-collection.png
index e93e2beb..e93e2beb 100644
--- a/tests/ref/base/collection.png
+++ b/tests/ref/compiler/methods-collection.png
Binary files differ
diff --git a/tests/ref/compiler/methods-color.png b/tests/ref/compiler/methods-color.png
new file mode 100644
index 00000000..9b65c16d
--- /dev/null
+++ b/tests/ref/compiler/methods-color.png
Binary files differ
diff --git a/tests/ref/compiler/ops.png b/tests/ref/compiler/ops.png
new file mode 100644
index 00000000..ef6ffb4a
--- /dev/null
+++ b/tests/ref/compiler/ops.png
Binary files differ
diff --git a/tests/ref/code/repr.png b/tests/ref/compiler/repr.png
index b81083f5..b81083f5 100644
--- a/tests/ref/code/repr.png
+++ b/tests/ref/compiler/repr.png
Binary files differ
diff --git a/tests/ref/compiler/return.png b/tests/ref/compiler/return.png
new file mode 100644
index 00000000..6d558e62
--- /dev/null
+++ b/tests/ref/compiler/return.png
Binary files differ
diff --git a/tests/ref/style/set.png b/tests/ref/compiler/set.png
index 94470239..94470239 100644
--- a/tests/ref/style/set.png
+++ b/tests/ref/compiler/set.png
Binary files differ
diff --git a/tests/ref/text/shorthands.png b/tests/ref/compiler/shorthand.png
index ddb679f5..ddb679f5 100644
--- a/tests/ref/text/shorthands.png
+++ b/tests/ref/compiler/shorthand.png
Binary files differ
diff --git a/tests/ref/style/show-bare.png b/tests/ref/compiler/show-bare.png
index ff746d26..ff746d26 100644
--- a/tests/ref/style/show-bare.png
+++ b/tests/ref/compiler/show-bare.png
Binary files differ
diff --git a/tests/ref/style/show-node.png b/tests/ref/compiler/show-node.png
index 1ea33e4f..1ea33e4f 100644
--- a/tests/ref/style/show-node.png
+++ b/tests/ref/compiler/show-node.png
Binary files differ
diff --git a/tests/ref/style/show-recursive.png b/tests/ref/compiler/show-recursive.png
index 4c47a7af..4c47a7af 100644
--- a/tests/ref/style/show-recursive.png
+++ b/tests/ref/compiler/show-recursive.png
Binary files differ
diff --git a/tests/ref/style/show-selector.png b/tests/ref/compiler/show-selector.png
index 1cdcfa3f..1cdcfa3f 100644
--- a/tests/ref/style/show-selector.png
+++ b/tests/ref/compiler/show-selector.png
Binary files differ
diff --git a/tests/ref/style/show-text.png b/tests/ref/compiler/show-text.png
index d0ed2f92..d0ed2f92 100644
--- a/tests/ref/style/show-text.png
+++ b/tests/ref/compiler/show-text.png
Binary files differ
diff --git a/tests/ref/compiler/while.png b/tests/ref/compiler/while.png
new file mode 100644
index 00000000..236be426
--- /dev/null
+++ b/tests/ref/compiler/while.png
Binary files differ
diff --git a/tests/ref/compute/create.png b/tests/ref/compute/create.png
new file mode 100644
index 00000000..600e6174
--- /dev/null
+++ b/tests/ref/compute/create.png
Binary files differ
diff --git a/tests/ref/compute/data.png b/tests/ref/compute/data.png
new file mode 100644
index 00000000..678a1fd1
--- /dev/null
+++ b/tests/ref/compute/data.png
Binary files differ
diff --git a/tests/ref/compute/utility.png b/tests/ref/compute/utility.png
new file mode 100644
index 00000000..035ce431
--- /dev/null
+++ b/tests/ref/compute/utility.png
Binary files differ
diff --git a/tests/ref/empty.png b/tests/ref/empty.png
index 87c06b0a..db3a6695 100644
--- a/tests/ref/empty.png
+++ b/tests/ref/empty.png
Binary files differ
diff --git a/tests/ref/graphics/hide.png b/tests/ref/graphics/hide.png
deleted file mode 100644
index 8a60cf90..00000000
--- a/tests/ref/graphics/hide.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/shape-circle.png b/tests/ref/graphics/shape-circle.png
deleted file mode 100644
index 040c6f0b..00000000
--- a/tests/ref/graphics/shape-circle.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/shape-ellipse.png b/tests/ref/graphics/shape-ellipse.png
deleted file mode 100644
index 296fc14e..00000000
--- a/tests/ref/graphics/shape-ellipse.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/shape-fill-stroke.png b/tests/ref/graphics/shape-fill-stroke.png
deleted file mode 100644
index 91cddcc2..00000000
--- a/tests/ref/graphics/shape-fill-stroke.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/shape-rect.png b/tests/ref/graphics/shape-rect.png
deleted file mode 100644
index e2ea0502..00000000
--- a/tests/ref/graphics/shape-rect.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/shape-square.png b/tests/ref/graphics/shape-square.png
deleted file mode 100644
index 00a0c848..00000000
--- a/tests/ref/graphics/shape-square.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/columns.png b/tests/ref/layout/columns.png
index 6f210510..df7b7084 100644
--- a/tests/ref/layout/columns.png
+++ b/tests/ref/layout/columns.png
Binary files differ
diff --git a/tests/ref/layout/container.png b/tests/ref/layout/container.png
index 87484c25..f82df108 100644
--- a/tests/ref/layout/container.png
+++ b/tests/ref/layout/container.png
Binary files differ
diff --git a/tests/ref/layout/flow-orphan.png b/tests/ref/layout/flow-orphan.png
new file mode 100644
index 00000000..1e5fade4
--- /dev/null
+++ b/tests/ref/layout/flow-orphan.png
Binary files differ
diff --git a/tests/ref/layout/grid-1.png b/tests/ref/layout/grid-1.png
index 2c57e28c..99a97bb7 100644
--- a/tests/ref/layout/grid-1.png
+++ b/tests/ref/layout/grid-1.png
Binary files differ
diff --git a/tests/ref/layout/grid-2.png b/tests/ref/layout/grid-2.png
index 64986797..8bc22660 100644
--- a/tests/ref/layout/grid-2.png
+++ b/tests/ref/layout/grid-2.png
Binary files differ
diff --git a/tests/ref/layout/grid-4.png b/tests/ref/layout/grid-4.png
index c78eb721..2bbc84cc 100644
--- a/tests/ref/layout/grid-4.png
+++ b/tests/ref/layout/grid-4.png
Binary files differ
diff --git a/tests/ref/layout/grid-5.png b/tests/ref/layout/grid-5.png
index 8afe9446..532700b1 100644
--- a/tests/ref/layout/grid-5.png
+++ b/tests/ref/layout/grid-5.png
Binary files differ
diff --git a/tests/ref/layout/hide.png b/tests/ref/layout/hide.png
new file mode 100644
index 00000000..6450d669
--- /dev/null
+++ b/tests/ref/layout/hide.png
Binary files differ
diff --git a/tests/ref/layout/locate-break.png b/tests/ref/layout/locate-break.png
deleted file mode 100644
index 25abb4a0..00000000
--- a/tests/ref/layout/locate-break.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/locate-group.png b/tests/ref/layout/locate-group.png
deleted file mode 100644
index c9fe4065..00000000
--- a/tests/ref/layout/locate-group.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/locate.png b/tests/ref/layout/locate.png
deleted file mode 100644
index 015c5a6d..00000000
--- a/tests/ref/layout/locate.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/orphan-heading.png b/tests/ref/layout/orphan-heading.png
deleted file mode 100644
index aa5a7838..00000000
--- a/tests/ref/layout/orphan-heading.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/orphan-widow.png b/tests/ref/layout/orphan-widow.png
deleted file mode 100644
index 8fc523a6..00000000
--- a/tests/ref/layout/orphan-widow.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/page-margin.png b/tests/ref/layout/page-margin.png
index 211f881c..6952189b 100644
--- a/tests/ref/layout/page-margin.png
+++ b/tests/ref/layout/page-margin.png
Binary files differ
diff --git a/tests/ref/layout/page-style.png b/tests/ref/layout/page-style.png
index 7132d20b..ac6b602c 100644
--- a/tests/ref/layout/page-style.png
+++ b/tests/ref/layout/page-style.png
Binary files differ
diff --git a/tests/ref/layout/page.png b/tests/ref/layout/page.png
index 35716e4d..4168d201 100644
--- a/tests/ref/layout/page.png
+++ b/tests/ref/layout/page.png
Binary files differ
diff --git a/tests/ref/text/bidi.png b/tests/ref/layout/par-bidi.png
index c9be82d4..c9be82d4 100644
--- a/tests/ref/text/bidi.png
+++ b/tests/ref/layout/par-bidi.png
Binary files differ
diff --git a/tests/ref/layout/par-indent.png b/tests/ref/layout/par-indent.png
new file mode 100644
index 00000000..7a0bd4b6
--- /dev/null
+++ b/tests/ref/layout/par-indent.png
Binary files differ
diff --git a/tests/ref/text/justify.png b/tests/ref/layout/par-justify.png
index e8b50723..e8b50723 100644
--- a/tests/ref/text/justify.png
+++ b/tests/ref/layout/par-justify.png
Binary files differ
diff --git a/tests/ref/layout/par-knuth.png b/tests/ref/layout/par-knuth.png
new file mode 100644
index 00000000..fca0892e
--- /dev/null
+++ b/tests/ref/layout/par-knuth.png
Binary files differ
diff --git a/tests/ref/layout/par-simple.png b/tests/ref/layout/par-simple.png
new file mode 100644
index 00000000..92f98b36
--- /dev/null
+++ b/tests/ref/layout/par-simple.png
Binary files differ
diff --git a/tests/ref/text/par.png b/tests/ref/layout/par.png
index 199c8919..199c8919 100644
--- a/tests/ref/text/par.png
+++ b/tests/ref/layout/par.png
Binary files differ
diff --git a/tests/ref/layout/repeat.png b/tests/ref/layout/repeat.png
new file mode 100644
index 00000000..fcd52987
--- /dev/null
+++ b/tests/ref/layout/repeat.png
Binary files differ
diff --git a/tests/ref/layout/stack-2.png b/tests/ref/layout/stack-2.png
index 52b75bbd..af58d9c4 100644
--- a/tests/ref/layout/stack-2.png
+++ b/tests/ref/layout/stack-2.png
Binary files differ
diff --git a/tests/ref/graphics/transform.png b/tests/ref/layout/transform.png
index cb4b0af2..cb4b0af2 100644
--- a/tests/ref/graphics/transform.png
+++ b/tests/ref/layout/transform.png
Binary files differ
diff --git a/tests/ref/layout/math.png b/tests/ref/math/simple.png
index 902354df..902354df 100644
--- a/tests/ref/layout/math.png
+++ b/tests/ref/math/simple.png
Binary files differ
diff --git a/tests/ref/meta/document.png b/tests/ref/meta/document.png
new file mode 100644
index 00000000..bc0a95bf
--- /dev/null
+++ b/tests/ref/meta/document.png
Binary files differ
diff --git a/tests/ref/meta/link.png b/tests/ref/meta/link.png
new file mode 100644
index 00000000..604e09d0
--- /dev/null
+++ b/tests/ref/meta/link.png
Binary files differ
diff --git a/tests/ref/structure/desc.png b/tests/ref/structure/desc.png
deleted file mode 100644
index e8b1d151..00000000
--- a/tests/ref/structure/desc.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/structure/enum.png b/tests/ref/structure/enum.png
deleted file mode 100644
index 39227b5b..00000000
--- a/tests/ref/structure/enum.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/style/closure.png b/tests/ref/style/closure.png
deleted file mode 100644
index 77d88d0c..00000000
--- a/tests/ref/style/closure.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/baseline.png b/tests/ref/text/baseline.png
index 37bb1949..f011c8c4 100644
--- a/tests/ref/text/baseline.png
+++ b/tests/ref/text/baseline.png
Binary files differ
diff --git a/tests/ref/text/chinese.png b/tests/ref/text/chinese.png
index aa8801c0..89ee357b 100644
--- a/tests/ref/text/chinese.png
+++ b/tests/ref/text/chinese.png
Binary files differ
diff --git a/tests/ref/text/emph-strong.png b/tests/ref/text/emph-strong.png
deleted file mode 100644
index cce98812..00000000
--- a/tests/ref/text/emph-strong.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/emphasis.png b/tests/ref/text/emphasis.png
new file mode 100644
index 00000000..c004421d
--- /dev/null
+++ b/tests/ref/text/emphasis.png
Binary files differ
diff --git a/tests/ref/text/features.png b/tests/ref/text/features.png
index 36609d89..1c3b030c 100644
--- a/tests/ref/text/features.png
+++ b/tests/ref/text/features.png
Binary files differ
diff --git a/tests/ref/text/hyphenate.png b/tests/ref/text/hyphenate.png
index 47a8ffa5..e304cb8c 100644
--- a/tests/ref/text/hyphenate.png
+++ b/tests/ref/text/hyphenate.png
Binary files differ
diff --git a/tests/ref/text/indent.png b/tests/ref/text/indent.png
deleted file mode 100644
index 9cf2ace5..00000000
--- a/tests/ref/text/indent.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/knuth.png b/tests/ref/text/knuth.png
deleted file mode 100644
index 8595fe29..00000000
--- a/tests/ref/text/knuth.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/link.png b/tests/ref/text/link.png
deleted file mode 100644
index 9d5cb054..00000000
--- a/tests/ref/text/link.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/microtype.png b/tests/ref/text/microtype.png
index 7edc61cc..e0d149e6 100644
--- a/tests/ref/text/microtype.png
+++ b/tests/ref/text/microtype.png
Binary files differ
diff --git a/tests/ref/text/plain.png b/tests/ref/text/plain.png
deleted file mode 100644
index bfdf47a2..00000000
--- a/tests/ref/text/plain.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/quotes.png b/tests/ref/text/quotes.png
index 058055ae..1054daca 100644
--- a/tests/ref/text/quotes.png
+++ b/tests/ref/text/quotes.png
Binary files differ
diff --git a/tests/ref/text/code.png b/tests/ref/text/raw-highlight.png
index e0387870..e0387870 100644
--- a/tests/ref/text/code.png
+++ b/tests/ref/text/raw-highlight.png
Binary files differ
diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png
index 3a7691fd..f7912051 100644
--- a/tests/ref/text/raw.png
+++ b/tests/ref/text/raw.png
Binary files differ
diff --git a/tests/ref/text/repeat.png b/tests/ref/text/repeat.png
deleted file mode 100644
index d7786bef..00000000
--- a/tests/ref/text/repeat.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/text/shifts.png b/tests/ref/text/shift.png
index 7e8d99a9..7e8d99a9 100644
--- a/tests/ref/text/shifts.png
+++ b/tests/ref/text/shift.png
Binary files differ
diff --git a/tests/ref/text/space.png b/tests/ref/text/space.png
new file mode 100644
index 00000000..09efda70
--- /dev/null
+++ b/tests/ref/text/space.png
Binary files differ
diff --git a/tests/ref/text/tracking-spacing.png b/tests/ref/text/tracking-spacing.png
index 69fc1eef..2ce0d549 100644
--- a/tests/ref/text/tracking-spacing.png
+++ b/tests/ref/text/tracking-spacing.png
Binary files differ
diff --git a/tests/ref/text/whitespace.png b/tests/ref/text/whitespace.png
deleted file mode 100644
index 9a1ed3cd..00000000
--- a/tests/ref/text/whitespace.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/graphics/image.png b/tests/ref/visualize/image.png
index a89f1963..a89f1963 100644
--- a/tests/ref/graphics/image.png
+++ b/tests/ref/visualize/image.png
Binary files differ
diff --git a/tests/ref/graphics/line.png b/tests/ref/visualize/line.png
index 4a73ccd7..4a73ccd7 100644
--- a/tests/ref/graphics/line.png
+++ b/tests/ref/visualize/line.png
Binary files differ
diff --git a/tests/ref/graphics/shape-aspect.png b/tests/ref/visualize/shape-aspect.png
index a8e458fb..a8e458fb 100644
--- a/tests/ref/graphics/shape-aspect.png
+++ b/tests/ref/visualize/shape-aspect.png
Binary files differ
diff --git a/tests/ref/visualize/shape-circle.png b/tests/ref/visualize/shape-circle.png
new file mode 100644
index 00000000..6cbbc0e3
--- /dev/null
+++ b/tests/ref/visualize/shape-circle.png
Binary files differ
diff --git a/tests/ref/visualize/shape-ellipse.png b/tests/ref/visualize/shape-ellipse.png
new file mode 100644
index 00000000..50467dce
--- /dev/null
+++ b/tests/ref/visualize/shape-ellipse.png
Binary files differ
diff --git a/tests/ref/visualize/shape-fill-stroke.png b/tests/ref/visualize/shape-fill-stroke.png
new file mode 100644
index 00000000..b8c78a55
--- /dev/null
+++ b/tests/ref/visualize/shape-fill-stroke.png
Binary files differ
diff --git a/tests/ref/visualize/shape-rect.png b/tests/ref/visualize/shape-rect.png
new file mode 100644
index 00000000..b3311ba5
--- /dev/null
+++ b/tests/ref/visualize/shape-rect.png
Binary files differ
diff --git a/tests/ref/visualize/shape-square.png b/tests/ref/visualize/shape-square.png
new file mode 100644
index 00000000..1f5303b9
--- /dev/null
+++ b/tests/ref/visualize/shape-square.png
Binary files differ
diff --git a/tests/src/benches.rs b/tests/src/benches.rs
index 1ae012eb..4cd7d9c3 100644
--- a/tests/src/benches.rs
+++ b/tests/src/benches.rs
@@ -10,7 +10,7 @@ use typst::util::Buffer;
use typst::World;
use unscanny::Scanner;
-const TEXT: &str = include_str!("../typ/benches/bench.typ");
+const TEXT: &str = include_str!("../typ/compiler/bench.typ");
const FONT: &[u8] = include_bytes!("../fonts/IBMPlexSans-Regular.ttf");
main!(
@@ -111,7 +111,7 @@ impl BenchWorld {
let book = FontBook::from_fonts([&font]);
Self {
- library: Prehashed::new(typst_library::new()),
+ library: Prehashed::new(typst_library::build()),
book: Prehashed::new(book),
font,
source: Source::detached(TEXT),
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index 215d7fe7..e7c630f6 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -145,7 +145,7 @@ impl Args {
}
fn library() -> Library {
- let mut lib = typst_library::new();
+ let mut lib = typst_library::build();
// Set page width to 120pt with 10pt margins, so that the inner page is
// exactly 100pt wide. Page height is unbounded and font size is 10pt so
diff --git a/tests/typ/base/assert.typ b/tests/typ/base/assert.typ
deleted file mode 100644
index b0c8aafd..00000000
--- a/tests/typ/base/assert.typ
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test the `assert` function.
-// Ref: false
-
----
-#assert(1 + 1 == 2)
-#assert(range(2, 5) == (2, 3, 4))
-#assert(not false)
-
----
-// Test failing assertions.
-// Error: 9-15 assertion failed
-#assert(1 == 2)
-
----
-// Test failing assertions.
-// Error: 9-15 expected boolean, found string
-#assert("true")
-
----
-// Test the `type` function.
-#test(type(1), "integer")
-#test(type(ltr), "direction")
-#test(type(10 / 3), "float")
diff --git a/tests/typ/base/numbering.typ b/tests/typ/base/numbering.typ
deleted file mode 100644
index 200850bc..00000000
--- a/tests/typ/base/numbering.typ
+++ /dev/null
@@ -1,13 +0,0 @@
-// Test integrated numbering patterns.
-
----
-#for i in range(9) {
- numbering(i, "* and ")
- numbering(i, "I")
- [ for #i]
- parbreak()
-}
-
----
-// Error: 12-14 must be at least zero
-#numbering(-1, "1")
diff --git a/tests/typ/base/type.typ b/tests/typ/base/type.typ
deleted file mode 100644
index 37cf8623..00000000
--- a/tests/typ/base/type.typ
+++ /dev/null
@@ -1,7 +0,0 @@
-// Test the `type` function.
-// Ref: false
-
----
-#test(type(1), "integer")
-#test(type(ltr), "direction")
-#test(type(10 / 3), "float")
diff --git a/tests/typ/structure/desc.typ b/tests/typ/basics/desc.typ
index 1bc92625..1bc92625 100644
--- a/tests/typ/structure/desc.typ
+++ b/tests/typ/basics/desc.typ
diff --git a/tests/typ/structure/enum.typ b/tests/typ/basics/enum.typ
index d4c30385..d4c30385 100644
--- a/tests/typ/structure/enum.typ
+++ b/tests/typ/basics/enum.typ
diff --git a/tests/typ/structure/heading.typ b/tests/typ/basics/heading.typ
index 9fd4e648..9fd4e648 100644
--- a/tests/typ/structure/heading.typ
+++ b/tests/typ/basics/heading.typ
diff --git a/tests/typ/structure/attach.typ b/tests/typ/basics/list-attach.typ
index 9d043eb0..9d043eb0 100644
--- a/tests/typ/structure/attach.typ
+++ b/tests/typ/basics/list-attach.typ
diff --git a/tests/typ/structure/list.typ b/tests/typ/basics/list.typ
index 9ed5993a..9ed5993a 100644
--- a/tests/typ/structure/list.typ
+++ b/tests/typ/basics/list.typ
diff --git a/tests/typ/structure/table.typ b/tests/typ/basics/table.typ
index 527141c5..527141c5 100644
--- a/tests/typ/structure/table.typ
+++ b/tests/typ/basics/table.typ
diff --git a/tests/typ/code/array.typ b/tests/typ/compiler/array.typ
index cb8433cb..cb8433cb 100644
--- a/tests/typ/code/array.typ
+++ b/tests/typ/compiler/array.typ
diff --git a/tests/typ/benches/bench.typ b/tests/typ/compiler/bench.typ
index 6aff1ac2..6aff1ac2 100644
--- a/tests/typ/benches/bench.typ
+++ b/tests/typ/compiler/bench.typ
diff --git a/tests/typ/code/block.typ b/tests/typ/compiler/block.typ
index d82d497f..45f63f8e 100644
--- a/tests/typ/code/block.typ
+++ b/tests/typ/compiler/block.typ
@@ -79,7 +79,7 @@
---
// Double block creates a scope.
{{
- import b from "target.typ"
+ import b from "module.typ"
test(b, 1)
}}
diff --git a/tests/typ/code/break-continue.typ b/tests/typ/compiler/break-continue.typ
index fb3222fa..fb3222fa 100644
--- a/tests/typ/code/break-continue.typ
+++ b/tests/typ/compiler/break-continue.typ
diff --git a/tests/typ/code/call.typ b/tests/typ/compiler/call.typ
index dc582c9c..dc582c9c 100644
--- a/tests/typ/code/call.typ
+++ b/tests/typ/compiler/call.typ
diff --git a/tests/typ/code/closure.typ b/tests/typ/compiler/closure.typ
index e9389e13..2c6c1ea0 100644
--- a/tests/typ/code/closure.typ
+++ b/tests/typ/compiler/closure.typ
@@ -60,7 +60,7 @@
---
// Import bindings.
{
- let b = "target.typ"
+ let b = "module.typ"
let f() = {
import b from b
b
diff --git a/tests/typ/code/comment.typ b/tests/typ/compiler/comment.typ
index 4a4dc7ab..4a4dc7ab 100644
--- a/tests/typ/code/comment.typ
+++ b/tests/typ/compiler/comment.typ
diff --git a/tests/typ/style/construct.typ b/tests/typ/compiler/construct.typ
index f535184c..f535184c 100644
--- a/tests/typ/style/construct.typ
+++ b/tests/typ/compiler/construct.typ
diff --git a/tests/typ/code/dict.typ b/tests/typ/compiler/dict.typ
index d791f77b..d791f77b 100644
--- a/tests/typ/code/dict.typ
+++ b/tests/typ/compiler/dict.typ
diff --git a/tests/typ/code/field.typ b/tests/typ/compiler/field.typ
index abea87fb..abea87fb 100644
--- a/tests/typ/code/field.typ
+++ b/tests/typ/compiler/field.typ
diff --git a/tests/typ/code/for.typ b/tests/typ/compiler/for.typ
index 822f7423..822f7423 100644
--- a/tests/typ/code/for.typ
+++ b/tests/typ/compiler/for.typ
diff --git a/tests/typ/code/if.typ b/tests/typ/compiler/if.typ
index 0d87c689..0d87c689 100644
--- a/tests/typ/code/if.typ
+++ b/tests/typ/compiler/if.typ
diff --git a/tests/typ/code/import.typ b/tests/typ/compiler/import.typ
index 5291af39..0620403d 100644
--- a/tests/typ/code/import.typ
+++ b/tests/typ/compiler/import.typ
@@ -4,45 +4,45 @@
// Test importing semantics.
// A named import.
-#import item from "target.typ"
+#import item from "module.typ"
#test(item(1, 2), 3)
// Test that this will be overwritten.
#let value = [foo]
// Import multiple things.
-#import fn, value from "target.typ"
+#import fn, value from "module.typ"
#fn[Like and Subscribe!]
#value
// Code mode
{
- import b from "target.typ"
+ import b from "module.typ"
test(b, 1)
}
// A wildcard import.
-#import * from "target.typ"
+#import * from "module.typ"
// It exists now!
#d
// Who needs whitespace anyways?
-#import*from"target.typ"
+#import*from"module.typ"
// Should output `bye`.
// Stop at semicolon.
-#import a, c from "target.typ";bye
+#import a, c from "module.typ";bye
// Allow the trailing comma.
-#import a, c, from "target.typ"
+#import a, c, from "module.typ"
---
// Error: 19-21 failed to load file (is a directory)
#import name from ""
---
-// Error: 16-27 file not found (searched at typ/code/lib/0.2.1)
+// Error: 16-27 file not found (searched at typ/compiler/lib/0.2.1)
#import * from "lib/0.2.1"
---
@@ -53,7 +53,7 @@
---
// Unresolved import.
// Error: 9-21 unresolved import
-#import non_existing from "target.typ"
+#import non_existing from "module.typ"
---
// Cyclic import of this very file.
@@ -62,7 +62,7 @@
---
// Cyclic import in other file.
-#import * from "./importable/cycle1.typ"
+#import * from "./modules/cycle1.typ"
This is never reached.
@@ -80,36 +80,36 @@ This is never reached.
#import afrom, "b", c
// Error: 9 expected import items
-#import from "target.typ"
+#import from "module.typ"
// Error: 9-10 expected expression, found assignment operator
// Error: 10 expected import items
-#import = from "target.typ"
+#import = from "module.typ"
// Error: 15 expected expression
#import * from
// An additional trailing comma.
// Error: 17-18 expected expression, found comma
-#import a, b, c,, from "target.typ"
+#import a, b, c,, from "module.typ"
// Error: 1-6 unexpected keyword `from`
-#from "target.typ"
+#from "module.typ"
// Error: 2:2 expected semicolon or line break
-#import * from "target.typ
+#import * from "module.typ
"target
// Error: 28 expected semicolon or line break
-#import * from "target.typ" § 0.2.1
+#import * from "module.typ" § 0.2.1
// A star in the list.
// Error: 12-13 expected expression, found star
-#import a, *, b from "target.typ"
+#import a, *, b from "module.typ"
// An item after a star.
// Error: 10 expected keyword `from`
-#import *, a from "target.typ"
+#import *, a from "module.typ"
---
// Error: 9-13 expected identifier, found named pair
diff --git a/tests/typ/code/include.typ b/tests/typ/compiler/include.typ
index e862adac..289fea21 100644
--- a/tests/typ/code/include.typ
+++ b/tests/typ/compiler/include.typ
@@ -6,22 +6,22 @@
= Document
// Include a file
-#include "/typ/code/importable/chap1.typ"
+#include "/typ/compiler/modules/chap1.typ"
// Expression as a file name.
-#let chap2 = include "import" + "able/chap" + "2.typ"
+#let chap2 = include "modu" + "les/chap" + "2.typ"
-- _Intermission_ --
#chap2
---
{
- // Error: 19-41 file not found (searched at typ/code/importable/chap3.typ)
- let x = include "importable/chap3.typ"
+ // Error: 19-38 file not found (searched at typ/compiler/modules/chap3.typ)
+ let x = include "modules/chap3.typ"
}
---
-#include "importable/chap1.typ"
+#include "modules/chap1.typ"
// The variables of the file should not appear in this scope.
// Error: 1-6 unknown variable
diff --git a/tests/typ/style/label.typ b/tests/typ/compiler/label.typ
index 795c0435..795c0435 100644
--- a/tests/typ/style/label.typ
+++ b/tests/typ/compiler/label.typ
diff --git a/tests/typ/code/let.typ b/tests/typ/compiler/let.typ
index c3be64a5..c3be64a5 100644
--- a/tests/typ/code/let.typ
+++ b/tests/typ/compiler/let.typ
diff --git a/tests/typ/base/collection.typ b/tests/typ/compiler/methods-collection.typ
index 46ff97ab..fcebf640 100644
--- a/tests/typ/base/collection.typ
+++ b/tests/typ/compiler/methods-collection.typ
@@ -1,4 +1,4 @@
-// Test collection functions.
+// Test the collection methods.
// Ref: false
---
diff --git a/tests/typ/compiler/methods-color.typ b/tests/typ/compiler/methods-color.typ
new file mode 100644
index 00000000..1188030a
--- /dev/null
+++ b/tests/typ/compiler/methods-color.typ
@@ -0,0 +1,22 @@
+// Test color modification methods.
+
+---
+// Test gray color modification.
+#test(luma(20%).lighten(50%), luma(60%))
+#test(luma(80%).darken(20%), luma(63.9%))
+#test(luma(80%).negate(), luma(20%))
+
+---
+// Test CMYK color conversion.
+// Ref: true
+#let c = cmyk(50%, 64%, 16%, 17%)
+#rect(width: 1cm, fill: cmyk(69%, 11%, 69%, 41%))
+#rect(width: 1cm, fill: c)
+#rect(width: 1cm, fill: c.negate())
+
+#for x in range(0, 11) {
+ square(width: 9pt, fill: c.lighten(x * 10%))
+}
+#for x in range(0, 11) {
+ square(width: 9pt, fill: c.darken(x * 10%))
+}
diff --git a/tests/typ/base/string.typ b/tests/typ/compiler/methods-str.typ
index e724f563..aead4aa4 100644
--- a/tests/typ/base/string.typ
+++ b/tests/typ/compiler/methods-str.typ
@@ -1,19 +1,7 @@
-// Test string related methods.
+// Test the string methods.
// Ref: false
---
-// Test conversion to string.
-#test(str(123), "123")
-#test(str(50.14), "50.14")
-#test(str(10 / 3).len() > 10, true)
-#test(repr(ltr), "ltr")
-#test(repr((1, 2, false, )), "(1, 2, false)")
-
----
-// Error: 6-8 cannot convert content to string
-#str([])
-
----
// Test the `slice` method.
#test("abc".slice(1, 2), "b")
#test("abc🏡def".slice(2, 7), "c🏡")
@@ -127,14 +115,3 @@
#test("abc".split("b"), ("a", "c"))
#test("a123c".split(regex("\d")), ("a", "", "", "c"))
#test("a123c".split(regex("\d+")), ("a", "c"))
-
----
-// 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 content, found integer
-#upper(1)
diff --git a/tests/typ/code/methods.typ b/tests/typ/compiler/methods.typ
index f5db8ca0..07f6e410 100644
--- a/tests/typ/code/methods.typ
+++ b/tests/typ/compiler/methods.typ
@@ -43,8 +43,4 @@
---
// Error: 3-6 cannot mutate a constant
-{ box = 1 }
-
----
-// Error: 3-6 cannot mutate a constant
{ box.push(1) }
diff --git a/tests/typ/code/target.typ b/tests/typ/compiler/module.typ
index b0a3fbf3..b0a3fbf3 100644
--- a/tests/typ/code/target.typ
+++ b/tests/typ/compiler/module.typ
diff --git a/tests/typ/code/importable/chap1.typ b/tests/typ/compiler/modules/chap1.typ
index 06a4c1a1..06a4c1a1 100644
--- a/tests/typ/code/importable/chap1.typ
+++ b/tests/typ/compiler/modules/chap1.typ
diff --git a/tests/typ/code/importable/chap2.typ b/tests/typ/compiler/modules/chap2.typ
index d4aedc60..d4aedc60 100644
--- a/tests/typ/code/importable/chap2.typ
+++ b/tests/typ/compiler/modules/chap2.typ
diff --git a/tests/typ/code/importable/cycle1.typ b/tests/typ/compiler/modules/cycle1.typ
index a9c00f5e..a9c00f5e 100644
--- a/tests/typ/code/importable/cycle1.typ
+++ b/tests/typ/compiler/modules/cycle1.typ
diff --git a/tests/typ/code/importable/cycle2.typ b/tests/typ/compiler/modules/cycle2.typ
index 204da519..204da519 100644
--- a/tests/typ/code/importable/cycle2.typ
+++ b/tests/typ/compiler/modules/cycle2.typ
diff --git a/tests/typ/code/ops-assoc.typ b/tests/typ/compiler/ops-assoc.typ
index ec128c61..ec128c61 100644
--- a/tests/typ/code/ops-assoc.typ
+++ b/tests/typ/compiler/ops-assoc.typ
diff --git a/tests/typ/code/ops-invalid.typ b/tests/typ/compiler/ops-invalid.typ
index 3e9e5478..3e9e5478 100644
--- a/tests/typ/code/ops-invalid.typ
+++ b/tests/typ/compiler/ops-invalid.typ
diff --git a/tests/typ/code/ops-prec.typ b/tests/typ/compiler/ops-prec.typ
index 23afcc5f..23afcc5f 100644
--- a/tests/typ/code/ops-prec.typ
+++ b/tests/typ/compiler/ops-prec.typ
diff --git a/tests/typ/code/ops.typ b/tests/typ/compiler/ops.typ
index c382f34d..a38a527c 100644
--- a/tests/typ/code/ops.typ
+++ b/tests/typ/compiler/ops.typ
@@ -189,6 +189,10 @@
{ x += "thing" } #test(x, "something")
---
+// Error: 3-6 cannot mutate a constant
+{ box = 1 }
+
+---
// Test `in` operator.
#test("hi" in "worship", true)
#test("hi" in ("we", "hi", "bye"), true)
diff --git a/tests/typ/code/repr.typ b/tests/typ/compiler/repr.typ
index bdea9c82..bdea9c82 100644
--- a/tests/typ/code/repr.typ
+++ b/tests/typ/compiler/repr.typ
diff --git a/tests/typ/code/return.typ b/tests/typ/compiler/return.typ
index 0eea394e..0eea394e 100644
--- a/tests/typ/code/return.typ
+++ b/tests/typ/compiler/return.typ
diff --git a/tests/typ/style/set.typ b/tests/typ/compiler/set.typ
index fc5053b1..fc5053b1 100644
--- a/tests/typ/style/set.typ
+++ b/tests/typ/compiler/set.typ
diff --git a/tests/typ/text/shorthands.typ b/tests/typ/compiler/shorthand.typ
index 5c94dab0..5c94dab0 100644
--- a/tests/typ/text/shorthands.typ
+++ b/tests/typ/compiler/shorthand.typ
diff --git a/tests/typ/style/show-bare.typ b/tests/typ/compiler/show-bare.typ
index 8b8d0852..8b8d0852 100644
--- a/tests/typ/style/show-bare.typ
+++ b/tests/typ/compiler/show-bare.typ
diff --git a/tests/typ/style/show-node.typ b/tests/typ/compiler/show-node.typ
index 98f36f13..98f36f13 100644
--- a/tests/typ/style/show-node.typ
+++ b/tests/typ/compiler/show-node.typ
diff --git a/tests/typ/style/show-recursive.typ b/tests/typ/compiler/show-recursive.typ
index 91a295f2..91a295f2 100644
--- a/tests/typ/style/show-recursive.typ
+++ b/tests/typ/compiler/show-recursive.typ
diff --git a/tests/typ/style/show-selector.typ b/tests/typ/compiler/show-selector.typ
index 0e9823a5..0e9823a5 100644
--- a/tests/typ/style/show-selector.typ
+++ b/tests/typ/compiler/show-selector.typ
diff --git a/tests/typ/style/show-text.typ b/tests/typ/compiler/show-text.typ
index 124d2ed2..124d2ed2 100644
--- a/tests/typ/style/show-text.typ
+++ b/tests/typ/compiler/show-text.typ
diff --git a/tests/typ/code/spread.typ b/tests/typ/compiler/spread.typ
index ff661ead..ff661ead 100644
--- a/tests/typ/code/spread.typ
+++ b/tests/typ/compiler/spread.typ
diff --git a/tests/typ/code/while.typ b/tests/typ/compiler/while.typ
index 5dc5ae41..5dc5ae41 100644
--- a/tests/typ/code/while.typ
+++ b/tests/typ/compiler/while.typ
diff --git a/tests/typ/base/calc.typ b/tests/typ/compute/calc.typ
index 4ccefa22..4ccefa22 100644
--- a/tests/typ/base/calc.typ
+++ b/tests/typ/compute/calc.typ
diff --git a/tests/typ/base/color.typ b/tests/typ/compute/create.typ
index aecd86b8..462f06e9 100644
--- a/tests/typ/base/color.typ
+++ b/tests/typ/compute/create.typ
@@ -1,4 +1,4 @@
-// Test color creation functions and modification methods.
+// Test creation and conversion functions.
// Ref: false
---
@@ -21,27 +21,6 @@
#rect(fill: luma(80%))
---
-// Test gray color modification.
-#test(luma(20%).lighten(50%), luma(60%))
-#test(luma(80%).darken(20%), luma(63.9%))
-#test(luma(80%).negate(), luma(20%))
-
----
-// Test CMYK color conversion.
-// Ref: true
-#let c = cmyk(50%, 64%, 16%, 17%)
-#rect(width: 1cm, fill: cmyk(69%, 11%, 69%, 41%))
-#rect(width: 1cm, fill: c)
-#rect(width: 1cm, fill: c.negate())
-
-#for x in range(0, 11) {
- square(width: 9pt, fill: c.lighten(x * 10%))
-}
-#for x in range(0, 11) {
- square(width: 9pt, fill: c.darken(x * 10%))
-}
-
----
// Error for values that are out of range.
// Error: 11-14 must be between 0 and 255
#test(rgb(-30, 15, 50))
@@ -61,3 +40,16 @@
---
// Error: 21-26 expected integer or ratio, found boolean
#rgb(10%, 20%, 30%, false)
+
+---
+// Test conversion to string.
+#test(str(123), "123")
+#test(str(50.14), "50.14")
+#test(str(10 / 3).len() > 10, true)
+
+---
+// Error: 6-8 cannot convert content to string
+#str([])
+
+---
+#assert(range(2, 5) == (2, 3, 4))
diff --git a/tests/typ/base/data.typ b/tests/typ/compute/data.typ
index 96b12ff5..c1def7d5 100644
--- a/tests/typ/base/data.typ
+++ b/tests/typ/compute/data.typ
@@ -10,7 +10,7 @@
#table(columns: data(0).len(), ..cells)
---
-// Error: 6-16 file not found (searched at typ/base/nope.csv)
+// Error: 6-16 file not found (searched at typ/compute/nope.csv)
#csv("nope.csv")
---
diff --git a/tests/typ/base/eval.typ b/tests/typ/compute/foundations.typ
index 80235c0c..6fc93a75 100644
--- a/tests/typ/base/eval.typ
+++ b/tests/typ/compute/foundations.typ
@@ -1,4 +1,30 @@
-// Test the `eval` function.
+// Test foundational functions.
+// Ref: false
+
+---
+#test(type(1), "integer")
+#test(type(ltr), "direction")
+#test(type(10 / 3), "float")
+
+---
+#test(repr(ltr), "ltr")
+#test(repr((1, 2, false, )), "(1, 2, false)")
+
+---
+// Test failing assertions.
+// Error: 9-15 assertion failed
+#assert(1 == 2)
+
+---
+// Test failing assertions.
+// Error: 9-15 expected boolean, found string
+#assert("true")
+
+---
+// Test the `type` function.
+#test(type(1), "integer")
+#test(type(ltr), "direction")
+#test(type(10 / 3), "float")
---
#eval("_Hello" + " World!_")
diff --git a/tests/typ/base/blind.typ b/tests/typ/compute/utility.typ
index 17452dec..f042c769 100644
--- a/tests/typ/base/blind.typ
+++ b/tests/typ/compute/utility.typ
@@ -1,4 +1,4 @@
-// Test blind text.
+// Test integrated numbering patterns.
---
// Test basic call.
@@ -30,3 +30,15 @@
---
// Error: 7-9 missing argument: number of words
#lorem()
+
+---
+#for i in range(9) {
+ numbering(i, "* and ")
+ numbering(i, "I")
+ [ for #i]
+ parbreak()
+}
+
+---
+// Error: 12-14 must be at least zero
+#numbering(-1, "1")
diff --git a/tests/typ/layout/orphan-widow.typ b/tests/typ/layout/flow-orphan.typ
index 445b44e3..a51da2b2 100644
--- a/tests/typ/layout/orphan-widow.typ
+++ b/tests/typ/layout/flow-orphan.typ
@@ -1,4 +1,11 @@
-// Test widow and orphan prevention.
+// Test that a heading doesn't become an orphan.
+
+---
+#set page(height: 100pt)
+#lorem(12)
+
+= Introduction
+This is the start and it goes on.
---
#set page("a8", height: 150pt)
diff --git a/tests/typ/graphics/hide.typ b/tests/typ/layout/hide.typ
index a979b24f..a979b24f 100644
--- a/tests/typ/graphics/hide.typ
+++ b/tests/typ/layout/hide.typ
diff --git a/tests/typ/layout/orphan-heading.typ b/tests/typ/layout/orphan-heading.typ
deleted file mode 100644
index ef3de885..00000000
--- a/tests/typ/layout/orphan-heading.typ
+++ /dev/null
@@ -1,8 +0,0 @@
-// Test that a heading doesn't become an orphan.
-
----
-#set page(height: 100pt)
-#lorem(12)
-
-= Introduction
-This is the start and it goes on.
diff --git a/tests/typ/text/bidi.typ b/tests/typ/layout/par-bidi.typ
index 11c0cafa..11c0cafa 100644
--- a/tests/typ/text/bidi.typ
+++ b/tests/typ/layout/par-bidi.typ
diff --git a/tests/typ/text/indent.typ b/tests/typ/layout/par-indent.typ
index 8454dda5..8454dda5 100644
--- a/tests/typ/text/indent.typ
+++ b/tests/typ/layout/par-indent.typ
diff --git a/tests/typ/text/justify.typ b/tests/typ/layout/par-justify.typ
index e3d61322..e3d61322 100644
--- a/tests/typ/text/justify.typ
+++ b/tests/typ/layout/par-justify.typ
diff --git a/tests/typ/text/knuth.typ b/tests/typ/layout/par-knuth.typ
index 59349738..59349738 100644
--- a/tests/typ/text/knuth.typ
+++ b/tests/typ/layout/par-knuth.typ
diff --git a/tests/typ/text/plain.typ b/tests/typ/layout/par-simple.typ
index 34a2d626..34a2d626 100644
--- a/tests/typ/text/plain.typ
+++ b/tests/typ/layout/par-simple.typ
diff --git a/tests/typ/text/par.typ b/tests/typ/layout/par.typ
index 558059e9..558059e9 100644
--- a/tests/typ/text/par.typ
+++ b/tests/typ/layout/par.typ
diff --git a/tests/typ/text/repeat.typ b/tests/typ/layout/repeat.typ
index 13e99b51..13e99b51 100644
--- a/tests/typ/text/repeat.typ
+++ b/tests/typ/layout/repeat.typ
diff --git a/tests/typ/graphics/transform.typ b/tests/typ/layout/transform.typ
index 2dde626b..2dde626b 100644
--- a/tests/typ/graphics/transform.typ
+++ b/tests/typ/layout/transform.typ
diff --git a/tests/typ/layout/math.typ b/tests/typ/math/simple.typ
index 55a853cf..55a853cf 100644
--- a/tests/typ/layout/math.typ
+++ b/tests/typ/math/simple.typ
diff --git a/tests/typ/style/document.typ b/tests/typ/meta/document.typ
index 1fcb8109..1fcb8109 100644
--- a/tests/typ/style/document.typ
+++ b/tests/typ/meta/document.typ
diff --git a/tests/typ/text/link.typ b/tests/typ/meta/link.typ
index 8c3e6ddd..8c3e6ddd 100644
--- a/tests/typ/text/link.typ
+++ b/tests/typ/meta/link.typ
diff --git a/tests/typ/text/case.typ b/tests/typ/text/case.typ
new file mode 100644
index 00000000..75574f21
--- /dev/null
+++ b/tests/typ/text/case.typ
@@ -0,0 +1,12 @@
+// Test the `upper` and `lower` functions.
+// Ref: false
+
+---
+#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 content, found integer
+#upper(1)
diff --git a/tests/typ/text/emph-strong.typ b/tests/typ/text/emphasis.typ
index cd2191cc..cd2191cc 100644
--- a/tests/typ/text/emph-strong.typ
+++ b/tests/typ/text/emphasis.typ
diff --git a/tests/typ/text/code.typ b/tests/typ/text/raw-highlight.typ
index d89f1c05..d89f1c05 100644
--- a/tests/typ/text/code.typ
+++ b/tests/typ/text/raw-highlight.typ
diff --git a/tests/typ/text/shifts.typ b/tests/typ/text/shift.typ
index 01a83f6e..01a83f6e 100644
--- a/tests/typ/text/shifts.typ
+++ b/tests/typ/text/shift.typ
diff --git a/tests/typ/text/whitespace.typ b/tests/typ/text/space.typ
index 8dcc59e3..8dcc59e3 100644
--- a/tests/typ/text/whitespace.typ
+++ b/tests/typ/text/space.typ
diff --git a/tests/typ/graphics/image.typ b/tests/typ/visualize/image.typ
index e97365cd..6a2c37e1 100644
--- a/tests/typ/graphics/image.typ
+++ b/tests/typ/visualize/image.typ
@@ -51,7 +51,7 @@ A #image("/res/tiger.jpg", height: 1cm, width: 80%) B
#image("/res/pattern.svg")
---
-// Error: 8-29 file not found (searched at typ/graphics/path/does/not/exist)
+// Error: 8-29 file not found (searched at typ/visualize/path/does/not/exist)
#image("path/does/not/exist")
---
diff --git a/tests/typ/graphics/line.typ b/tests/typ/visualize/line.typ
index 2cb2fc9c..2cb2fc9c 100644
--- a/tests/typ/graphics/line.typ
+++ b/tests/typ/visualize/line.typ
diff --git a/tests/typ/graphics/shape-aspect.typ b/tests/typ/visualize/shape-aspect.typ
index f2dd9b51..f2dd9b51 100644
--- a/tests/typ/graphics/shape-aspect.typ
+++ b/tests/typ/visualize/shape-aspect.typ
diff --git a/tests/typ/graphics/shape-circle.typ b/tests/typ/visualize/shape-circle.typ
index 13ff67de..13ff67de 100644
--- a/tests/typ/graphics/shape-circle.typ
+++ b/tests/typ/visualize/shape-circle.typ
diff --git a/tests/typ/graphics/shape-ellipse.typ b/tests/typ/visualize/shape-ellipse.typ
index ba4d0d0a..ba4d0d0a 100644
--- a/tests/typ/graphics/shape-ellipse.typ
+++ b/tests/typ/visualize/shape-ellipse.typ
diff --git a/tests/typ/graphics/shape-fill-stroke.typ b/tests/typ/visualize/shape-fill-stroke.typ
index d14d0981..d14d0981 100644
--- a/tests/typ/graphics/shape-fill-stroke.typ
+++ b/tests/typ/visualize/shape-fill-stroke.typ
diff --git a/tests/typ/graphics/shape-rect.typ b/tests/typ/visualize/shape-rect.typ
index 94686da2..94686da2 100644
--- a/tests/typ/graphics/shape-rect.typ
+++ b/tests/typ/visualize/shape-rect.typ
diff --git a/tests/typ/graphics/shape-square.typ b/tests/typ/visualize/shape-square.typ
index 622fa9c8..622fa9c8 100644
--- a/tests/typ/graphics/shape-square.typ
+++ b/tests/typ/visualize/shape-square.typ