Merge passed package and class options
Preamble \PassOptionsToPackage and \PassOptionsToClass declarations are collected and merged into the next \usepackage or \documentclass request, so the shared option lists in article-class projects reach the local class and package option protocol.
This commit is contained in:
1 parent
6aa9d70a49
commit
9195d090de
5 files changed
+122
-13
No files matched your search
@@ -546,6 +546,51 @@ fn project_preview_loads_local_base_classes() {
|
||||
assert!(!text.contains("LoadClass"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_previews_apply_passed_package_and_class_options() {
|
||||
let server = TestServer::start("route-d-passed-options");
|
||||
let style = "\\ProvidesPackage{mystyle}\n\\DeclareOption{shout}{\\newcommand{\\loudword}{QZ}}\n\\ProcessOptions\n\\newcommand{\\plainword}{JK}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=mystyle.sty",
|
||||
style.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let class = "\\ProvidesClass{myclass}\n\\DeclareOption{boxed}{\\newcommand{\\boxword}{BO}}\n\\ProcessOptions\n\\newcommand{\\plainclassword}{WX}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=myclass.cls",
|
||||
class.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let document = "\\PassOptionsToClass{boxed}{myclass}\n\\PassOptionsToPackage{shout}{mystyle}\n\\documentclass{myclass}\n\\usepackage{mystyle}\n\\begin{document}\nBody \\boxword{} \\loudword{} \\plainword.\n\\end{document}\n";
|
||||
let response = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
document.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(response.status, 200, "{}", response.text());
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let text = preview.text();
|
||||
for character in ["B", "O", "Q", "Z", "J", "K"] {
|
||||
assert!(
|
||||
text.contains(&format!(">{character}</text>")),
|
||||
"missing {character}: {text}"
|
||||
);
|
||||
}
|
||||
assert!(!text.contains("PassOptions"), "{text}");
|
||||
assert!(!text.contains("DeclareOption"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_executes_local_class_options() {
|
||||
let server = TestServer::start("route-d-class-option");
|
||||
|
||||
Reference in new issue
Block a user