fix numbat aliases like mib -> MiB

This commit is contained in:
mat 2024-04-15 01:18:25 +00:00
parent f1190ab15f
commit 22007fb6b7
2 changed files with 8 additions and 2 deletions

2
README
View File

@ -17,4 +17,4 @@ the config.toml file is created in your current working directory on the first
run of metasearch2. alternatively, you can copy the default-config.toml in the run of metasearch2. alternatively, you can copy the default-config.toml in the
repo and rename it to config.toml. repo and rename it to config.toml.
the default port is port 28019. the default port is 28019.

View File

@ -93,7 +93,8 @@ fn interpret(query: &str) -> Option<(Statement, Markup)> {
CodeSource::Text, CodeSource::Text,
) { ) {
Ok(r) => r, Ok(r) => r,
Err(_) => { Err(err) => {
eprintln!("numbat error: {}", err);
return None; return None;
} }
}; };
@ -185,10 +186,15 @@ pub static NUMBAT_CTX: Lazy<numbat::Context> = Lazy::new(|| {
// (the lowercase alias code won't work for these because they have prefixes) // (the lowercase alias code won't work for these because they have prefixes)
for (alias, canonical) in &[ for (alias, canonical) in &[
("kb", "kB"), ("kb", "kB"),
("kib", "KiB"),
("mb", "MB"), ("mb", "MB"),
("mib", "MiB"),
("gb", "GB"), ("gb", "GB"),
("gib", "GiB"),
("tb", "TB"), ("tb", "TB"),
("tib", "TiB"),
("pb", "PB"), ("pb", "PB"),
("pib", "PiB"),
] { ] {
let _ = ctx.interpret(&format!("let {alias} = {canonical}"), CodeSource::Internal); let _ = ctx.interpret(&format!("let {alias} = {canonical}"), CodeSource::Internal);
} }