Skip to content

Commit 98105ff

Browse files
committed
docmodel: have shell_escape_cwd imply shell_escape = true
Reported in #933.
1 parent 204f033 commit 98105ff

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

crates/docmodel/src/document.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ mod syntax {
390390
}
391391

392392
pub fn to_runtime(&self) -> super::OutputProfile {
393+
let shell_escape_default = self.shell_escape_cwd.is_some();
394+
393395
super::OutputProfile {
394396
name: self.name.clone(),
395397
target_type: self.target_type.to_runtime(),
@@ -411,7 +413,7 @@ mod syntax {
411413
.postamble_file
412414
.clone()
413415
.unwrap_or_else(|| DEFAULT_POSTAMBLE_FILE.to_owned()),
414-
shell_escape: self.shell_escape.unwrap_or_default(),
416+
shell_escape: self.shell_escape.unwrap_or(shell_escape_default),
415417
shell_escape_cwd: self.shell_escape_cwd.clone(),
416418
}
417419
}
@@ -469,3 +471,45 @@ mod syntax {
469471
}
470472
}
471473
}
474+
475+
#[cfg(test)]
476+
mod tests {
477+
use std::io::Cursor;
478+
479+
use super::*;
480+
481+
#[test]
482+
fn shell_escape_default_false() {
483+
const TOML: &str = r#"
484+
[doc]
485+
name = "test"
486+
bundle = "na"
487+
488+
[[output]]
489+
name = "o"
490+
type = "pdf"
491+
"#;
492+
493+
let mut c = Cursor::new(TOML.as_bytes());
494+
let doc = Document::new_from_toml(".", ".", &mut c).unwrap();
495+
assert!(!doc.outputs.get("o").unwrap().shell_escape);
496+
}
497+
498+
#[test]
499+
fn shell_escape_cwd_implies_shell_escape() {
500+
const TOML: &str = r#"
501+
[doc]
502+
name = "test"
503+
bundle = "na"
504+
505+
[[output]]
506+
name = "o"
507+
type = "pdf"
508+
shell_escape_cwd = "."
509+
"#;
510+
511+
let mut c = Cursor::new(TOML.as_bytes());
512+
let doc = Document::new_from_toml(".", ".", &mut c).unwrap();
513+
assert!(doc.outputs.get("o").unwrap().shell_escape);
514+
}
515+
}

0 commit comments

Comments
 (0)