From 57e7caffad640d22b91ad0aed4bc3dfde850647d Mon Sep 17 00:00:00 2001 From: Grant Lemons Date: Wed, 15 Jan 2025 16:30:46 -0700 Subject: [PATCH] tests: rename typst tests and add simplified document --- harper-typst/tests/run_tests.rs | 5 +- ...complex_typst.typ => complex_document.typ} | 0 ...typ => complex_with_spelling_mistakes.typ} | 0 .../test_sources/simplified_document.typ | 55 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) rename harper-typst/tests/test_sources/{complex_typst.typ => complex_document.typ} (100%) rename harper-typst/tests/test_sources/{typst_spelling_mistakes.typ => complex_with_spelling_mistakes.typ} (100%) create mode 100644 harper-typst/tests/test_sources/simplified_document.typ diff --git a/harper-typst/tests/run_tests.rs b/harper-typst/tests/run_tests.rs index c9c15f73..a9acc4df 100644 --- a/harper-typst/tests/run_tests.rs +++ b/harper-typst/tests/run_tests.rs @@ -37,5 +37,6 @@ macro_rules! create_test { }; } -create_test!(complex_typst.typ, 0); -create_test!(typst_spelling_mistakes.typ, 4); +create_test!(complex_document.typ, 0); +create_test!(simplified_document.typ, 0); +create_test!(complex_with_spelling_mistakes.typ, 4); diff --git a/harper-typst/tests/test_sources/complex_typst.typ b/harper-typst/tests/test_sources/complex_document.typ similarity index 100% rename from harper-typst/tests/test_sources/complex_typst.typ rename to harper-typst/tests/test_sources/complex_document.typ diff --git a/harper-typst/tests/test_sources/typst_spelling_mistakes.typ b/harper-typst/tests/test_sources/complex_with_spelling_mistakes.typ similarity index 100% rename from harper-typst/tests/test_sources/typst_spelling_mistakes.typ rename to harper-typst/tests/test_sources/complex_with_spelling_mistakes.typ diff --git a/harper-typst/tests/test_sources/simplified_document.typ b/harper-typst/tests/test_sources/simplified_document.typ new file mode 100644 index 00000000..cd22f9be --- /dev/null +++ b/harper-typst/tests/test_sources/simplified_document.typ @@ -0,0 +1,55 @@ +#let template( + title: "Default Title", + authors: ("Author 1", "Author 2"), + abstract: [*This is content*], + body, +) = { + set par(justify: true) + set page( + paper: "us-letter", + columns: 2, + number-align: top, + numbering: (..n) => if n.pos().first() > 1 { + n.pos().map(str).join(" of ") + h(1fr) + title + }, + ) + + place( + top + center, + float: true, + scope: "parent", + clearance: 2em, + )[ + #show heading: set text(17pt) + = #title + + #let authors-line = if authors.len() > 3 { + // "et al." isn't parsed properly, but this isn't the fault of the Typst + // parser. + // authors-max3.push("et al.") + authors => authors.join(", ") + } else { + authors => authors.join(", ", last: ", and ") + } + #emph(authors-line(authors.slice(0, calc.min(authors.len(), 3)))) + + #par(justify: false)[ + *Abstract* \ + #abstract + ] + ] + + body +} + +#show: template.with( + title: "A fluid dynamic model for glacier flow", + authors: ("Grant Lemons", "John Doe", "Jane Doe"), + abstract: lorem(80), +) + += Introduction +#lorem(300) + += Related Work +#lorem(200)