Skip to content

Commit

Permalink
Paranoid commit: latest updates as in thesis
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicKatora committed May 10, 2020
1 parent f0b1e19 commit 62ed0b2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
pulldown-cmark = "0.4.0"
str-concat = "0.1.4"
str-concat = "0.2.0"
structopt = "0.2.10"
void = "1.0.2"
boolinator = "2.4"
Expand Down
9 changes: 3 additions & 6 deletions src/backend/latex/complex/math.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::io::Write;

use crate::backend::latex::InlineEnvironment;
use crate::backend::{Backend, CodeGenUnit};
use crate::config::Config;
use crate::error::Result;
Expand Down Expand Up @@ -31,7 +31,7 @@ impl<'a> CodeGenUnit<'a, ()> for InlineMathGen {

#[derive(Debug)]
pub struct MathBlockGen<'a> {
inline_fig: InlineEnvironment<'a>,
_label: Option<WithRange<Cow<'a, str>>>,
kind: MathBlockKind,
}

Expand All @@ -41,16 +41,14 @@ impl<'a> CodeGenUnit<'a, MathBlock<'a>> for MathBlockGen<'a> {
gen: &mut Generator<'a, impl Backend<'a>, impl Write>,
) -> Result<Self> {
let WithRange(MathBlock { kind, label, caption }, _range) = eq;
let inline_fig = InlineEnvironment::new_figure(label, caption);
let out = gen.get_out();
inline_fig.write_begin(&mut *out)?;

match kind {
MathBlockKind::Equation => writeln!(out, "\\begin{{align*}}")?,
MathBlockKind::NumberedEquation => writeln!(out, "\\begin{{align}}")?,
}

Ok(MathBlockGen { inline_fig, kind })
Ok(MathBlockGen { _label: label, kind })
}

fn finish(
Expand All @@ -62,7 +60,6 @@ impl<'a> CodeGenUnit<'a, MathBlock<'a>> for MathBlockGen<'a> {
MathBlockKind::Equation => writeln!(out, "\\end{{align*}}")?,
MathBlockKind::NumberedEquation => writeln!(out, "\\end{{align}}")?,
}
self.inline_fig.write_end(out)?;
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/frontend/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a> Iterator for Concat<'a> {

match t {
Cow::Borrowed(b) => match next {
Cow::Borrowed(next) => match str_concat::concat(b, next) {
Cow::Borrowed(next) => match unsafe { str_concat::concat(b, next) } {
Ok(res) => t = Cow::Borrowed(res),
Err(_) => t = Cow::Owned(b.to_string() + next),
},
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![forbid(unsafe_code)]
// groups
#![warn(nonstandard_style)]
#![warn(rust_2018_idioms)]
Expand Down Expand Up @@ -84,7 +83,8 @@ fn main() {
};

let tmpdir = TempDir::new("heradoc").expect("can't create tempdir");
let cfg = Config::new(args, infile, file, &tmpdir);
let tmpdir = core::mem::ManuallyDrop::new(tmpdir);
let cfg = Config::new(args, infile, file, &*tmpdir);
if cfg.out_dir != cfg.temp_dir {
// While initializing the config, some files may already be downloaded.
// Thus we must only clear the output directory if it's not a temporary directory.
Expand All @@ -99,12 +99,12 @@ fn main() {
let tex_file = File::create(&tex_path).expect("can't create temporary tex file");
gen(&cfg, markdown, tex_file);

pdflatex(&tmpdir, &cfg);
pdflatex(&*tmpdir, &cfg);
if cfg.bibliography.is_some() {
biber(&tmpdir);
pdflatex(&tmpdir, &cfg);
biber(&*tmpdir);
pdflatex(&*tmpdir, &cfg);
}
pdflatex(&tmpdir, &cfg);
pdflatex(&*tmpdir, &cfg);
let mut pdf = File::open(tmpdir.path().join("document.pdf"))
.expect("unable to open generated pdf");
io::copy(&mut pdf, &mut cfg.output.to_write()).expect("can't write to output");
Expand Down

0 comments on commit 62ed0b2

Please sign in to comment.