diff options
| author | lukeflo | 2025-10-14 08:54:35 +0200 |
|---|---|---|
| committer | lukeflo | 2025-10-14 08:54:35 +0200 |
| commit | c62b83e02359c24973344699116acc12b4a04108 (patch) | |
| tree | 2b86c65f311e4ea9f64b911846c95cbc11916cdb | |
| parent | 467851007e1861834326deee3116aa88fe839f5a (diff) | |
| download | bibiman-c62b83e02359c24973344699116acc12b4a04108.tar.gz bibiman-c62b83e02359c24973344699116acc12b4a04108.zip | |
skip set and xdata entries by default
| -rw-r--r-- | src/bibiman/citekeys.rs | 7 | ||||
| -rw-r--r-- | src/bibiman/citekeys/citekey_utils.rs | 5 | ||||
| -rw-r--r-- | src/config.rs | 10 | ||||
| -rw-r--r-- | tests/biblatex-test-citekeys.bib | 4 |
4 files changed, 22 insertions, 4 deletions
diff --git a/src/bibiman/citekeys.rs b/src/bibiman/citekeys.rs index 0cec28e..999c6cb 100644 --- a/src/bibiman/citekeys.rs +++ b/src/bibiman/citekeys.rs @@ -28,7 +28,7 @@ use owo_colors::OwoColorize; use serde::{Deserialize, Serialize}; use crate::{ - bibiman::citekeys::citekey_utils::{build_citekey, formatting_help}, + bibiman::citekeys::citekey_utils::{SKIPPED_ENTRIES, build_citekey, formatting_help}, config::{BibiConfig, IGNORED_SPECIAL_CHARS, IGNORED_WORDS}, }; @@ -167,6 +167,10 @@ impl CitekeyFormatting { pub fn do_formatting(&mut self, ignored_chars: &[char], ignored_words: &[String]) -> &mut Self { let mut old_new_keys: Vec<(String, String)> = Vec::new(); for entry in self.bib_entries.iter() { + // Skip specific entries + if SKIPPED_ENTRIES.contains(&entry.entry_type.to_string().to_lowercase().as_str()) { + continue; + } old_new_keys.push(( entry.key.clone(), build_citekey( @@ -181,7 +185,6 @@ impl CitekeyFormatting { } self.old_new_keys_map = old_new_keys; - // dbg!(&self.old_new_keys_map); self } diff --git a/src/bibiman/citekeys/citekey_utils.rs b/src/bibiman/citekeys/citekey_utils.rs index 5f70224..58a8274 100644 --- a/src/bibiman/citekeys/citekey_utils.rs +++ b/src/bibiman/citekeys/citekey_utils.rs @@ -15,6 +15,8 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. ///// +use std::sync::LazyLock; + use biblatex::{ChunksExt, Entry, Type}; use deunicode::deunicode; use indoc::formatdoc; @@ -25,6 +27,8 @@ use owo_colors::{ use crate::bibiman::{citekeys::CitekeyCase, sanitize::sanitize_single_string_fully}; +pub(super) const SKIPPED_ENTRIES: [&str; 2] = ["set", "xdata"]; + pub(super) fn formatting_help() { let help = vec![ formatdoc!( @@ -200,6 +204,7 @@ pub(super) fn build_citekey( match case { Some(CitekeyCase::Lower) => new_citekey.to_lowercase(), Some(CitekeyCase::Upper) => new_citekey.to_uppercase(), + // otherwise skip, since camelcase is processed in char loop _ => new_citekey, } } diff --git a/src/config.rs b/src/config.rs index 7c1a0f8..b8d8b45 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,6 +52,10 @@ pub static IGNORED_WORDS: LazyLock<Vec<String>> = LazyLock::new(|| { String::from("at"), String::from("to"), String::from("and"), + String::from("him"), + String::from("her"), + String::from("his"), + String::from("hers"), String::from("der"), String::from("die"), String::from("das"), @@ -63,6 +67,12 @@ pub static IGNORED_WORDS: LazyLock<Vec<String>> = LazyLock::new(|| { String::from("und"), String::from("für"), String::from("vor"), + String::from("er"), + String::from("sie"), + String::from("es"), + String::from("ihm"), + String::from("ihr"), + String::from("ihnen"), ] }); diff --git a/tests/biblatex-test-citekeys.bib b/tests/biblatex-test-citekeys.bib index 9767f97..34c2f33 100644 --- a/tests/biblatex-test-citekeys.bib +++ b/tests/biblatex-test-citekeys.bib @@ -1,9 +1,9 @@ -@set{set, +@set{SET, entryset = {article:herrmann-ofele_carboc=carben=as_2006,article:aksin-turkmen_effect=immobi=on_2006,article:yoon-ryu_pallad=pincer=comple_2006}, annotation = {A \texttt{set} with three members.}, } -@set{set, +@set{stdmodel, entryset = {article:glashow_partia=symmet=weak_1961,article:weinberg_model=lepton_1967,salam}, annotation = {A \texttt{set} with three members discussing the standard model of particle physics.}, |
