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
+9
-1
@@ -500,7 +500,15 @@ fn handle_project_request(
|
||||
Err(error) => return respond_api_error(request, 422, &error),
|
||||
};
|
||||
if query_param(url, "engine").as_deref() == Some("route-d") {
|
||||
return match route_d::project_preview_json(id, &source) {
|
||||
let read = |path: &str| {
|
||||
let bytes = store
|
||||
.read_file(id, path)
|
||||
.ok()
|
||||
.or_else(|| store.read_file(id, &format!("{path}.tex")).ok())?;
|
||||
String::from_utf8(bytes).ok()
|
||||
};
|
||||
let expanded = route_d::expand_inputs(&source, read);
|
||||
return match route_d::project_preview_json(id, &expanded) {
|
||||
Ok(json) => respond_json(request, 200, &json),
|
||||
Err(error) => respond_api_error(request, 422, &error),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user