Preview SIVP with placeholders for PDF figures

This commit is contained in:
gloamxun committed 2026-10-20 00:37:56 +08:00
1 parent ac3e42a201
commit 82542740e7
5 files changed
+21 -5

No files matched your search

+1 -1
View File
@@ -520,7 +520,7 @@ advisory breaks, starred `\vspace`/`\hspace`, `center`, `\hrule`, `\fbox`,
## New-template compatibility
The SIVP class (`sn-jnl.cls`) loads completely and `sn-article.tex` exports a 12-page PDF; the Huawei E fragment (`projects/e/问题一.tex`) compiles to 16 A4 pages. This required generic TeX conditionals (`\if`, `\ifx`), `\newcount`/`\newdimen`, `\char`, 64-bit dimension scanning, `tabular*`/`tabularx` environments, and the math accent/operator/arrow vocabulary used by both documents. Both are covered by integration tests.
The SIVP class (`sn-jnl.cls`) loads completely and `sn-article.tex` previews and exports a 16-page PDF; the Huawei E fragment (`projects/e/问题一.tex`) compiles to 16 A4 pages. This required generic TeX conditionals (`\if`, `\ifx`), `\newcount`/`\newdimen`, `\char`, 64-bit dimension scanning, `tabular*`/`tabularx` environments, and the math accent/operator/arrow vocabulary used by both documents. Both are covered by integration tests.
## Capability matrix (current)
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

+1 -1
View File
@@ -147,4 +147,4 @@ See `docs/ROADMAP.md` for concrete implementation plans.
since printpdf 0.3.4 has no annotation API.
- Fonts: bundled reserved-glyph subsets in `assets/fonts-subset/` are used when the document charset is covered; arXiv PDF is about 0.29 MB.
- New-template compatibility: the SIVP class file loads fully and `sn-article.tex` exports a 12-page PDF (live preview falls back on unsupported layout features); the Huawei E fragment compiles to 16 A4 pages. Generic support added for TeX `\if`/`\ifx`, `\newcount`, `\newdimen`, `\char`, `tabular*`/`tabularx`, math accents/operators/arrows, a 64-bit dimension scanner, and `geometry` `text={width,height}` blocks. Both fixtures are regression tests (`sivp_project_exports_a_pdf`, `e_fixture_compiles`).
- New-template compatibility: the SIVP class file loads fully and `sn-article.tex` previews and exports a 16-page PDF (PDF figures render as placeholders); the Huawei E fragment compiles to 16 A4 pages. Generic support added for TeX `\if`/`\ifx`, `\newcount`, `\newdimen`, `\char`, `tabular*`/`tabularx`, math accents/operators/arrows, a 64-bit dimension scanner, and `geometry` `text={width,height}` blocks. Both fixtures are regression tests (`sivp_project_previews_and_exports_a_pdf`, `e_fixture_compiles`).
+15 -2
View File
@@ -782,8 +782,21 @@ fn layout_figure(
math_layout: &MathLayoutEnvironment,
cache: &mut ParagraphLayoutCache,
) -> Option<PositionedFigure> {
let image_path = resolved_image_path(source_dir, path);
let (pixel_width, pixel_height) = image::image_dimensions(&image_path).ok()?;
let requested_path = resolved_image_path(source_dir, path);
let is_pdf = requested_path
.extension()
.is_some_and(|extension| extension.eq_ignore_ascii_case("pdf"));
let (image_path, pixel_width, pixel_height) = match image::image_dimensions(&requested_path) {
Ok((width, height)) => (requested_path, width, height),
Err(_) if is_pdf => {
let placeholder = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("assets")
.join("figure-placeholder.png");
let (width, height) = image::image_dimensions(&placeholder).ok()?;
(placeholder, width, height)
}
Err(_) => return None,
};
let (scale_x, scale_y) = image_scale(
options,
pixel_width,
+4 -1
View File
@@ -1852,8 +1852,11 @@ fn geometry_text_sets_the_text_block() {
}
#[test]
fn sivp_project_exports_a_pdf() {
fn sivp_project_previews_and_exports_a_pdf() {
let source = std::fs::read_to_string("projects/_sivp__/sn-article.tex").unwrap();
let value = fresh_preview(&source, "projects/_sivp__/sn-article.tex");
assert_eq!(value["status"], "ok", "{value}");
assert!(!pages(&value).is_empty());
let pdf = CompilerSession::default()
.compile(&source, "projects/_sivp__/sn-article.tex")
.expect("SIVP PDF");