Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tracing_subscriber::{self, EnvFilter};

use technique::formatting::*;
use technique::formatting::{self};

use technique::parsing;

mod problem;
Expand All @@ -17,6 +18,7 @@ mod rendering;
#[derive(Eq, Debug, PartialEq)]
enum Output {
Native,
Typst,
Silent,
}

Expand Down Expand Up @@ -108,6 +110,15 @@ fn main() {
PDF. By default this will highlight the source of the \
input file for the purposes of reviewing the raw \
procedure.")
.arg(
Arg::new("output")
.short('o')
.long("output")
.value_parser(["typst", "none"])
.default_value("none")
.action(ArgAction::Set)
.help("Output format: pdf (default) or typst markup.")
)
.arg(
Arg::new("filename")
.required(true)
Expand Down Expand Up @@ -215,6 +226,17 @@ fn main() {
print!("{}", result);
}
Some(("render", submatches)) => {
let output = submatches
.get_one::<String>("output")
.unwrap();
let output = match output.as_str() {
"typst" => Output::Typst,
"none" => Output::Silent,
_ => panic!("Unrecognized --output value"),
};

debug!(?output);

let filename = submatches
.get_one::<String>("filename")
.unwrap(); // argument are required by definition so always present
Expand Down Expand Up @@ -244,6 +266,18 @@ fn main() {
};

let result = formatting::render(&Typst, &technique, 70);

match output {
Output::Typst => {
print!("{}", result);
}
_ => {
// ignore; the default is to not output any intermediate
// representations and instead proceed to invoke the
// typesetter to generate the desired PDF.
}
}

rendering::via_typst(&filename, &result);
}
Some(_) => {
Expand Down