Handle parbox, orcidlink and a bare hrule
The last three corpus warnings: \parbox becomes an \mbox so the existing box
handling keeps its content (width wrapping is not modelled); \orcidlink{id}
becomes a hyperlink labelled ORCID; and a standalone \hrule becomes the same
here-float rule block as \rule, with the width left unset so the page builder
uses the current line width and a 0.4pt height.
The corpus sweep now reports 0 warnings for examples/hello.tex, boxes.tex,
compat.tex and the arXiv template.
A test previews parbox content, the ORCID link label and a bare hrule with no
warnings and no leaked commands.
This commit is contained in:
1 parent
93ecf76ea3
commit
65a132d7b1
3 files changed
+128
-7
No files matched your search
@@ -49,7 +49,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
|||||||
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
||||||
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
||||||
PDF opt-in with `?engine=route-d`; flat `/preview` and project previews now
|
PDF opt-in with `?engine=route-d`; flat `/preview` and project previews now
|
||||||
prefer route-D with a v1 fallback). 1010 workspace tests are green and no oracle
|
prefer route-D with a v1 fallback). 1011 workspace tests are green and no oracle
|
||||||
fixture is ignored. Preview JSON also carries a `warnings` array naming
|
fixture is ignored. Preview JSON also carries a `warnings` array naming
|
||||||
environments route-D cannot lay out and control words that survived layout, so
|
environments route-D cannot lay out and control words that survived layout, so
|
||||||
unsupported source is reported instead of being silently typeset.
|
unsupported source is reported instead of being silently typeset.
|
||||||
|
|||||||
+5
-6
@@ -370,7 +370,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
|
|||||||
|
|
||||||
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
||||||
|
|
||||||
The crate currently has 437 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1010 tests (437 route-D unit, 383 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 62 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; the flat response carries `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4.
|
The crate currently has 437 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1011 tests (437 route-D unit, 384 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 62 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; the flat response carries `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4.
|
||||||
|
|
||||||
### M0 incremental demo
|
### M0 incremental demo
|
||||||
|
|
||||||
@@ -520,14 +520,13 @@ deliberately open rather than approximated:
|
|||||||
|
|
||||||
## Limits and remaining gaps
|
## Limits and remaining gaps
|
||||||
|
|
||||||
The suite currently stands at 1010 passing tests, with the workspace clean.
|
The suite currently stands at 1011 passing tests, with the workspace clean.
|
||||||
Route-D serves both flat `/preview` and project preview/PDF requests by default
|
Route-D serves both flat `/preview` and project preview/PDF requests by default
|
||||||
(automatic v1 fallback; `?engine=v1` or `TEXRRA_ENGINE=v1` opts out). The
|
(automatic v1 fallback; `?engine=v1` or `TEXRRA_ENGINE=v1` opts out). The
|
||||||
objective's areas are implemented to the limits below; complex-script shaping is
|
objective's areas are implemented to the limits below; complex-script shaping is
|
||||||
outside pdfLaTeX's own scope. A corpus sweep of `examples/` and the arXiv
|
outside pdfLaTeX's own scope. A corpus sweep of the three `examples/` documents
|
||||||
fixture reports 0 warnings for the arXiv template and only `\hrule`, `\parbox`
|
and the arXiv template reports 0 warnings for all four (guillemets, inline
|
||||||
and `\orcidlink` left in the examples (inline spacing and guillemets are
|
spacing, `\parbox`, `\orcidlink` and bare `\hrule` are handled).
|
||||||
handled).
|
|
||||||
|
|
||||||
Status by area: service default is done (flat and project endpoints); saveboxes
|
Status by area: service default is done (flat and project endpoints); saveboxes
|
||||||
are measured and frozen apart from image-only bodies; tables support real nested
|
are measured and frozen apart from image-only bodies; tables support real nested
|
||||||
|
|||||||
+122
@@ -8611,6 +8611,27 @@ fn verse_block(raw: &str) -> Option<Vec<SourceParagraph>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rule_block(raw: &str) -> Option<SourceParagraph> {
|
fn rule_block(raw: &str) -> Option<SourceParagraph> {
|
||||||
|
if raw.trim() == "\\hrule" {
|
||||||
|
let mut block = parse_paragraph("");
|
||||||
|
block.float = Some(FloatSpec {
|
||||||
|
kind: FloatKind::Figure,
|
||||||
|
placement: FloatPlacement::Here,
|
||||||
|
width: None,
|
||||||
|
height: Some(ImageLength::Absolute(26_214)),
|
||||||
|
scale: None,
|
||||||
|
keep_aspectratio: false,
|
||||||
|
caption: None,
|
||||||
|
caption_short: None,
|
||||||
|
list_caption: None,
|
||||||
|
caption_starred: false,
|
||||||
|
image: None,
|
||||||
|
table: None,
|
||||||
|
});
|
||||||
|
block.space_before = 6 * SCALE;
|
||||||
|
block.space_stretch = 0;
|
||||||
|
block.space_shrink = 0;
|
||||||
|
return Some(block);
|
||||||
|
}
|
||||||
let rest = raw.trim().strip_prefix("\\rule")?;
|
let rest = raw.trim().strip_prefix("\\rule")?;
|
||||||
let mut rest = rest.trim_start();
|
let mut rest = rest.trim_start();
|
||||||
if rest.starts_with('[') {
|
if rest.starts_with('[') {
|
||||||
@@ -9656,6 +9677,79 @@ fn strip_noop_commands(text: &str) -> String {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rewrite `\parbox[pos]{width}[..][..]{body}` into an `\mbox` so the existing
|
||||||
|
/// box handling keeps the content unbreakable (width wrapping is not modelled).
|
||||||
|
fn expand_parbox(text: &str) -> String {
|
||||||
|
let mut output = String::new();
|
||||||
|
let mut rest = text;
|
||||||
|
while let Some(position) = rest.find("\\parbox") {
|
||||||
|
output.push_str(&rest[..position]);
|
||||||
|
let after = &rest[position + "\\parbox".len()..];
|
||||||
|
if after
|
||||||
|
.chars()
|
||||||
|
.next()
|
||||||
|
.is_some_and(|character| character.is_ascii_alphabetic())
|
||||||
|
{
|
||||||
|
output.push_str("\\parbox");
|
||||||
|
rest = after;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let mut cursor = after.trim_start();
|
||||||
|
if let Some(stripped) = cursor.strip_prefix('[')
|
||||||
|
&& let Some((_, tail)) = stripped.split_once(']')
|
||||||
|
{
|
||||||
|
cursor = tail.trim_start();
|
||||||
|
}
|
||||||
|
let Some((_width, used)) = braced_group(cursor) else {
|
||||||
|
output.push_str("\\parbox");
|
||||||
|
rest = after;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
cursor = cursor[used..].trim_start();
|
||||||
|
for _ in 0..2 {
|
||||||
|
if let Some(stripped) = cursor.strip_prefix('[')
|
||||||
|
&& let Some((_, tail)) = stripped.split_once(']')
|
||||||
|
{
|
||||||
|
cursor = tail.trim_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let Some((body, used)) = braced_group(cursor) else {
|
||||||
|
output.push_str("\\parbox");
|
||||||
|
rest = after;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
output.push_str("\\mbox{");
|
||||||
|
output.push_str(body);
|
||||||
|
output.push('}');
|
||||||
|
rest = &cursor[used..];
|
||||||
|
}
|
||||||
|
output.push_str(rest);
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rewrite `\orcidlink{id}` into a hyperlink labelled ORCID.
|
||||||
|
fn expand_orcidlink(text: &str) -> String {
|
||||||
|
let mut output = String::new();
|
||||||
|
let mut rest = text;
|
||||||
|
while let Some(position) = rest.find("\\orcidlink") {
|
||||||
|
output.push_str(&rest[..position]);
|
||||||
|
let after = &rest[position + "\\orcidlink".len()..];
|
||||||
|
let trimmed = after.trim_start();
|
||||||
|
let Some((id, used)) = braced_group(trimmed) else {
|
||||||
|
output.push_str("\\orcidlink");
|
||||||
|
rest = after;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
output.push_str(&format!(
|
||||||
|
"\\href{{https://orcid.org/{}}}{{ORCID}}",
|
||||||
|
id.trim()
|
||||||
|
));
|
||||||
|
rest = &trimmed[used..];
|
||||||
|
}
|
||||||
|
output.push_str(rest);
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove vertical spacing commands that survived into running text; the
|
/// Remove vertical spacing commands that survived into running text; the
|
||||||
/// standalone forms already became vertical glue items earlier.
|
/// standalone forms already became vertical glue items earlier.
|
||||||
fn strip_inline_spacing(text: &str) -> String {
|
fn strip_inline_spacing(text: &str) -> String {
|
||||||
@@ -12246,6 +12340,8 @@ fn build_document_with_labels(
|
|||||||
text = rest.trim_start().to_string();
|
text = rest.trim_start().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text = expand_parbox(&text);
|
||||||
|
text = expand_orcidlink(&text);
|
||||||
text = strip_box_commands(&text);
|
text = strip_box_commands(&text);
|
||||||
text = expand_math_spaces(&text);
|
text = expand_math_spaces(&text);
|
||||||
text = expand_ensuremath(&text);
|
text = expand_ensuremath(&text);
|
||||||
@@ -16177,6 +16273,32 @@ A definition.
|
|||||||
assert!(!text.contains("makeatletter"), "{text}");
|
assert!(!text.contains("makeatletter"), "{text}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parbox_orcid_and_hrule_are_handled() {
|
||||||
|
let source = "\\documentclass{article}\n\\begin{document}\n\n\\parbox{60mm}{Parbox words} and \\orcidlink{0000-0002-1825-0097}.\n\n\\hrule\n\nAfter.\n\n\\end{document}\n";
|
||||||
|
let json = preview_json(source).expect("preview");
|
||||||
|
let value: serde_json::Value = serde_json::from_str(&json).expect("JSON");
|
||||||
|
assert_eq!(
|
||||||
|
value["warnings"].as_array().map(Vec::len),
|
||||||
|
Some(0),
|
||||||
|
"{}",
|
||||||
|
value["warnings"]
|
||||||
|
);
|
||||||
|
let svg = value["pages"][0]["svg"].as_str().expect("svg");
|
||||||
|
let text: String = svg
|
||||||
|
.split('>')
|
||||||
|
.filter_map(|piece| piece.split('<').next())
|
||||||
|
.collect::<String>()
|
||||||
|
.split_whitespace()
|
||||||
|
.collect();
|
||||||
|
assert!(text.contains("Parboxwords"), "{text}");
|
||||||
|
assert!(text.contains("ORCID"), "{text}");
|
||||||
|
assert!(text.contains("After."), "{text}");
|
||||||
|
assert!(!text.contains("parbox"), "{text}");
|
||||||
|
assert!(!text.contains("orcidlink"), "{text}");
|
||||||
|
assert!(!text.contains("hrule"), "{text}");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inline_spacing_and_guillemets_are_clean() {
|
fn inline_spacing_and_guillemets_are_clean() {
|
||||||
let source = "\\documentclass{article}\n\\begin{document}\n\nA\\vspace*{6pt}B \\smallskip C\\bigskip D\\samepage \\guillemotleft x\\guillemotright\n\n\\end{document}\n";
|
let source = "\\documentclass{article}\n\\begin{document}\n\nA\\vspace*{6pt}B \\smallskip C\\bigskip D\\samepage \\guillemotleft x\\guillemotright\n\n\\end{document}\n";
|
||||||
|
|||||||
Reference in new issue
Block a user