diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/layouting.rs | 30 | ||||
| -rw-r--r-- | tests/layouts/align.typ | 3 | ||||
| -rw-r--r-- | tests/layouts/coma.typ | 3 | ||||
| -rw-r--r-- | tests/layouts/pagebreaks.typ | 4 | ||||
| -rw-r--r-- | tests/layouts/styles.typ | 3 |
5 files changed, 13 insertions, 30 deletions
diff --git a/tests/layouting.rs b/tests/layouting.rs index 27999d43..933335cc 100644 --- a/tests/layouting.rs +++ b/tests/layouting.rs @@ -9,8 +9,6 @@ use regex::{Regex, Captures}; use typst::export::pdf::PdfExporter; use typst::layout::LayoutAction; use typst::toddle::query::FileSystemFontProvider; -use typst::size::{Size, Size2D, SizeBox}; -use typst::style::PageStyle; use typst::Typesetter; const CACHE_DIR: &str = "tests/cache"; @@ -62,19 +60,12 @@ fn main() { fn test(name: &str, src: &str) { println!("Testing: {}.", name); - let (src, size) = preprocess(src); + let src = preprocess(src); let mut typesetter = Typesetter::new(); let provider = FileSystemFontProvider::from_listing("fonts/fonts.toml").unwrap(); typesetter.add_font_provider(provider.clone()); - if let Some(dimensions) = size { - typesetter.set_page_style(PageStyle { - dimensions, - margins: SizeBox::zero() - }); - } - // Make run warm. #[cfg(not(debug_assertions))] let warmup_start = Instant::now(); #[cfg(not(debug_assertions))] typesetter.typeset(&src).unwrap(); @@ -138,24 +129,11 @@ fn test(name: &str, src: &str) { exporter.export(&layouts, typesetter.loader(), file).unwrap(); } -fn preprocess<'a>(src: &'a str) -> (String, Option<Size2D>) { +fn preprocess<'a>(src: &'a str) -> String { let include_regex = Regex::new(r"\{include:((.|\.|\-)*)\}").unwrap(); let lorem_regex = Regex::new(r"\{lorem:(\d*)\}").unwrap(); - let size_regex = Regex::new(r"\{(size:(([\d\w]*)\sx\s([\d\w]*)))\}").unwrap(); - - let mut size = None; - - let mut preprocessed = size_regex.replace_all(&src, |cap: &Captures| { - let width_str = cap.get(3).unwrap().as_str(); - let height_str = cap.get(4).unwrap().as_str(); - let width = width_str.parse::<Size>().unwrap(); - let height = height_str.parse::<Size>().unwrap(); - - size = Some(Size2D::new(width, height)); - - "".to_string() - }).to_string(); + let mut preprocessed = src.to_string(); let mut changed = true; while changed { @@ -179,7 +157,7 @@ fn preprocess<'a>(src: &'a str) -> (String, Option<Size2D>) { generate_lorem(num_words) }).to_string(); - (preprocessed, size) + preprocessed } fn generate_lorem(num_words: usize) -> String { diff --git a/tests/layouts/align.typ b/tests/layouts/align.typ index e993a43b..34c2f16f 100644 --- a/tests/layouts/align.typ +++ b/tests/layouts/align.typ @@ -1,4 +1,5 @@ -{size:150pt x 215pt} +[page.size: width=150pt, height=215pt] +[page.margins: 0pt] // ---------------------------------- // // Without newline in between. diff --git a/tests/layouts/coma.typ b/tests/layouts/coma.typ index e9fb0994..237b24f4 100644 --- a/tests/layouts/coma.typ +++ b/tests/layouts/coma.typ @@ -1,4 +1,5 @@ -{size:420pt x 300pt} +[page.size: width=450pt, height=300pt] +[page.margins: 1cm] [box][ *Technical University Berlin* [n] diff --git a/tests/layouts/pagebreaks.typ b/tests/layouts/pagebreaks.typ index 6252ecb9..4d3c1843 100644 --- a/tests/layouts/pagebreaks.typ +++ b/tests/layouts/pagebreaks.typ @@ -1,4 +1,6 @@ -{size:150pt x 200pt} +[page.size: width=150pt, height=200pt] +[page.margins: 0pt] + {lorem:100} [page.break] diff --git a/tests/layouts/styles.typ b/tests/layouts/styles.typ index 25057d8a..63745026 100644 --- a/tests/layouts/styles.typ +++ b/tests/layouts/styles.typ @@ -1,4 +1,5 @@ -{size:250pt x 500pt} +[page.size: width=250pt, height=300pt] +[page.margins: 10pt] _Emoji:_ Hello World! 🌍 |
