Make route-D the default flat preview engine
POST /preview served the v1 pipeline while route-D lived behind /api/route-d and the project engine switch. Try route_d::preview_json first and keep the v1 compiler as the fallback when route-D rejects the source; ?engine=v1 forces the old path and the project endpoints are unchanged. Both paths now answer with an X-Preview-Engine header (route-d or v1) so the choice is observable, and the server test helper compares header names case-insensitively because tiny-http lowercases them. A server test posts a document and checks route-d by default plus v1 when the query asks for it.
This commit is contained in:
1 parent
621a8abb92
commit
a56d441513
4 files changed
+59
-11
No files matched your search
@@ -48,7 +48,8 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
|||||||
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
||||||
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`). 992 workspace tests are green and no oracle
|
PDF opt-in with `?engine=route-d`; flat `/preview` now prefers route-D with a v1
|
||||||
|
fallback). 993 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.
|
||||||
@@ -491,8 +492,9 @@ Each goal keeps `cargo fmt`, `cargo test`, `cargo build --release` green, update
|
|||||||
## Handoff (round 150/150)
|
## Handoff (round 150/150)
|
||||||
|
|
||||||
Route-D currently passes **928** workspace tests and is pushed at `b191f7d`.
|
Route-D currently passes **928** workspace tests and is pushed at `b191f7d`.
|
||||||
The default service path is still v1; route-D is selected with `?engine=route-d`
|
The flat `/preview` endpoint now tries route-D first and falls back to v1 (pass
|
||||||
or `TEXRRA_ENGINE=route-d`. To continue the programme:
|
`?engine=v1` to force v1); project previews still select route-D with
|
||||||
|
`?engine=route-d` or `TEXRRA_ENGINE=route-d`. To continue the programme:
|
||||||
|
|
||||||
1. Run `cargo fmt --all -- --check` and `cargo test --workspace --offline`
|
1. Run `cargo fmt --all -- --check` and `cargo test --workspace --offline`
|
||||||
from `engine/` before every change; pdfLaTeX oracles skip automatically when
|
from `engine/` before every change; pdfLaTeX oracles skip automatically when
|
||||||
|
|||||||
+6
-4
@@ -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 992 tests (437 route-D unit, 367 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path.
|
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 993 tests (437 route-D unit, 367 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 61 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint now tries route-D first and falls back to v1 on error (`?engine=v1` forces v1; the `X-Preview-Engine` response header names the engine used), while the project preview/PDF endpoints still follow `TEXRRA_ENGINE`.
|
||||||
|
|
||||||
### M0 incremental demo
|
### M0 incremental demo
|
||||||
|
|
||||||
@@ -520,9 +520,11 @@ deliberately open rather than approximated:
|
|||||||
|
|
||||||
## Remaining gaps at round 148
|
## Remaining gaps at round 148
|
||||||
|
|
||||||
The suite currently stands at 928 passing tests, with the workspace clean and
|
The suite currently stands at 928 passing tests, with the workspace clean.
|
||||||
route-D's default path still v1 behind `?engine=route-d`/`TEXRRA_ENGINE`. The
|
Route-D now serves flat `/preview` requests by default (automatic v1 fallback,
|
||||||
honest open items against the "feature-complete LaTeX compiler" objective are:
|
`?engine=v1` opt-out), while project previews still follow
|
||||||
|
`?engine=route-d`/`TEXRRA_ENGINE`. The honest open items against the
|
||||||
|
"feature-complete LaTeX compiler" objective are:
|
||||||
|
|
||||||
- **Macro engine scope**: `\def`-style definitions, registers, conditionals,
|
- **Macro engine scope**: `\def`-style definitions, registers, conditionals,
|
||||||
`\csname`, `\expandafter`, delimited parameters and `\edef` are executed
|
`\csname`, `\expandafter`, delimited parameters and `\edef` are executed
|
||||||
|
|||||||
+24
-1
@@ -231,8 +231,12 @@ fn handle_request(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let force_v1 = url.contains("engine=v1");
|
||||||
|
if !force_v1 && let Ok(json) = route_d::preview_json(&source) {
|
||||||
|
return respond_json_engine(request, 200, &json, "route-d");
|
||||||
|
}
|
||||||
match compiler.preview_json(&source, &input_path.display().to_string()) {
|
match compiler.preview_json(&source, &input_path.display().to_string()) {
|
||||||
Ok(json) => respond(request, 200, "application/json; charset=utf-8", &json),
|
Ok(json) => respond_json_engine(request, 200, &json, "v1"),
|
||||||
Err(error) => respond(
|
Err(error) => respond(
|
||||||
request,
|
request,
|
||||||
422,
|
422,
|
||||||
@@ -386,6 +390,25 @@ fn respond(request: Request, status: u16, content_type: &str, body: &str) -> Res
|
|||||||
.map_err(|error| format!("could not send response: {error}"))
|
.map_err(|error| format!("could not send response: {error}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn respond_json_engine(
|
||||||
|
request: Request,
|
||||||
|
status: u16,
|
||||||
|
body: &str,
|
||||||
|
engine: &str,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let content_type = Header::from_bytes("Content-Type", "application/json; charset=utf-8")
|
||||||
|
.map_err(|_| "invalid response header".to_string())?;
|
||||||
|
let engine_header = Header::from_bytes("X-Preview-Engine", engine)
|
||||||
|
.map_err(|_| "invalid response header".to_string())?;
|
||||||
|
let response = Response::from_string(body)
|
||||||
|
.with_status_code(StatusCode(status))
|
||||||
|
.with_header(content_type)
|
||||||
|
.with_header(engine_header);
|
||||||
|
request
|
||||||
|
.respond(response)
|
||||||
|
.map_err(|error| format!("could not send response: {error}"))
|
||||||
|
}
|
||||||
|
|
||||||
fn respond_with_cache(
|
fn respond_with_cache(
|
||||||
request: Request,
|
request: Request,
|
||||||
content_type: &str,
|
content_type: &str,
|
||||||
|
|||||||
+24
-3
@@ -26,9 +26,13 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn header(&self, name: &str) -> Option<&str> {
|
fn header(&self, name: &str) -> Option<&str> {
|
||||||
self.headers
|
let needle = format!("{}: ", name.to_ascii_lowercase());
|
||||||
.lines()
|
self.headers.lines().find_map(|line| {
|
||||||
.find_map(|line| line.strip_prefix(&format!("{name}: ")))
|
let lowered = line.to_ascii_lowercase();
|
||||||
|
lowered
|
||||||
|
.strip_prefix(&needle)
|
||||||
|
.map(|_| line[needle.len()..].trim())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2299,3 +2303,20 @@ fn project_images_resolve_through_graphicspath() {
|
|||||||
"pdf should embed the image resolved through graphicspath"
|
"pdf should embed the image resolved through graphicspath"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn preview_uses_route_d_by_default_and_v1_on_request() {
|
||||||
|
let server = TestServer::start("preview-engine");
|
||||||
|
let source = b"\\documentclass{article}\n\\begin{document}\n\nHello\n\n\\end{document}";
|
||||||
|
let default = server.request("POST", "/preview", source, "text/plain");
|
||||||
|
assert_eq!(default.status, 200, "{}", default.text());
|
||||||
|
assert_eq!(
|
||||||
|
default.header("X-Preview-Engine"),
|
||||||
|
Some("route-d"),
|
||||||
|
"headers: {}",
|
||||||
|
default.headers
|
||||||
|
);
|
||||||
|
let v1 = server.request("POST", "/preview?engine=v1", source, "text/plain");
|
||||||
|
assert_eq!(v1.status, 200, "{}", v1.text());
|
||||||
|
assert_eq!(v1.header("X-Preview-Engine"), Some("v1"));
|
||||||
|
}
|
||||||
Reference in new issue
Block a user