Makeglossary fix

This commit is contained in:
Dandaedre 2026-07-20 00:10:46 +02:00
parent 7ec926432e
commit 4ac2146b13
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 41 additions and 14 deletions

View File

@ -34,6 +34,8 @@ pub enum VerboseLevel {
Error,
/// Uncatchable errors
Critical,
/// Interactive prompt context, only useful in interactive mode
InteractiveContext,
/// Literrally uncatchable things
Uncatchable,
}

View File

@ -32,13 +32,14 @@ use tokio::{
use anyhow::{Context, Result, anyhow};
use crate::makepdf_functions::{
BuilderParseResult, make_clean, make_file, make_glossaries, make_list,
};
use crate::makepdf_structs::{
BuildInfo, COL_INFO, COL_NORMAL, LineType, Status, TXT_BOXX, TXT_CNTX, TXT_CRIT, TXT_ERRR,
TXT_INFO, TXT_MISC, TXT_UKNW, TXT_WARN,
};
use crate::{
makepdf_functions::{BuilderParseResult, make_clean, make_file, make_glossaries, make_list},
makepdf_structs::TXT_ICTX,
};
/// Make a pdf spawning a subprocess
pub fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
@ -284,6 +285,15 @@ fn checkline(
*TXT_CNTX,
COL_NORMAL.apply_to(final_line)
)), // Context tends to be shit ))?
VerboseLevel::InteractiveContext => {
if !args.non_interactive {
pb.println(format!(
"{} {:?}",
*TXT_ICTX,
COL_NORMAL.apply_to(final_line)
))
}
}
VerboseLevel::Info => {
status.info += 1;
pb.println(format!(

View File

@ -46,6 +46,9 @@ pub(super) static TXT_BOXX: LazyLock<String> =
/// Filler box for the [CNTX] text box
pub(super) static TXT_CNTX: LazyLock<String> =
LazyLock::new(|| format!("{}", COL_CONTEXT.apply_to(&"[CNTX]")));
/// Filler box for the [CNTX] text box
pub(super) static TXT_ICTX: LazyLock<String> =
LazyLock::new(|| format!("{}", COL_CONTEXT.apply_to(&"[ICTX]")));
/// Filler box for the [INFO] text box
pub(super) static TXT_INFO: LazyLock<String> =
LazyLock::new(|| format!("{}", COL_INFO.apply_to(&"[INFO]")));
@ -234,10 +237,10 @@ pub(super) enum LineType {
/// Glossary will not be built
#[token("This document will not have a glossary.")]
#[token("Remove \\makeglossaries if you don't want any glossaries.")]
#[token("Remove .makeglossaries if you don't want any glossaries.")]
NoGlossary,
#[regex(r"No file [^$]\.gls\.", |_| "".to_string())]
#[regex(r"No file [^$]+\.gls\.", |lex| lex.slice().replace("No file ", ""))]
/// The glossary file wasn't found
NoGlossaryFile(String),
@ -262,6 +265,15 @@ pub(super) enum LineType {
#[regex(r"\([A-z_-]+\) [^\n]+", |lex| split_by(")",&lex.slice()[1..]), allow_greedy=true)]
PackageContext((String, String)),
/// You should read the LaTex manual
#[token("See the pdftex.def package documentation for explanation.", |lex| lex.slice().to_string())]
#[token("See the LaTeX manual or LaTeX Companion for explanation.", |lex| lex.slice().to_string())]
HelpGiven(String),
/// Interactive prompt
#[token("Type H for immediate help.")]
Prompt,
/// Loading (Load something)
#[regex(r"(\)+ )?\(/usr[^)]*", |lex| lex.slice().split("/").last().unwrap_or("").to_string())]
Loading(String),
@ -284,9 +296,10 @@ pub(super) enum LineType {
#[token("Transcript written on")]
Log,
// /// Barely parsable data
// #[regex(r"\)+")]
// Garbage,
/// Useless help line
#[regex(r"\.\.\.")]
Garbage,
/// Empty line, to discard
Empty,
@ -301,6 +314,10 @@ pub(super) enum LineType {
/// Transcript
#[token("(see the transcript file for additional information)")]
Transcript,
/// Error Context
#[regex(r"l\.\d+ [^\n]+", |lex| split_by(" ",lex.slice()), allow_greedy=true) ]
// #[regex(r"\(\./[A-z/_-]+\.(gls|tex)", |lex| lex.slice().split("(").nth(1).unwrap_or("").to_string())]
ErrorContext((String, String)),
}
impl LineType {
@ -349,6 +366,10 @@ impl LineType {
LineType::NoGlossary => VerboseLevel::Warning,
LineType::FontAwesome => VerboseLevel::Info,
LineType::NoGlossaryFile(_) => VerboseLevel::Warning,
LineType::HelpGiven(_) => VerboseLevel::Context,
LineType::Prompt => VerboseLevel::InteractiveContext,
LineType::Garbage => VerboseLevel::None,
LineType::ErrorContext(_) => VerboseLevel::Error,
}
}
}

View File

@ -49,7 +49,6 @@ fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
template_load!(templates, &config.monster, resists_row);
template_load!(templates, &config.monster, stats);
template_load!(templates, &config.monster, phase_row);
// template_load!(templates, &config.monster, attack_color);
template_load!(templates, &config.monster, attack_repeatable_row);
template_load!(templates, &config.monster, attack_info_row);
template_load!(templates, &config.monster, intent_table);
@ -253,11 +252,6 @@ fn number_of_description(monster_first_atk: &&MonsterSingleAttack) -> usize {
}
}
#[derive(Serialize)]
struct Coloring<'a> {
color: &'a str,
// size: usize,
}
#[derive(Serialize)]
struct PhaseName<'a> {
phase_name: &'a String,
}