Cover preprint metadata spacing
This commit is contained in:
1 parent
6f71414d69
commit
7c4edbb1f1
2 files changed
+42
-1
No files matched your search
+1
-1
@@ -119,7 +119,7 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
||||
- ASCII-only documents use non-embedded Base-14 Times/Courier (arXiv PDF is
|
||||
about 0.7 MB); documents with accented/non-WinAnsi text embed Liberation
|
||||
faces. Tables use natural column widths and centered rules.
|
||||
- `cargo fmt --check` passes; `cargo test --offline` (51 tests: 47 compiler
|
||||
- `cargo fmt --check` passes; `cargo test --offline` (52 tests: 48 compiler
|
||||
integration tests + 4 server tests) covers the three examples, the arXiv
|
||||
fixture, figure/table floats (top and bottom), newpage, page styles and `\thispagestyle`, SVG/PDF output,
|
||||
project API, static frontend assets, path traversal, the legacy
|
||||
|
||||
@@ -507,6 +507,47 @@ fn small_caps_uses_reduced_uppercase_glyphs() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preprint_metadata_spacing_matches_reference() {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("fixtures")
|
||||
.join("arxiv-template")
|
||||
.join("template.tex");
|
||||
let source = std::fs::read_to_string(&path).expect("read arXiv fixture");
|
||||
let value = fresh_preview(&source, &path.to_string_lossy());
|
||||
assert_eq!(value["status"], "ok", "{}", value["message"]);
|
||||
let svg = page_svg(&value, 0);
|
||||
let title = text_y(&svg, "STYLE");
|
||||
let author = text_y_contains(&svg, "Hippocampus");
|
||||
let date = text_y(&svg, "October");
|
||||
// Measured against the XeLaTeX reference PDF (1 pt = 0.3528 mm).
|
||||
assert!(
|
||||
(author - title - 25.1).abs() < 1.0,
|
||||
"title-to-author gap: {}",
|
||||
author - title
|
||||
);
|
||||
assert!(
|
||||
(date - author - 29.4).abs() < 1.0,
|
||||
"author-to-date gap: {}",
|
||||
date - author
|
||||
);
|
||||
}
|
||||
|
||||
fn text_y_contains(svg: &str, needle: &str) -> f64 {
|
||||
let index = svg
|
||||
.find(needle)
|
||||
.unwrap_or_else(|| panic!("missing text element containing `{needle}`"));
|
||||
let start = svg[..index]
|
||||
.rfind("<text ")
|
||||
.unwrap_or_else(|| panic!("no text element before `{needle}`"));
|
||||
let tag = &svg[start..index];
|
||||
tag.split("y=\"")
|
||||
.nth(1)
|
||||
.and_then(|rest| rest.split('\"').next())
|
||||
.and_then(|value| value.parse::<f64>().ok())
|
||||
.unwrap_or_else(|| panic!("text element for `{needle}` has no y coordinate"))
|
||||
}
|
||||
|
||||
fn text_y(svg: &str, needle: &str) -> f64 {
|
||||
let closing = format!("{needle}</text>");
|
||||
let index = svg
|
||||
|
||||
Reference in new issue
Block a user