fix/space and help #11
|
|
@ -3,7 +3,7 @@ use clap::Args;
|
|||
use phf::phf_map;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use std::fmt::Debug;
|
||||
use std::{fmt::Debug, sync::LazyLock};
|
||||
|
||||
use regex_static::once_cell::sync::Lazy;
|
||||
|
||||
|
|
@ -43,12 +43,12 @@ pub(super) struct Craft {
|
|||
/// Configuration options for processing TSV files and generating LaTeX tables.
|
||||
#[derive(Debug, Args)]
|
||||
pub(super) struct TableArgs {
|
||||
/// A boolean indicating whether to generate LaTeX code and write it to an output file
|
||||
/// (if true) or just print the generated code to stdout
|
||||
/// Wether to export all files (if used), or output everything to stdout
|
||||
#[arg(short)]
|
||||
pub export: bool,
|
||||
|
||||
/// The kind of tables to operate on: classes, craft or files followed by a list of files
|
||||
#[arg(help = format!("The kind of tables to operate on : {}", *HELP_STR_TO_TARGET_TABLES))]
|
||||
pub kind: TableGenerationTarget,
|
||||
/// A vector of strings representing the names of TSV files to process.
|
||||
pub filenames: Vec<String>,
|
||||
|
|
@ -75,6 +75,16 @@ static STR_TO_TARGET: phf::Map<&'static str, TableGenerationTarget> = phf_map! {
|
|||
"all" => TableGenerationTarget::All,
|
||||
};
|
||||
|
||||
/// A help of all the table targets to be built
|
||||
pub(super) static HELP_STR_TO_TARGET_TABLES: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = STR_TO_TARGET
|
||||
.keys()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// All the type of tsv that can be processed by the program
|
||||
// #[enum_dispatch]
|
||||
#[derive(Clone)]
|
||||
|
|
@ -128,8 +138,8 @@ impl From<&str> for TableGenerationTarget {
|
|||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Only the following target can be used: {:?}",
|
||||
STR_TO_TARGET.keys()
|
||||
"Only the following target can be used: {}",
|
||||
*HELP_STR_TO_TARGET_TABLES
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,15 +145,15 @@ pub fn export_tsv(
|
|||
/// Replace all instances of unrepresentable utf8 or non escaped characters with latex ones
|
||||
pub fn make_latex_string(arg: &str) -> String {
|
||||
let res = arg
|
||||
.replace('🩸', "\\blood")
|
||||
.replace('⚡', "\\gauge")
|
||||
.replace('☽', "\\slash")
|
||||
.replace('◅', "\\pierce")
|
||||
.replace('⧆', "\\blunt")
|
||||
.replace('🩸', "\\blood{}")
|
||||
.replace('⚡', "\\gauge{}")
|
||||
.replace('☽', "\\slash{}")
|
||||
.replace('◅', "\\pierce{}")
|
||||
.replace('⧆', "\\blunt{}")
|
||||
.replace('Ø', "\\o{}")
|
||||
.replace('⌭', "\\torque")
|
||||
.replace('☆', "\\ddzero")
|
||||
.replace('🗘', "\\reload")
|
||||
.replace('⌭', "\\torque{}")
|
||||
.replace('☆', "\\ddzero{}")
|
||||
.replace('🗘', "\\reload{}")
|
||||
.replace('½', "\\sfrac{1}{2}")
|
||||
.replace('&', "\\&");
|
||||
let res = RE_PLUS_STARS.replace_all(&res, |caps: &Captures| {
|
||||
|
|
|
|||
Loading…
Reference in New Issue