Preview SIVP with placeholders for PDF figures
This commit is contained in:
1 parent
ac3e42a201
commit
82542740e7
5 files changed
+21
-5
No files matched your search
@@ -520,7 +520,7 @@ advisory breaks, starred `\vspace`/`\hspace`, `center`, `\hrule`, `\fbox`,
|
|||||||
|
|
||||||
## New-template compatibility
|
## 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)
|
## Capability matrix (current)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
+1
-1
@@ -147,4 +147,4 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
|||||||
since printpdf 0.3.4 has no annotation API.
|
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.
|
- 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`).
|
||||||
@@ -782,8 +782,21 @@ fn layout_figure(
|
|||||||
math_layout: &MathLayoutEnvironment,
|
math_layout: &MathLayoutEnvironment,
|
||||||
cache: &mut ParagraphLayoutCache,
|
cache: &mut ParagraphLayoutCache,
|
||||||
) -> Option<PositionedFigure> {
|
) -> Option<PositionedFigure> {
|
||||||
let image_path = resolved_image_path(source_dir, path);
|
let requested_path = resolved_image_path(source_dir, path);
|
||||||
let (pixel_width, pixel_height) = image::image_dimensions(&image_path).ok()?;
|
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(
|
let (scale_x, scale_y) = image_scale(
|
||||||
options,
|
options,
|
||||||
pixel_width,
|
pixel_width,
|
||||||
|
|||||||
+4
-1
@@ -1852,8 +1852,11 @@ fn geometry_text_sets_the_text_block() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[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 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()
|
let pdf = CompilerSession::default()
|
||||||
.compile(&source, "projects/_sivp__/sn-article.tex")
|
.compile(&source, "projects/_sivp__/sn-article.tex")
|
||||||
.expect("SIVP PDF");
|
.expect("SIVP PDF");
|
||||||
|
|||||||
Reference in new issue
Block a user