Expand input and include files in project previews
Project previews now expand \input{...} and \include{...} from the
project store (adding a .tex suffix when needed) before route-D parses
the source. Unknown paths and cycles leave the directive as literal
text.
This commit is contained in:
1 parent
67eb719cbd
commit
9599436447
6 files changed
+109
-5
No files matched your search
@@ -243,6 +243,39 @@ fn serves_frontend_assets_and_fonts() {
|
||||
assert_eq!(missing.status, 404);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_expands_included_files() {
|
||||
let server = TestServer::start("route-d-input");
|
||||
let section = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=section.tex",
|
||||
b"ZXQ included.",
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(section.status, 200, "{}", section.text());
|
||||
let main = "\\documentclass{article}\n\\begin{document}\nBefore.\n\\input{section}\nAfter.\n\\end{document}\n";
|
||||
let put = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
main.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(put.status, 200, "{}", put.text());
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
|
||||
let svg = value["pages"][0]["svg"].as_str().unwrap();
|
||||
assert!(svg.contains(">Z</text>"), "{svg}");
|
||||
assert!(svg.contains(">X</text>"), "{svg}");
|
||||
assert!(svg.contains(">Q</text>"), "{svg}");
|
||||
assert!(svg.contains(">B</text>"), "{svg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serves_project_api_preview_and_pdf() {
|
||||
let server = TestServer::start("api");
|
||||
|
||||
Reference in new issue
Block a user