1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-06-07 11:36:14 +02:00

Merge pull request #92 from stefan0xC/support_tectonic

add support for tectonic
This commit is contained in:
Élisabeth Henry 2022-02-24 12:07:00 +01:00 committed by GitHub
commit e99f311619
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 44 deletions

View File

@ -1454,7 +1454,10 @@ impl Book {
}
match String::from_utf8(res) {
Err(_) => panic!("{}", lformat!("header generated by mustache was not valid utf-8")),
Err(_) => panic!(
"{}",
lformat!("header generated by mustache was not valid utf-8")
),
Ok(res) => Ok(HeaderData {
text: res,
number: number,

View File

@ -450,11 +450,14 @@ impl BookOptions {
continue;
}
_ => {
panic!("{}", lformat!(
"Ill-formatted OPTIONS string: unrecognized type \
panic!(
"{}",
lformat!(
"Ill-formatted OPTIONS string: unrecognized type \
'{option_type}'",
option_type = option_type.unwrap()
))
option_type = option_type.unwrap()
)
)
}
}
if key == "crowbook.temp_dir" {

View File

@ -342,13 +342,17 @@ impl<'a> EpubRenderer<'a> {
let mut res: Vec<u8> = vec![];
template.render_data(&mut res, &data)?;
match String::from_utf8(res) {
Err(_) => panic!("{}", lformat!(
"generated HTML for cover.xhtml was not utf-8 valid"
)),
Err(_) => panic!(
"{}",
lformat!("generated HTML for cover.xhtml was not utf-8 valid")
),
Ok(res) => Ok(res),
}
} else {
panic!("{}", lformat!("Why is this method called if cover is None???"));
panic!(
"{}",
lformat!("Why is this method called if cover is None???")
);
}
}

View File

@ -19,10 +19,13 @@ pub fn get_hash(lang: &str) -> Hash {
if let Yaml::Hash(hash) = elem {
hash
} else {
panic!("{}", lformat!(
"Yaml file for language {lang} didn't contain a hash",
lang = lang
));
panic!(
"{}",
lformat!(
"Yaml file for language {lang} didn't contain a hash",
lang = lang
)
);
}
}
@ -37,10 +40,13 @@ pub fn get_str(lang: &str, s: &str) -> String {
if let &Yaml::String(ref result) = yaml {
result.clone()
} else {
panic!("{}", lformat!(
"Yaml for {key} in lang {lang} is not a String!",
key = s,
lang = lang
));
panic!(
"{}",
lformat!(
"Yaml for {key} in lang {lang} is not a String!",
key = s,
lang = lang
)
);
}
}

View File

@ -290,8 +290,10 @@ impl<'a> LatexRenderer<'a> {
if self.book.options.get_bool("rendering.initials") == Ok(true) {
data = data.insert_bool("initials", true);
}
// Insert xelatex if tex.command is set to xelatex
if self.book.options.get_str("tex.command") == Ok("xelatex") {
// Insert xelatex if tex.command is set to xelatex or tectonic
if (self.book.options.get_str("tex.command") == Ok("xelatex"))
| (self.book.options.get_str("tex.command") == Ok("tectonic"))
{
data = data.insert_bool("xelatex", true);
}
let data = data.build();

View File

@ -1,10 +1,10 @@
/// Equivalent to assert_eq! but with prettier output
pub fn test_eq(actual: &str, expected: &str) {
if actual != expected {
panic!("{}", format!(
"\nexpected:\n{:?}\nactual:\n{:?}\n",
expected, actual
));
panic!(
"{}",
format!("\nexpected:\n{:?}\nactual:\n{:?}\n", expected, actual)
);
}
}

View File

@ -133,24 +133,20 @@ This is forbidden because we are supposed \
in_file: &str,
out: &mut dyn Write,
) -> Result<String> {
let res_output = command
.args(&self.args)
.current_dir(&self.path)
.output()
.map_err(|e| {
debug!(
"{}",
lformat!(
"output for command {name}:\n{error}",
name = command_name,
error = e
)
);
Error::zipper(lformat!(
"failed to run command '{name}'",
name = command_name
))
});
let res_output = command.output().map_err(|e| {
debug!(
"{}",
lformat!(
"output for command {name}:\n{error}",
name = command_name,
error = e
)
);
Error::zipper(lformat!(
"failed to run command '{name}'",
name = command_name
))
});
let output = res_output?;
if output.status.success() {
let mut file = File::open(self.path.join(in_file)).map_err(|_| {
@ -161,7 +157,7 @@ This is forbidden because we are supposed \
Command output:\n\
{output}'",
command = command_name,
output = String::from_utf8_lossy(&output.stdout)
output = String::from_utf8_lossy(&output.stderr)
)
);
Error::zipper(lformat!(
@ -180,7 +176,7 @@ This is forbidden because we are supposed \
lformat!(
"{command} didn't return succesfully: {output}",
command = command_name,
output = String::from_utf8_lossy(&output.stdout)
output = String::from_utf8_lossy(&output.stderr)
)
);
Err(Error::zipper(lformat!(
@ -193,6 +189,7 @@ This is forbidden because we are supposed \
/// zip all files in zipper's tmp dir to a given file name and write to odt file
pub fn generate_odt(&mut self, command_name: &str, odt_file: &mut dyn Write) -> Result<String> {
let mut command = Command::new(command_name);
command.current_dir(&self.path);
command.arg("-r");
command.arg("result.odt");
command.arg(".");