-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
395 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ build: | |
@cargo build -r | ||
|
||
test: | ||
@cargo test | ||
@cargo test --all | ||
|
||
doc: | ||
@cargo doc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,10 @@ | ||
//! tex-fmt | ||
//! An extremely fast LaTeX formatter written in Rust | ||
|
||
#![warn(missing_docs)] | ||
#![warn(clippy::nursery)] | ||
#![warn(clippy::cargo)] | ||
#![warn(clippy::missing_docs_in_private_items)] | ||
#![warn(clippy::pedantic)] | ||
#![allow(clippy::wildcard_imports)] | ||
#![allow(clippy::multiple_crate_versions)] | ||
#![allow(clippy::struct_excessive_bools)] | ||
#![allow(clippy::module_name_repetitions)] | ||
#[warn(unused_imports)] | ||
|
||
use clap::Parser; | ||
use std::fs; | ||
use std::process::ExitCode; | ||
|
||
mod cli; | ||
mod comments; | ||
mod format; | ||
mod ignore; | ||
mod indent; | ||
mod logging; | ||
mod read; | ||
mod regexes; | ||
mod subs; | ||
mod verbatim; | ||
mod wrap; | ||
mod write; | ||
use crate::cli::*; | ||
use crate::format::*; | ||
use crate::logging::*; | ||
use crate::read::*; | ||
use crate::write::*; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
#[cfg(target_family = "unix")] | ||
/// Line ending for unix | ||
const LINE_END: &str = "\n"; | ||
|
||
#[cfg(target_family = "windows")] | ||
/// Line ending for Windows | ||
const LINE_END: &str = "\r\n"; | ||
|
||
fn main() -> ExitCode { | ||
let mut args = Cli::parse(); | ||
init_logger(args.log_level()); | ||
|
||
let mut logs = Vec::<Log>::new(); | ||
let mut exit_code = args.resolve(&mut logs); | ||
|
||
if exit_code == 0 { | ||
if args.stdin { | ||
// TODO combine the read and read_stdin functions to simplify this | ||
if let Some((file, text)) = read_stdin(&mut logs) { | ||
let new_text = format_file(&text, &file, &args, &mut logs); | ||
exit_code = process_output( | ||
&args, &file, &text, &new_text, exit_code, &mut logs, | ||
); | ||
} else { | ||
exit_code = 1; | ||
} | ||
} else { | ||
for file in &args.files { | ||
if let Some((file, text)) = read(file, &mut logs) { | ||
let new_text = format_file(&text, &file, &args, &mut logs); | ||
exit_code = process_output( | ||
&args, &file, &text, &new_text, exit_code, &mut logs, | ||
); | ||
} else { | ||
exit_code = 1; | ||
}; | ||
} | ||
} | ||
} | ||
|
||
print_logs(&mut logs); | ||
ExitCode::from(exit_code) | ||
} | ||
fn main() -> std::process::ExitCode { | ||
let mut output: Option<String> = None; | ||
let exit_code = tex_fmt_lib::run(None, &mut output); | ||
std::process::ExitCode::from(exit_code) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
name = "tex-fmt-lib" | ||
description = "tex-fmt compiled to web assembly" | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
edition.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
exclude.workspace = true | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
clap = { version = "4.5.21", features = ["derive"] } | ||
colored = "2.1.0" | ||
env_logger = "0.11.5" | ||
lazy_static = "1.5.0" | ||
log = "0.4.22" | ||
regex = "1.11.1" | ||
similar = "2.6.0" | ||
wasm-bindgen = "0.2" | ||
web-time = "1.1.0" | ||
|
||
[dependencies.web-sys] | ||
version = "0.3" | ||
features = ["console"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.