From 4c304d1dbde7a50108e3f5db520ce63261dce847 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 5 Jun 2026 22:20:07 +0200 Subject: [PATCH 01/31] Start restructuring --- Cargo.lock | 150 +- Cargo.toml | 57 +- crates/hayagriva-archive/Cargo.toml | 19 + crates/hayagriva-archive/src/lib.rs | 0 .../hayagriva-archive/tests}/archiver.rs | 18 +- crates/hayagriva-biblatex/Cargo.toml | 10 + crates/hayagriva-biblatex/src/lib.rs | 1 + crates/hayagriva-cli/Cargo.toml | 20 + {src => crates/hayagriva-cli/src}/interop.rs | 0 {src => crates/hayagriva-cli/src}/main.rs | 2 +- crates/hayagriva-core/Cargo.toml | 18 + {src => crates/hayagriva-core/src}/lang/en.rs | 0 .../hayagriva-core/src}/lang/mod.rs | 0 .../hayagriva-core/src}/lang/name.rs | 0 crates/hayagriva-core/src/lib.rs | 34 + .../hayagriva-core/src}/types/mod.rs | 4 +- .../hayagriva-core/src}/types/numeric.rs | 2 +- .../hayagriva-core/src}/types/page.rs | 4 +- .../hayagriva-core/src}/types/persons.rs | 2 +- .../hayagriva-core/src}/types/strings.rs | 0 .../hayagriva-core/src}/types/time.rs | 2 +- {src => crates/hayagriva-core/src}/util.rs | 0 crates/hayagriva-csl/Cargo.toml | 18 + .../hayagriva-csl/src}/citation_label.rs | 5 +- {src/csl => crates/hayagriva-csl/src}/elem.rs | 0 .../mod.rs => crates/hayagriva-csl/src/lib.rs | 13 +- .../hayagriva-csl/src}/rendering/mod.rs | 4 +- .../hayagriva-csl/src}/rendering/names.rs | 4 +- {src/csl => crates/hayagriva-csl/src}/sort.rs | 6 +- crates/hayagriva-csl/src/taxonomy.rs | 127 ++ crates/hayagriva-format/Cargo.toml | 22 + {src => crates/hayagriva-format/src}/io.rs | 0 {src => crates/hayagriva-format/src}/lib.rs | 25 +- .../hayagriva-format/src}/selectors/mod.rs | 4 +- .../hayagriva-format/src}/selectors/parser.rs | 2 +- .../hayagriva-format/src}/taxonomy.rs | 372 +---- crates/hayagriva-json/Cargo.toml | 14 + crates/hayagriva-json/src/lib.rs | 216 +++ crates/hayagriva-util/Cargo.toml | 11 + crates/hayagriva-util/src/lib.rs | 1 + crates/hayagriva-util/src/test_util.rs | 97 ++ src/csl/archive.rs | 1210 ----------------- tests/common/mod.rs | 96 -- 43 files changed, 759 insertions(+), 1831 deletions(-) create mode 100644 crates/hayagriva-archive/Cargo.toml create mode 100644 crates/hayagriva-archive/src/lib.rs rename {tests => crates/hayagriva-archive/tests}/archiver.rs (98%) create mode 100644 crates/hayagriva-biblatex/Cargo.toml create mode 100644 crates/hayagriva-biblatex/src/lib.rs create mode 100644 crates/hayagriva-cli/Cargo.toml rename {src => crates/hayagriva-cli/src}/interop.rs (100%) rename {src => crates/hayagriva-cli/src}/main.rs (99%) create mode 100644 crates/hayagriva-core/Cargo.toml rename {src => crates/hayagriva-core/src}/lang/en.rs (100%) rename {src => crates/hayagriva-core/src}/lang/mod.rs (100%) rename {src => crates/hayagriva-core/src}/lang/name.rs (100%) create mode 100644 crates/hayagriva-core/src/lib.rs rename {src => crates/hayagriva-core/src}/types/mod.rs (99%) rename {src => crates/hayagriva-core/src}/types/numeric.rs (99%) rename {src => crates/hayagriva-core/src}/types/page.rs (99%) rename {src => crates/hayagriva-core/src}/types/persons.rs (99%) rename {src => crates/hayagriva-core/src}/types/strings.rs (100%) rename {src => crates/hayagriva-core/src}/types/time.rs (99%) rename {src => crates/hayagriva-core/src}/util.rs (100%) create mode 100644 crates/hayagriva-csl/Cargo.toml rename {src/csl => crates/hayagriva-csl/src}/citation_label.rs (98%) rename {src/csl => crates/hayagriva-csl/src}/elem.rs (100%) rename src/csl/mod.rs => crates/hayagriva-csl/src/lib.rs (99%) rename {src/csl => crates/hayagriva-csl/src}/rendering/mod.rs (99%) rename {src/csl => crates/hayagriva-csl/src}/rendering/names.rs (99%) rename {src/csl => crates/hayagriva-csl/src}/sort.rs (98%) create mode 100644 crates/hayagriva-csl/src/taxonomy.rs create mode 100644 crates/hayagriva-format/Cargo.toml rename {src => crates/hayagriva-format/src}/io.rs (100%) rename {src => crates/hayagriva-format/src}/lib.rs (98%) rename {src => crates/hayagriva-format/src}/selectors/mod.rs (98%) rename {src => crates/hayagriva-format/src}/selectors/parser.rs (99%) rename {src/csl => crates/hayagriva-format/src}/taxonomy.rs (64%) create mode 100644 crates/hayagriva-json/Cargo.toml create mode 100644 crates/hayagriva-json/src/lib.rs create mode 100644 crates/hayagriva-util/Cargo.toml create mode 100644 crates/hayagriva-util/src/lib.rs create mode 100644 crates/hayagriva-util/src/test_util.rs delete mode 100644 src/csl/archive.rs diff --git a/Cargo.lock b/Cargo.lock index 9b3240e8..03b4fab7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - [[package]] name = "anstream" version = "1.0.0" @@ -161,9 +152,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", @@ -203,31 +194,84 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] -name = "hayagriva" +name = "hayagriva-archive" version = "0.10.0" dependencies = [ - "biblatex", "ciborium", "citationberg", - "clap", + "hayagriva-util", "heck", + "serde", +] + +[[package]] +name = "hayagriva-biblatex" +version = "0.10.0" + +[[package]] +name = "hayagriva-cli" +version = "0.10.0" +dependencies = [ + "biblatex", + "citationberg", + "clap", + "hayagriva-archive", + "strum 0.26.3", +] + +[[package]] +name = "hayagriva-core" +version = "0.10.0" +dependencies = [ + "citationberg", + "roman-numerals-rs", + "serde", + "thiserror", + "unicode-segmentation", + "unscanny", + "url", +] + +[[package]] +name = "hayagriva-csl" +version = "0.10.0" +dependencies = [ + "citationberg", + "hayagriva-core", "icu_collator", "icu_locale", "indexmap", + "unic-langid", +] + +[[package]] +name = "hayagriva-format" +version = "0.10.0" +dependencies = [ + "citationberg", + "hayagriva-core", + "indexmap", "paste", - "regex", - "roman-numerals-rs", "serde", - "serde_json", "serde_yaml", - "strum 0.26.3", "thiserror", "unic-langid", "unicode-segmentation", "unscanny", - "url", ] +[[package]] +name = "hayagriva-json" +version = "0.10.0" +dependencies = [ + "citationberg", + "hayagriva-core", +] + +[[package]] +name = "hayagriva-util" +version = "0.10.0" + [[package]] name = "heck" version = "0.5.0" @@ -421,9 +465,9 @@ checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" [[package]] name = "once_cell_polyfill" @@ -488,35 +532,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "regex" -version = "1.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" - [[package]] name = "roman-numerals-rs" version = "3.1.0" @@ -565,19 +580,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_json" -version = "1.0.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" -dependencies = [ - "itoa", - "memchr", - "serde", - "serde_core", - "zmij", -] - [[package]] name = "serde_path_to_error" version = "0.1.20" @@ -792,9 +794,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unsafe-libyaml" @@ -868,9 +870,9 @@ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" [[package]] name = "yoke" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -891,18 +893,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639" dependencies = [ "proc-macro2", "quote", @@ -964,9 +966,3 @@ dependencies = [ "quote", "syn", ] - -[[package]] -name = "zmij" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 7562ee42..052997fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,50 +1,41 @@ -[package] -name = "hayagriva" +[workspace] +members = [ + "crates/hayagriva-archive", + "crates/hayagriva-biblatex", + "crates/hayagriva-cli", + "crates/hayagriva-core", + "crates/hayagriva-csl", + "crates/hayagriva-format", + "crates/hayagriva-json", + "crates/hayagriva-util", +] +resolver = "2" + +[workspace.package] version = "0.10.0" -authors = ["Martin Haug "] +authors = [ + "Martin Haug ", + "Daniel Drodt ", +] edition = "2024" license = "MIT OR Apache-2.0" -description = "Work with references: Literature database management, storage, and citation formatting" repository = "https://github.com/typst/hayagriva" readme = "README.md" -categories = ["template-engine", "value-formatting", "command-line-utilities"] -keywords = ["bibliography", "citation", "reference", "bibtex", "literature"] - -[features] -default = ["biblatex", "archive"] -cli = ["clap", "strum"] -archive = ["ciborium"] -csl-json = ["citationberg/json"] +keywords = ["bibliography", "citation", "reference", "literature"] -[dependencies] +[workspace.dependencies] +biblatex = { version = "0.12.0", features = ["unic-langid"] } +ciborium = { version = "0.2.1" } citationberg = "0.7.0" indexmap = { version = "2.0.2", features = ["serde"] } -roman-numerals-rs = "3.1.0" -paste = "1.0.14" serde = { version = "1", features = ["derive"] } -serde_yaml = "0.9.25" -thiserror = "2.0.16" unic-langid = { version = "0.9.6", features = ["serde"] } unicode-segmentation = "1.6.0" +thiserror = "2.0.16" unscanny = "0.1.0" url = { version = "2.4", features = ["serde"] } -biblatex = { version = "0.12.0", features = ["unic-langid"], optional = true } -ciborium = { version = "0.2.1", optional = true } -clap = { version = "4", optional = true, features = ["cargo"] } -strum = { version = "0.26", features = ["derive"], optional = true } -icu_collator = "2.2.0" -icu_locale = "2.2.0" -[dev-dependencies] +[workspace.dev-dependencies] heck = "0.5" serde_json = "1" regex = "1" - -[[bin]] -name = "hayagriva" -required-features = ["cli"] - -[[test]] -name = "citeproc" -path = "tests/citeproc.rs" -required-features = ["csl-json"] diff --git a/crates/hayagriva-archive/Cargo.toml b/crates/hayagriva-archive/Cargo.toml new file mode 100644 index 00000000..2e9a6de2 --- /dev/null +++ b/crates/hayagriva-archive/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "hayagriva-archive" +description = "Archived CSL styles and locales for Hayagriva/Typst" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +citationberg = { workspace = true } +serde = { workspace = true } +hayagriva-util = { path = "../hayagriva-util" } +ciborium = { workspace = true } + +[dev-dependencies] +heck = "0.5" diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs new file mode 100644 index 00000000..e69de29b diff --git a/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs similarity index 98% rename from tests/archiver.rs rename to crates/hayagriva-archive/tests/archiver.rs index 00df2d7d..dd5ee44f 100644 --- a/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -10,6 +10,9 @@ //! these tests (with `--test archiver`) to update the otherwise outdated //! files. +extern crate citationberg; +extern crate serde; + use citationberg::{IndependentStyle, LocaleCode, Style}; use citationberg::{Locale, LocaleFile, XmlDeError}; use serde::Serialize; @@ -19,12 +22,15 @@ use std::fs; use std::hash::RandomState; use std::io::{self, BufReader, Read}; use std::path::{Path, PathBuf}; -use std::{fmt, iter}; - -mod common; -use common::{ensure_repo, iter_files, iter_files_with_name}; +use std::{ + fmt, + iter::{self, FromIterator}, +}; -use crate::common::CACHE_PATH; +extern crate hayagriva_util; +use hayagriva_util::test_util::{ + ensure_repo, iter_files, iter_files_with_name, CACHE_PATH, +}; const STYLES_REPO_NAME: &str = "styles"; const CSL_REPO: &str = "https://github.com/citation-style-language/styles"; @@ -33,7 +39,7 @@ const LOCALES_REPO_NAME: &str = "locales"; const OWN_STYLES: &str = "styles"; const ARCHIVE_STYLES_PATH: &str = "archive/styles/"; const ARCHIVE_LOCALES_PATH: &str = "archive/locales/"; -const ARCHIVE_SRC_PATH: &str = "src/csl/archive.rs"; +const ARCHIVE_SRC_PATH: &str = "crates/hayagriva-archive/lib.rs"; const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; diff --git a/crates/hayagriva-biblatex/Cargo.toml b/crates/hayagriva-biblatex/Cargo.toml new file mode 100644 index 00000000..e304c46f --- /dev/null +++ b/crates/hayagriva-biblatex/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "hayagriva-biblatex" +description = "Archived CSL styles and locales for Hayagriva/Typst" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true diff --git a/crates/hayagriva-biblatex/src/lib.rs b/crates/hayagriva-biblatex/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/crates/hayagriva-biblatex/src/lib.rs @@ -0,0 +1 @@ + diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml new file mode 100644 index 00000000..a88e24ec --- /dev/null +++ b/crates/hayagriva-cli/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "hayagriva-cli" +description = "Archived CSL styles and locales for Hayagriva/Typst" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +citationberg = { workspace = true } +clap = { version = "4", features = ["cargo"] } +hayagriva-archive = { path = "../hayagriva-archive" } +strum = { version = "0.26", features = ["derive"] } +biblatex = { workspace = true, optional = true } + +[features] +default = ["biblatex"] diff --git a/src/interop.rs b/crates/hayagriva-cli/src/interop.rs similarity index 100% rename from src/interop.rs rename to crates/hayagriva-cli/src/interop.rs diff --git a/src/main.rs b/crates/hayagriva-cli/src/main.rs similarity index 99% rename from src/main.rs rename to crates/hayagriva-cli/src/main.rs index c28ad9c4..efa27076 100644 --- a/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -12,12 +12,12 @@ use clap::builder::PossibleValue; use clap::{Arg, ArgAction, Command, ValueEnum, crate_version}; use strum::VariantNames; -use hayagriva::archive::{ArchivedStyle, locales}; use hayagriva::{ BibliographyDriver, CitationItem, CitationRequest, LocatorPayload, SpecificLocator, io, }; use hayagriva::{BibliographyRequest, Selector}; +use hayagriva_archive::{ArchivedStyle, locales}; #[derive(Debug, Copy, Clone, PartialEq, VariantNames)] #[strum(serialize_all = "kebab_case")] diff --git a/crates/hayagriva-core/Cargo.toml b/crates/hayagriva-core/Cargo.toml new file mode 100644 index 00000000..1dcb7bcc --- /dev/null +++ b/crates/hayagriva-core/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "hayagriva-core" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +serde = { workspace = true } +url = { workspace = true } +thiserror = { workspace = true } +citationberg = { workspace = true } +unscanny = { workspace = true } +roman-numerals-rs = "3.1.0" +unicode-segmentation = { workspace = true } diff --git a/src/lang/en.rs b/crates/hayagriva-core/src/lang/en.rs similarity index 100% rename from src/lang/en.rs rename to crates/hayagriva-core/src/lang/en.rs diff --git a/src/lang/mod.rs b/crates/hayagriva-core/src/lang/mod.rs similarity index 100% rename from src/lang/mod.rs rename to crates/hayagriva-core/src/lang/mod.rs diff --git a/src/lang/name.rs b/crates/hayagriva-core/src/lang/name.rs similarity index 100% rename from src/lang/name.rs rename to crates/hayagriva-core/src/lang/name.rs diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs new file mode 100644 index 00000000..e387ac2a --- /dev/null +++ b/crates/hayagriva-core/src/lib.rs @@ -0,0 +1,34 @@ +pub mod lang; +pub mod types; +pub mod util; + +use std::borrow::Cow; + +use citationberg::{ + LongShortForm, + taxonomy::{ + self, DateVariable, NameVariable, NumberVariable, PageVariable, StandardVariable, + }, +}; +pub use types::*; + +pub trait EntryLike { + fn resolve_number_variable( + &self, + variable: NumberVariable, + ) -> Option>>; + fn resolve_page_variable( + &self, + variable: PageVariable, + ) -> Option>; + fn resolve_standard_variable( + &self, + form: LongShortForm, + variable: StandardVariable, + ) -> Option>; + fn resolve_name_variable(&self, variable: NameVariable) -> Vec>; + fn resolve_date_variable(&self, variable: DateVariable) -> Option>; + fn matches_entry_type(&self, kind: taxonomy::Kind) -> bool; + fn is_english(&self) -> Option; + fn key(&self) -> Cow<'_, str>; +} diff --git a/src/types/mod.rs b/crates/hayagriva-core/src/types/mod.rs similarity index 99% rename from src/types/mod.rs rename to crates/hayagriva-core/src/types/mod.rs index a222a6b8..b677c023 100644 --- a/src/types/mod.rs +++ b/crates/hayagriva-core/src/types/mod.rs @@ -254,7 +254,7 @@ pub enum EntryType { impl EntryType { /// Entry parents have implicit defaults. This function returns the default /// parent for this entry type. - pub(crate) fn default_parent(&self) -> Self { + pub fn default_parent(&self) -> Self { match self { Self::Article => Self::Periodical, Self::Chapter => Self::Book, @@ -358,7 +358,7 @@ impl MaybeTyped where T: FromStr, { - pub(crate) fn infallible_from_str(s: &str) -> Self { + pub fn infallible_from_str(s: &str) -> Self { match s.parse::() { Ok(t) => MaybeTyped::Typed(t), Err(_) => MaybeTyped::String(s.to_owned()), diff --git a/src/types/numeric.rs b/crates/hayagriva-core/src/types/numeric.rs similarity index 99% rename from src/types/numeric.rs rename to crates/hayagriva-core/src/types/numeric.rs index ac509323..6b44ae0a 100644 --- a/src/types/numeric.rs +++ b/crates/hayagriva-core/src/types/numeric.rs @@ -233,7 +233,7 @@ impl Numeric { impl MaybeTyped> { /// Order the values according to CSL rules. - pub(crate) fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { + pub fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { match (self, other) { (MaybeTyped::Typed(a), MaybeTyped::Typed(b)) => a.csl_cmp(b), _ => self.to_string().cmp(&other.to_string()), diff --git a/src/types/page.rs b/crates/hayagriva-core/src/types/page.rs similarity index 99% rename from src/types/page.rs rename to crates/hayagriva-core/src/types/page.rs index 4d205b45..72328527 100644 --- a/src/types/page.rs +++ b/crates/hayagriva-core/src/types/page.rs @@ -1,6 +1,6 @@ use std::{cmp::Ordering, fmt::Display, num::TryFromIntError, str::FromStr}; -use crate::{MaybeTyped, Numeric, NumericError}; +use crate::types::{MaybeTyped, Numeric, NumericError}; use super::{custom_deserialize, serialize_display}; use serde::{Deserialize, Serialize}; @@ -8,7 +8,7 @@ use thiserror::Error; impl MaybeTyped { /// Order the values according to CSL rules. - pub(crate) fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { + pub fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { match (self, other) { (MaybeTyped::Typed(a), MaybeTyped::Typed(b)) => a.csl_cmp(b), _ => self.to_string().cmp(&other.to_string()), diff --git a/src/types/persons.rs b/crates/hayagriva-core/src/types/persons.rs similarity index 99% rename from src/types/persons.rs rename to crates/hayagriva-core/src/types/persons.rs index 6a3d752b..e00fb77d 100644 --- a/src/types/persons.rs +++ b/crates/hayagriva-core/src/types/persons.rs @@ -502,7 +502,7 @@ impl Person { } /// Order according to the CSL specification. - pub(crate) fn csl_cmp( + pub fn csl_cmp( &self, other: &Self, form: LongShortForm, diff --git a/src/types/strings.rs b/crates/hayagriva-core/src/types/strings.rs similarity index 100% rename from src/types/strings.rs rename to crates/hayagriva-core/src/types/strings.rs diff --git a/src/types/time.rs b/crates/hayagriva-core/src/types/time.rs similarity index 99% rename from src/types/time.rs rename to crates/hayagriva-core/src/types/time.rs index e1a6dce2..dfd0c7f3 100644 --- a/src/types/time.rs +++ b/crates/hayagriva-core/src/types/time.rs @@ -146,7 +146,7 @@ impl PartialOrd for Date { impl Date { /// Order two dates according to the CSL specification. - pub(crate) fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { + pub fn csl_cmp(&self, other: &Self) -> std::cmp::Ordering { let ord_fn = |a: Option, b: Option| match (a, b) { (Some(a), Some(b)) => a.cmp(&b), (Some(_), None) => std::cmp::Ordering::Greater, diff --git a/src/util.rs b/crates/hayagriva-core/src/util.rs similarity index 100% rename from src/util.rs rename to crates/hayagriva-core/src/util.rs diff --git a/crates/hayagriva-csl/Cargo.toml b/crates/hayagriva-csl/Cargo.toml new file mode 100644 index 00000000..a9a92505 --- /dev/null +++ b/crates/hayagriva-csl/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "hayagriva-csl" +description = "Work with references: Literature database management, storage, and citation formatting" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +citationberg = { workspace = true } +indexmap = { workspace = true } +icu_collator = "2.2.0" +icu_locale = "2.2.0" +hayagriva-core = { path = "../hayagriva-core" } +unic-langid = { workspace = true } diff --git a/src/csl/citation_label.rs b/crates/hayagriva-csl/src/citation_label.rs similarity index 98% rename from src/csl/citation_label.rs rename to crates/hayagriva-csl/src/citation_label.rs index 0b0fc3e5..de94923e 100644 --- a/src/csl/citation_label.rs +++ b/crates/hayagriva-csl/src/citation_label.rs @@ -3,10 +3,7 @@ use std::fmt::Write; use unicode_segmentation::UnicodeSegmentation; -use crate::{ - Entry, - types::{EntryType, Person, PersonRole}, -}; +use hayagriva_core::types::{EntryType, Person, PersonRole}; /// Citation labels in the form of numbers. /// diff --git a/src/csl/elem.rs b/crates/hayagriva-csl/src/elem.rs similarity index 100% rename from src/csl/elem.rs rename to crates/hayagriva-csl/src/elem.rs diff --git a/src/csl/mod.rs b/crates/hayagriva-csl/src/lib.rs similarity index 99% rename from src/csl/mod.rs rename to crates/hayagriva-csl/src/lib.rs index 4666465e..71420537 100644 --- a/src/csl/mod.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -21,14 +21,13 @@ use citationberg::{ ToFormatting, taxonomy as csl_taxonomy, }; use citationberg::{DateForm, LongShortForm, OrdinalLookup, TextCase}; +use hayagriva_core::lang::CaseFolder; use indexmap::IndexSet; -use crate::csl::elem::{NonEmptyStack, simplify_children}; -use crate::csl::rendering::RenderCsl; -use crate::csl::rendering::names::{DisambiguatedNameForm, NameDisambiguationProperties}; -use crate::csl::taxonomy::NumberOrPageVariableResult; -use crate::lang::CaseFolder; -use crate::types::{ChunkKind, ChunkedString, Date, MaybeTyped, Person}; +use crate::elem::{NonEmptyStack, simplify_children}; +use crate::rendering::RenderCsl; +use crate::rendering::names::{DisambiguatedNameForm, NameDisambiguationProperties}; +use crate::taxonomy::NumberOrPageVariableResult; use self::elem::last_text_mut_child; pub use self::elem::{ @@ -36,8 +35,6 @@ pub use self::elem::{ }; use self::taxonomy::{EntryLike, NumberVariableResult, PageVariableResult}; -#[cfg(feature = "archive")] -pub mod archive; mod citation_label; mod elem; mod rendering; diff --git a/src/csl/rendering/mod.rs b/crates/hayagriva-csl/src/rendering/mod.rs similarity index 99% rename from src/csl/rendering/mod.rs rename to crates/hayagriva-csl/src/rendering/mod.rs index a2ed9f06..876167d6 100644 --- a/src/csl/rendering/mod.rs +++ b/crates/hayagriva-csl/src/rendering/mod.rs @@ -15,9 +15,9 @@ use citationberg::{ use citationberg::{TermForm, TextTarget}; use crate::PageRanges; -use crate::csl::Sorting; -use crate::csl::taxonomy::{NumberVariableResult, PageVariableResult}; +use crate::Sorting; use crate::lang::{Case, SentenceCase, TitleCase}; +use crate::taxonomy::{NumberVariableResult, PageVariableResult}; use crate::types::{ChunkedString, Date, MaybeTyped, Numeric}; use super::taxonomy::{EntryLike, NumberOrPageVariableResult}; diff --git a/src/csl/rendering/names.rs b/crates/hayagriva-csl/src/rendering/names.rs similarity index 99% rename from src/csl/rendering/names.rs rename to crates/hayagriva-csl/src/rendering/names.rs index cb1bc510..2c3b36c0 100644 --- a/src/csl/rendering/names.rs +++ b/crates/hayagriva-csl/src/rendering/names.rs @@ -10,9 +10,9 @@ use citationberg::{ ToFormatting, }; -use crate::csl::taxonomy::EntryLike; -use crate::csl::{Context, DisambiguateState, ElemMeta, SpecialForm, UsageInfo}; +use crate::taxonomy::EntryLike; use crate::types::Person; +use crate::{Context, DisambiguateState, ElemMeta, SpecialForm, UsageInfo}; use super::{RenderCsl, render_label_with_var}; diff --git a/src/csl/sort.rs b/crates/hayagriva-csl/src/sort.rs similarity index 98% rename from src/csl/sort.rs rename to crates/hayagriva-csl/src/sort.rs index 7a251ef4..a6e116b6 100644 --- a/src/csl/sort.rs +++ b/crates/hayagriva-csl/src/sort.rs @@ -9,11 +9,11 @@ use icu_collator::Collator; use icu_collator::options::CollatorOptions; use icu_locale::Locale as IcuLocale; -use crate::csl::BufWriteFormat; -use crate::csl::rendering::RenderCsl; +use crate::BufWriteFormat; +use crate::rendering::RenderCsl; -use super::taxonomy::EntryLike; use super::{CitationItem, InstanceContext, StyleContext}; +use hayagriva_core::EntryLike; trait CollationOrd: Ord { fn collation_cmp(&self, other: &Self, locale: LocaleCode) -> Ordering; diff --git a/crates/hayagriva-csl/src/taxonomy.rs b/crates/hayagriva-csl/src/taxonomy.rs new file mode 100644 index 00000000..deeadfcd --- /dev/null +++ b/crates/hayagriva-csl/src/taxonomy.rs @@ -0,0 +1,127 @@ +use std::borrow::Cow; +use std::cmp; +use std::str::FromStr; + +use citationberg::LongShortForm; +use citationberg::taxonomy::{NumberVariable, PageVariable, StandardVariable}; +use hayagriva_core::{ + EntryLike, PageRanges, + types::{ChunkedString, MaybeTyped, Numeric, StringChunk}, +}; + +use super::{DisambiguateState, InstanceContext, LocatorPayload}; + +impl<'a, T: EntryLike> InstanceContext<'a, T> { + pub(super) fn resolve_number_variable( + &self, + variable: NumberVariable, + ) -> Option> { + match variable { + NumberVariable::CitationNumber => { + Some(NumberVariableResult::Regular(MaybeTyped::Typed(Cow::Owned( + Numeric::from(self.cite_props.speculative.citation_number as u32 + 1), + )))) + } + NumberVariable::FirstReferenceNoteNumber => { + self.cite_props.certain.first_note_number.map(|n| { + NumberVariableResult::Regular(MaybeTyped::Typed(Cow::Owned( + Numeric::from(n as u32), + ))) + }) + } + NumberVariable::Locator => { + match &self.cite_props.speculative.locator.as_ref()?.1 { + &LocatorPayload::Str(l) => Some(NumberVariableResult::from_regular( + Numeric::from_str(l) + .map(|n| MaybeTyped::Typed(Cow::Owned(n))) + .unwrap_or_else(|_| MaybeTyped::String(l.to_owned())), + )), + LocatorPayload::Transparent(_) => { + Some(NumberVariableResult::Transparent( + self.cite_props.certain.initial_idx, + )) + } + } + } + _ => self + .entry + .resolve_number_variable(variable) + .map(NumberVariableResult::from_regular), + } + } + + pub(super) fn resolve_page_variable( + &self, + variable: PageVariable, + ) -> Option { + self.entry.resolve_page_variable(variable) + } + + // Number variables are standard variables. + pub(super) fn resolve_standard_variable( + &self, + form: LongShortForm, + variable: StandardVariable, + ) -> Option> { + match variable { + StandardVariable::YearSuffix => { + if let DisambiguateState::YearSuffix(s) = + self.cite_props.speculative.disambiguation + { + Some(Cow::Owned(StringChunk::normal(letter(s)).into())) + } else { + None + } + } + _ => self.entry.resolve_standard_variable(form, variable), + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(super) enum NumberVariableResult<'a> { + Regular(MaybeTyped>), + Transparent(usize), +} + +pub(super) type PageVariableResult = MaybeTyped; + +pub(super) enum NumberOrPageVariableResult<'a> { + Number(NumberVariableResult<'a>), + Page(PageVariableResult), +} + +impl<'a> NumberVariableResult<'a> { + pub(super) fn from_regular(regular: MaybeTyped>) -> Self { + Self::Regular(regular) + } + + pub(super) fn csl_cmp(&self, other: &Self) -> cmp::Ordering { + match (self, other) { + (Self::Regular(a), Self::Regular(b)) => a.csl_cmp(b), + (Self::Regular(_), Self::Transparent(_)) => cmp::Ordering::Less, + (Self::Transparent(_), Self::Regular(_)) => cmp::Ordering::Greater, + (Self::Transparent(a), Self::Transparent(b)) => a.cmp(b), + } + } +} + +// A function that takes a usize value and returns a String +fn letter(val: u8) -> String { + let mut result = String::with_capacity(1); + let mut current = val; + + loop { + let remainder = current % 26; + let c = (remainder + b'a') as char; + result.insert(0, c); + + if current < 26 { + break; + } + + current = (current - 26) / 26; + } + + result +} diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml new file mode 100644 index 00000000..9678d581 --- /dev/null +++ b/crates/hayagriva-format/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "hayagriva-format" +description = "Archived CSL styles and locales for Hayagriva/Typst" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +citationberg = { workspace = true } +indexmap = { workspace = true } +paste = "1.0.14" +serde = { workspace = true } +unic-langid = { workspace = true } +serde_yaml = "0.9.25" +unicode-segmentation = { workspace = true } +hayagriva-core = { path = "../hayagriva-core" } +thiserror = { workspace = true } +unscanny = { workspace = true } diff --git a/src/io.rs b/crates/hayagriva-format/src/io.rs similarity index 100% rename from src/io.rs rename to crates/hayagriva-format/src/io.rs diff --git a/src/lib.rs b/crates/hayagriva-format/src/lib.rs similarity index 98% rename from src/lib.rs rename to crates/hayagriva-format/src/lib.rs index fa9fa0d2..40ce7f8f 100644 --- a/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -140,37 +140,24 @@ return `Some` even if no sub-entry was bound / if the hash map is empty. #[macro_use] mod selectors; -#[cfg(feature = "biblatex")] -mod interop; -mod csl; pub mod io; -pub mod lang; -pub mod types; -mod util; +pub mod taxonomy; use std::collections::BTreeMap; -#[cfg(feature = "archive")] -pub use crate::csl::archive; pub use citationberg; -pub use csl::{ - BibliographyDriver, BibliographyItem, BibliographyRequest, Brackets, BufWriteFormat, - CitationItem, CitationRequest, CitePurpose, Elem, ElemChild, ElemChildren, ElemMeta, - Formatted, Formatting, LocatorPayload, Rendered, RenderedBibliography, - RenderedCitation, SpecificLocator, TransparentLocator, standalone_citation, -}; pub use selectors::{Selector, SelectorError}; +use hayagriva_core::types::*; +use hayagriva_core::util::{ + OneOrMany, deserialize_one_or_many_opt, serialize_one_or_many, + serialize_one_or_many_opt, +}; use indexmap::IndexMap; use paste::paste; use serde::{Deserialize, Serialize, de::Visitor}; -use types::*; use unic_langid::LanguageIdentifier; -use util::{ - OneOrMany, deserialize_one_or_many_opt, serialize_one_or_many, - serialize_one_or_many_opt, -}; /// A collection of bibliographic entries. #[derive(Debug, Clone, Default, PartialEq, Serialize)] diff --git a/src/selectors/mod.rs b/crates/hayagriva-format/src/selectors/mod.rs similarity index 98% rename from src/selectors/mod.rs rename to crates/hayagriva-format/src/selectors/mod.rs index c991bdfb..9576062f 100644 --- a/src/selectors/mod.rs +++ b/crates/hayagriva-format/src/selectors/mod.rs @@ -51,7 +51,7 @@ macro_rules! select { }; ($entry_type:ident) => { - $crate::Selector::Entry($crate::types::EntryType::$entry_type) + $crate::Selector::Entry(::hayagriva_core::types::EntryType::$entry_type) }; ($binding:literal:$expr:tt) => { @@ -95,7 +95,7 @@ use std::collections::HashMap; use thiserror::Error; use crate::Entry; -use crate::types::EntryType; +use hayagriva_core::EntryType; /// A selector used to filter bibliographies and match on entries. #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/src/selectors/parser.rs b/crates/hayagriva-format/src/selectors/parser.rs similarity index 99% rename from src/selectors/parser.rs rename to crates/hayagriva-format/src/selectors/parser.rs index 31cadf4e..fb5878e2 100644 --- a/src/selectors/parser.rs +++ b/crates/hayagriva-format/src/selectors/parser.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use super::{Selector, SelectorError, SelectorResult}; -use crate::types::EntryType; +use hayagriva_core::types::EntryType; /// Parse a selector. pub fn parse(src: &str) -> SelectorResult { diff --git a/src/csl/taxonomy.rs b/crates/hayagriva-format/src/taxonomy.rs similarity index 64% rename from src/csl/taxonomy.rs rename to crates/hayagriva-format/src/taxonomy.rs index 97152534..282cbeec 100644 --- a/src/csl/taxonomy.rs +++ b/crates/hayagriva-format/src/taxonomy.rs @@ -1,139 +1,18 @@ -use std::borrow::Cow; -use std::cmp; -use std::str::FromStr; +use std::{borrow::Cow, str::FromStr}; -use crate::types::{ - ChunkedString, Date, EntryType, MaybeTyped, Numeric, Person, PersonRole, Publisher, - StringChunk, +use citationberg::{ + LongShortForm, + taxonomy::{ + DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, + }, }; -use crate::{Entry, PageRanges}; -use citationberg::taxonomy::{ - DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, +use hayagriva_core::{ + ChunkedString, Date, EntryLike, EntryType, MaybeTyped, Numeric, PageRanges, Person, + PersonRole, Publisher, StringChunk, }; -use citationberg::{LongShortForm, taxonomy}; use unic_langid::LanguageIdentifier; -#[cfg(feature = "csl-json")] -use citationberg::json as csl_json; - -use super::citation_label::Alphanumerical; -use super::{DisambiguateState, InstanceContext, LocatorPayload}; - -pub trait EntryLike { - fn resolve_number_variable( - &self, - variable: NumberVariable, - ) -> Option>>; - fn resolve_page_variable( - &self, - variable: PageVariable, - ) -> Option>; - fn resolve_standard_variable( - &self, - form: LongShortForm, - variable: StandardVariable, - ) -> Option>; - fn resolve_name_variable(&self, variable: NameVariable) -> Vec>; - fn resolve_date_variable(&self, variable: DateVariable) -> Option>; - fn matches_entry_type(&self, kind: taxonomy::Kind) -> bool; - fn is_english(&self) -> Option; - fn key(&self) -> Cow<'_, str>; -} - -impl<'a, T: EntryLike> InstanceContext<'a, T> { - pub(super) fn resolve_number_variable( - &self, - variable: NumberVariable, - ) -> Option> { - match variable { - NumberVariable::CitationNumber => { - Some(NumberVariableResult::Regular(MaybeTyped::Typed(Cow::Owned( - Numeric::from(self.cite_props.speculative.citation_number as u32 + 1), - )))) - } - NumberVariable::FirstReferenceNoteNumber => { - self.cite_props.certain.first_note_number.map(|n| { - NumberVariableResult::Regular(MaybeTyped::Typed(Cow::Owned( - Numeric::from(n as u32), - ))) - }) - } - NumberVariable::Locator => { - match &self.cite_props.speculative.locator.as_ref()?.1 { - &LocatorPayload::Str(l) => Some(NumberVariableResult::from_regular( - Numeric::from_str(l) - .map(|n| MaybeTyped::Typed(Cow::Owned(n))) - .unwrap_or_else(|_| MaybeTyped::String(l.to_owned())), - )), - LocatorPayload::Transparent(_) => { - Some(NumberVariableResult::Transparent( - self.cite_props.certain.initial_idx, - )) - } - } - } - _ => self - .entry - .resolve_number_variable(variable) - .map(NumberVariableResult::from_regular), - } - } - - pub(super) fn resolve_page_variable( - &self, - variable: PageVariable, - ) -> Option { - self.entry.resolve_page_variable(variable) - } - - // Number variables are standard variables. - pub(super) fn resolve_standard_variable( - &self, - form: LongShortForm, - variable: StandardVariable, - ) -> Option> { - match variable { - StandardVariable::YearSuffix => { - if let DisambiguateState::YearSuffix(s) = - self.cite_props.speculative.disambiguation - { - Some(Cow::Owned(StringChunk::normal(letter(s)).into())) - } else { - None - } - } - _ => self.entry.resolve_standard_variable(form, variable), - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub(super) enum NumberVariableResult<'a> { - Regular(MaybeTyped>), - Transparent(usize), -} - -pub(super) type PageVariableResult = MaybeTyped; - -pub(super) enum NumberOrPageVariableResult<'a> { - Number(NumberVariableResult<'a>), - Page(PageVariableResult), -} - -impl<'a> NumberVariableResult<'a> { - pub(super) fn from_regular(regular: MaybeTyped>) -> Self { - Self::Regular(regular) - } - - pub(super) fn csl_cmp(&self, other: &Self) -> cmp::Ordering { - match (self, other) { - (Self::Regular(a), Self::Regular(b)) => a.csl_cmp(b), - (Self::Regular(_), Self::Transparent(_)) => cmp::Ordering::Less, - (Self::Transparent(_), Self::Regular(_)) => cmp::Ordering::Greater, - (Self::Transparent(a), Self::Transparent(b)) => a.cmp(b), - } - } -} +use super::Entry; impl EntryLike for Entry { fn key(&self) -> Cow<'_, str> { @@ -411,10 +290,7 @@ impl EntryLike for Entry { }?)) } - fn resolve_name_variable( - &self, - variable: taxonomy::NameVariable, - ) -> Vec> { + fn resolve_name_variable(&self, variable: NameVariable) -> Vec> { match variable { NameVariable::Author => self.authors().map(|a| a.iter().collect()), NameVariable::Chair => self @@ -524,7 +400,7 @@ impl EntryLike for Entry { .collect() } - fn matches_entry_type(&self, kind: citationberg::taxonomy::Kind) -> bool { + fn matches_entry_type(&self, kind: Kind) -> bool { // Each match arm contains mutually exclusive entry kinds. match kind { Kind::Article @@ -704,210 +580,6 @@ impl EntryLike for Entry { } } -#[cfg(feature = "csl-json")] -fn resolve_csl_json_standard_variable( - item: &citationberg::json::Item, - variable: StandardVariable, -) -> Option> { - match item.0.get(&variable.to_string())? { - csl_json::Value::String(s) => { - Some(Cow::Owned(StringChunk::normal(s.clone()).into())) - } - csl_json::Value::Number(n) => { - Some(Cow::Owned(StringChunk::normal(n.to_string()).into())) - } - _ => None, - } -} - -#[cfg(feature = "csl-json")] -impl EntryLike for citationberg::json::Item { - fn resolve_standard_variable( - &self, - form: LongShortForm, - variable: StandardVariable, - ) -> Option> { - match variable { - StandardVariable::Title => match form { - LongShortForm::Short => { - // Per citeproc tests, a 'title-short' without 'title' is - // valid and should be used when the short form is - // selected. - resolve_csl_json_standard_variable(self, StandardVariable::TitleShort) - .or_else(|| { - resolve_csl_json_standard_variable( - self, - StandardVariable::Title, - ) - }) - } - LongShortForm::Long => { - resolve_csl_json_standard_variable(self, StandardVariable::Title) - } - }, - _ => resolve_csl_json_standard_variable(self, variable), - } - } - - fn resolve_date_variable(&self, variable: DateVariable) -> Option> { - match self.0.get(&variable.to_string())? { - csl_json::Value::Date(d) => { - let Ok(d) = csl_json::FixedDateRange::try_from(d.clone()) else { - return None; - }; - if d.end.is_some() { - panic!("ranges are not supported") - } - let d = d.start; - Some(Cow::Owned(Date { - year: d.year as i32, - month: d.month, - day: d.day, - approximate: d.circa, - season: d.season, - })) - } - _ => None, - } - } - - fn resolve_name_variable(&self, variable: NameVariable) -> Vec> { - match self.0.get(&variable.to_string()) { - Some(csl_json::Value::Names(names)) => names - .iter() - .filter_map(|name| { - Some(Cow::Owned(match name { - csl_json::NameValue::Literal(l) => Person { - name: l.literal.clone(), - prefix: None, - suffix: None, - given_name: None, - alias: None, - comma_suffix: false, - }, - csl_json::NameValue::Item(csl_json::NameItem { - family, - given, - non_dropping_particle: None, - dropping_particle: None, - suffix, - comma_suffix, - }) => { - let mut parts = vec![family.as_str()]; - if let Some(given) = given { - parts.push(given.as_str()); - } - let mut p = Person::from_strings(parts).ok()?; - if let Some(suffix) = suffix { - p.suffix = Some(suffix.as_str().to_owned()); - } - if comma_suffix.unwrap_or_default() { - p.comma_suffix = true; - } - - p - } - csl_json::NameValue::Item(csl_json::NameItem { - family, - given, - non_dropping_particle, - dropping_particle, - suffix, - comma_suffix, - }) => Person { - name: if let Some(non_drop) = non_dropping_particle { - format!("{non_drop} {family}") - } else { - family.clone() - }, - prefix: dropping_particle.clone(), - suffix: suffix.clone(), - given_name: given.clone(), - alias: None, - comma_suffix: comma_suffix.unwrap_or_default(), - }, - })) - }) - .collect(), - _ => vec![], - } - } - - fn resolve_page_variable( - &self, - variable: PageVariable, - ) -> Option> { - match variable { - PageVariable::Page => match self.0.get("page")? { - &csl_json::Value::Number(n) => { - // Page ranges use i32 internally, so we check whether the - // number is in range. - Some(match i32::try_from(n) { - Ok(n) => MaybeTyped::Typed(PageRanges::from(n)), - // If the number is not in range, we degrade to a - // string, which disables some CSL features. - Err(_) => MaybeTyped::String(n.to_string()), - }) - } - csl_json::Value::String(s) => { - let res = MaybeTyped::::infallible_from_str(s); - Some(match res { - MaybeTyped::String(s) => MaybeTyped::String(s), - MaybeTyped::Typed(r) => MaybeTyped::Typed(r), - }) - } - _ => None, - }, - } - } - - fn resolve_number_variable( - &self, - variable: NumberVariable, - ) -> Option>> { - if matches!(variable, NumberVariable::PageFirst) - && let Some(MaybeTyped::Typed(n)) = - self.resolve_page_variable(PageVariable::Page) - { - return n.first().map(|r| MaybeTyped::Typed(Cow::Owned(r.clone()))); - } - match self.0.get(&variable.to_string())? { - csl_json::Value::Number(n) => { - Some(MaybeTyped::Typed(Cow::Owned(Numeric::from(*n as u32)))) - } - csl_json::Value::String(s) => { - let res = MaybeTyped::::infallible_from_str(s); - Some(match res { - MaybeTyped::String(s) => MaybeTyped::String(s), - MaybeTyped::Typed(n) => MaybeTyped::Typed(Cow::Owned(n)), - }) - } - _ => None, - } - } - - fn matches_entry_type(&self, kind: taxonomy::Kind) -> bool { - let Some(actual) = self.0.get("type") else { - return false; - }; - let Some(string) = actual.to_str() else { - return false; - }; - Kind::from_str(&string) == Ok(kind) - } - - fn is_english(&self) -> Option { - self.0 - .get("language") - .and_then(|l| l.to_str()) - .map(|l| l.starts_with("en")) - } - - fn key(&self) -> Cow<'_, str> { - self.id().unwrap_or_default() - } -} - pub(super) fn csl_language(lang_id: &LanguageIdentifier) -> String { let mut buf = String::with_capacity(if lang_id.region.is_some() { 5 } else { 2 }); buf.push_str(lang_id.language.as_str()); @@ -917,23 +589,3 @@ pub(super) fn csl_language(lang_id: &LanguageIdentifier) -> String { } buf } - -// A function that takes a usize value and returns a String -fn letter(val: u8) -> String { - let mut result = String::with_capacity(1); - let mut current = val; - - loop { - let remainder = current % 26; - let c = (remainder + b'a') as char; - result.insert(0, c); - - if current < 26 { - break; - } - - current = (current - 26) / 26; - } - - result -} diff --git a/crates/hayagriva-json/Cargo.toml b/crates/hayagriva-json/Cargo.toml new file mode 100644 index 00000000..5af04919 --- /dev/null +++ b/crates/hayagriva-json/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "hayagriva-json" +description = "Archived CSL styles and locales for Hayagriva/Typst" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] +citationberg = { workspace = true, features = ["json"] } +hayagriva-core = { path = "../hayagriva-core" } diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-json/src/lib.rs new file mode 100644 index 00000000..fe1e4ac1 --- /dev/null +++ b/crates/hayagriva-json/src/lib.rs @@ -0,0 +1,216 @@ +use std::{borrow::Cow, str::FromStr}; + +use citationberg::{ + LongShortForm, json as csl_json, + taxonomy::{ + DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, + }, +}; +use hayagriva_core::{ + ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, Person, StringChunk, +}; + +pub struct Item(pub csl_json::Item); + +fn resolve_csl_json_standard_variable( + item: &Item, + variable: StandardVariable, +) -> Option> { + match item.0.0.get(&variable.to_string())? { + csl_json::Value::String(s) => { + Some(Cow::Owned(StringChunk::normal(s.clone()).into())) + } + csl_json::Value::Number(n) => { + Some(Cow::Owned(StringChunk::normal(n.to_string()).into())) + } + _ => None, + } +} + +impl EntryLike for Item { + fn resolve_standard_variable( + &self, + form: LongShortForm, + variable: StandardVariable, + ) -> Option> { + match variable { + StandardVariable::Title => match form { + LongShortForm::Short => { + // Per citeproc tests, a 'title-short' without 'title' is + // valid and should be used when the short form is + // selected. + resolve_csl_json_standard_variable(self, StandardVariable::TitleShort) + .or_else(|| { + resolve_csl_json_standard_variable( + self, + StandardVariable::Title, + ) + }) + } + LongShortForm::Long => { + resolve_csl_json_standard_variable(self, StandardVariable::Title) + } + }, + _ => resolve_csl_json_standard_variable(self, variable), + } + } + + fn resolve_date_variable(&self, variable: DateVariable) -> Option> { + match self.0.0.get(&variable.to_string())? { + csl_json::Value::Date(d) => { + let Ok(d) = csl_json::FixedDateRange::try_from(d.clone()) else { + return None; + }; + if d.end.is_some() { + panic!("ranges are not supported") + } + let d = d.start; + Some(Cow::Owned(Date { + year: d.year as i32, + month: d.month, + day: d.day, + approximate: d.circa, + season: d.season, + })) + } + _ => None, + } + } + + fn resolve_name_variable(&self, variable: NameVariable) -> Vec> { + match self.0.0.get(&variable.to_string()) { + Some(csl_json::Value::Names(names)) => names + .iter() + .filter_map(|name| { + Some(Cow::Owned(match name { + csl_json::NameValue::Literal(l) => Person { + name: l.literal.clone(), + prefix: None, + suffix: None, + given_name: None, + alias: None, + comma_suffix: false, + }, + csl_json::NameValue::Item(csl_json::NameItem { + family, + given, + non_dropping_particle: None, + dropping_particle: None, + suffix, + comma_suffix, + }) => { + let mut parts = vec![family.as_str()]; + if let Some(given) = given { + parts.push(given.as_str()); + } + let mut p = Person::from_strings(parts).ok()?; + if let Some(suffix) = suffix { + p.suffix = Some(suffix.as_str().to_owned()); + } + if comma_suffix.unwrap_or_default() { + p.comma_suffix = true; + } + + p + } + csl_json::NameValue::Item(csl_json::NameItem { + family, + given, + non_dropping_particle, + dropping_particle, + suffix, + comma_suffix, + }) => Person { + name: if let Some(non_drop) = non_dropping_particle { + format!("{non_drop} {family}") + } else { + family.clone() + }, + prefix: dropping_particle.clone(), + suffix: suffix.clone(), + given_name: given.clone(), + alias: None, + comma_suffix: comma_suffix.unwrap_or_default(), + }, + })) + }) + .collect(), + _ => vec![], + } + } + + fn resolve_page_variable( + &self, + variable: PageVariable, + ) -> Option> { + match variable { + PageVariable::Page => match self.0.0.get("page")? { + &csl_json::Value::Number(n) => { + // Page ranges use i32 internally, so we check whether the + // number is in range. + Some(match i32::try_from(n) { + Ok(n) => MaybeTyped::Typed(PageRanges::from(n)), + // If the number is not in range, we degrade to a + // string, which disables some CSL features. + Err(_) => MaybeTyped::String(n.to_string()), + }) + } + csl_json::Value::String(s) => { + let res = MaybeTyped::::infallible_from_str(s); + Some(match res { + MaybeTyped::String(s) => MaybeTyped::String(s), + MaybeTyped::Typed(r) => MaybeTyped::Typed(r), + }) + } + _ => None, + }, + } + } + + fn resolve_number_variable( + &self, + variable: NumberVariable, + ) -> Option>> { + if matches!(variable, NumberVariable::PageFirst) + && let Some(MaybeTyped::Typed(n)) = + self.resolve_page_variable(PageVariable::Page) + { + return n.first().map(|r| MaybeTyped::Typed(Cow::Owned(r.clone()))); + } + match self.0.0.get(&variable.to_string())? { + csl_json::Value::Number(n) => { + Some(MaybeTyped::Typed(Cow::Owned(Numeric::from(*n as u32)))) + } + csl_json::Value::String(s) => { + let res = MaybeTyped::::infallible_from_str(s); + Some(match res { + MaybeTyped::String(s) => MaybeTyped::String(s), + MaybeTyped::Typed(n) => MaybeTyped::Typed(Cow::Owned(n)), + }) + } + _ => None, + } + } + + fn matches_entry_type(&self, kind: Kind) -> bool { + let Some(actual) = self.0.0.get("type") else { + return false; + }; + let Some(string) = actual.to_str() else { + return false; + }; + Kind::from_str(&string) == Ok(kind) + } + + fn is_english(&self) -> Option { + self.0 + .0 + .get("language") + .and_then(|l| l.to_str()) + .map(|l| l.starts_with("en")) + } + + fn key(&self) -> Cow<'_, str> { + self.0.id().unwrap_or_default() + } +} diff --git a/crates/hayagriva-util/Cargo.toml b/crates/hayagriva-util/Cargo.toml new file mode 100644 index 00000000..25ffc24e --- /dev/null +++ b/crates/hayagriva-util/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "hayagriva-util" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true + +[dependencies] diff --git a/crates/hayagriva-util/src/lib.rs b/crates/hayagriva-util/src/lib.rs new file mode 100644 index 00000000..1528db7d --- /dev/null +++ b/crates/hayagriva-util/src/lib.rs @@ -0,0 +1 @@ +pub mod test_util; diff --git a/crates/hayagriva-util/src/test_util.rs b/crates/hayagriva-util/src/test_util.rs new file mode 100644 index 00000000..2e16f7e3 --- /dev/null +++ b/crates/hayagriva-util/src/test_util.rs @@ -0,0 +1,97 @@ +use std::{fs, io, path::PathBuf, process::Command}; + +pub const CACHE_PATH: &str = "target/haya-cache"; + +#[allow(unused)] +pub fn iter_files<'a>( + path: &'a PathBuf, + extension: &'a str, +) -> impl Iterator + 'a { + iter_files_with_name(path, extension, |_| true) +} + +pub fn iter_files_with_name<'a, F>( + path: &'a PathBuf, + extension: &'a str, + mut name_assertion: F, +) -> impl Iterator + 'a +where + F: FnMut(&str) -> bool + 'static, +{ + fs::read_dir(path).unwrap().filter_map(move |thing| { + let thing = thing.ok()?; + if !thing.file_type().ok()?.is_file() { + return None; + } + + let path = thing.path(); + let thing_ext = path.extension(); + if thing_ext?.to_str() != Some(extension) { + return None; + } + + if !name_assertion(path.file_stem()?.to_str()?) { + return None; + } + + Some(path) + }) +} + +/// Clone a repo if it does not exist, pull it otherwise. +/// +/// This function requires a `git` installation to be available in PATH. +pub fn ensure_repo( + repo_url: &str, + repo_name: &str, + branch_name: &str, +) -> Result<(), io::Error> { + let cache_path = PathBuf::from(CACHE_PATH); + fs::create_dir_all(CACHE_PATH)?; + + // Check if styles directory exists. If it does, try to git pull origin + // main. If that fails or the directory does not exist, clone the repo. + let style_path = cache_path.join(repo_name); + let clone = if style_path.exists() { + let status = Command::new("git") + .args(["pull", "origin", branch_name]) + .current_dir(&style_path) + .status() + .expect("Please ensure git is installed"); + + if !status.success() { + fs::remove_dir_all(&style_path)?; + true + } else { + false + } + } else { + true + }; + + if clone { + let status = Command::new("git") + .args([ + "clone", + repo_url, + repo_name, + "--depth", + "1", + // Do not convert LF to CRLF. + // Otherwise, CSL/XML may generate different CBOR on Unix and Windows. + "--config", + "core.autocrlf=input", + ]) + .current_dir(&cache_path) + .status() + .expect("Please ensure git is installed"); + + if !status.success() { + return Err(io::Error::other( + "Failed to clone repo. Is git installed correnctly and is the internet working?", + )); + } + } + + Ok(()) +} diff --git a/src/csl/archive.rs b/src/csl/archive.rs deleted file mode 100644 index 669d20ec..00000000 --- a/src/csl/archive.rs +++ /dev/null @@ -1,1210 +0,0 @@ -//! Optional archive of included CSL styles. -// This file is generated by tests/generate.rs -// Do not edit by hand! - -use citationberg::{Locale, Style}; -use serde::de::DeserializeOwned; - -/// An embedded CSL style. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[non_exhaustive] -pub enum ArchivedStyle { - /// Alphanumeric. - /// - /// Authors: Martin Haug, Laurenz Mädje. - Alphanumeric, - /// American Anthropological Association. - /// - /// Authors: Sebastian Karcher. - AmericanAnthropologicalAssociation, - /// ACS Guide 2022 revision. - /// - /// Authors: Julian Onions. - AmericanChemicalSociety, - /// American Geophysical Union. - /// - /// Authors: Julian Onions, Simon Kornblith. - AmericanGeophysicalUnion, - /// American Institute of Aeronautics and Astronautics. - /// - /// Authors: Garrett Foster. - AmericanInstituteOfAeronauticsAndAstronautics, - /// AIP Style Manual 4th edition. - /// - /// Authors: Richard Karnesky. - AmericanInstituteOfPhysics, - /// AMA Manual of Style 11th edition. - /// - /// Authors: Julian Onions. - AmericanMedicalAssociation, - /// American Meteorological Society. - /// - /// Authors: Carl J. Schreck, III. - AmericanMeteorologicalSociety, - /// American Physical Society. - /// - /// Authors: Richard Karnesky, Brenton M. Wiernik. - AmericanPhysicsSociety, - /// American Physiological Society. - /// - /// Authors: Michael Berkowitz. - AmericanPhysiologicalSociety, - /// APSA Style Manual revised 2018 edition. - /// - /// Authors: Julian Onions. - AmericanPoliticalScienceAssociation, - /// APA Style 7th edition. - /// - /// Authors: Brenton M. Wiernik, Andrew Dunning. - AmericanPsychologicalAssociation, - /// American Society for Microbiology. - /// - /// Authors: Julian Onions. - AmericanSocietyForMicrobiology, - /// American Society of Civil Engineers. - /// - /// Authors: Rintze Zelle. - AmericanSocietyOfCivilEngineers, - /// American Society of Mechanical Engineers. - /// - /// Authors: Richard Karnesky. - AmericanSocietyOfMechanicalEngineers, - /// ASA Style Guide 6th/7th edition. - /// - /// Authors: Julian Onions. - AmericanSociologicalAssociation, - /// Angewandte Chemie International Edition. - /// - /// Authors: Richard Karnesky. - AngewandteChemie, - /// Annual Reviews (sorted by order of appearance). - /// - /// Authors: Michael Berkowitz. - AnnualReviews, - /// Annual Reviews (author-date). - /// - /// Authors: Michael Berkowitz. - AnnualReviewsAuthorDate, - /// Associação Brasileira de Normas Técnicas (Português - Brasil). - /// - /// Authors: Juliana Geyna Régis. - AssociacaoBrasileiraDeNormasTecnicas, - /// Association for Computing Machinery. - /// - /// Authors: Patrick O'Brien. - AssociationForComputingMachinery, - /// BioMed Central. - /// - /// Authors: Robert M Flight. - BiomedCentral, - /// Bristol University Press. - /// - /// Authors: Patrick O'Brien. - BristolUniversityPress, - /// BMJ. - /// - /// Authors: Sebastian Karcher. - BritishMedicalJournal, - /// Cell. - /// - /// Authors: Adam Mark. - Cell, - /// Chicago Manual of Style 18th edition (author-date). - /// - /// Authors: Andrew Dunning. - ChicagoAuthorDate, - /// Chicago Manual of Style 18th edition (notes and bibliography). - /// - /// Authors: Andrew Dunning. - ChicagoNotes, - /// Chicago Manual of Style 18th edition (shortened notes and bibliography). - /// - /// Authors: Andrew Dunning. - ChicagoShortenedNotes, - /// Copernicus Publications. - /// - /// Authors: Julian Onions. - Copernicus, - /// CSE Manual: Scientific Style and Format 8th edition (citation-sequence, brackets). - /// - /// Authors: Pavel Giverts. - CseCitationSequenceBrackets8thEdition, - /// CSE Manual: Scientific Style and Format 9th edition (name-year). - /// - /// Authors: Patrick O'Brien. - CseNameYear, - /// Current Opinion journals. - /// - /// Authors: David M. Kaplan. - CurrentOpinion, - /// Deutsche Gesellschaft für Psychologie 5. Auflage (Deutsch). - /// - /// Authors: Daniel Hirsbrunner. - DeutscheGesellschaftFürPsychologie, - /// Deutsche Sprache (Deutsch). - /// - /// Authors: Philipp Zumstein. - DeutscheSprache, - /// Elsevier (author-date/Harvard, with titles). - /// - /// Authors: David Kaplan. - ElsevierHarvard, - /// Elsevier - NLM/Vancouver (citation-sequence). - /// - /// Authors: Richard Karnesky. - ElsevierVancouver, - /// Elsevier (numeric, with titles). - /// - /// Authors: Richard Karnesky. - ElsevierWithTitles, - /// Frontiers journals. - /// - /// Authors: Sebastian Karcher. - Frontiers, - /// Future Medicine journals. - /// - /// Authors: Patrick O'Bien. - FutureMedicine, - /// Future Science Group. - /// - /// Authors: Sebastian Karcher. - FutureScience, - /// China National Standard GB/T 7714-2005 (numeric, 中文). - /// - /// Authors: heromyth. - Gb77142005Numeric, - /// China National Standard GB/T 7714-2015 (author-date, 中文). - /// - /// Authors: 牛耕田. - Gb77142015AuthorDate, - /// China National Standard GB/T 7714-2015 (note, 中文). - /// - /// Authors: 牛耕田. - Gb77142015Note, - /// China National Standard GB/T 7714-2015 (numeric, 中文). - /// - /// Authors: 牛耕田. - Gb77142015Numeric, - /// Russian GOST R 7.0.5-2008 (numeric). - /// - /// Authors: Yurkin Maxim. - GostR7052008Numeric, - /// Cite Them Right 12th edition (author-date/Harvard). - /// - /// Authors: Patrick O'Brien. - HarvardCiteThemRight, - /// IEEE Reference Guide version 11.29.2023. - /// - /// Authors: Michael Berkowitz. - InstituteOfElectricalAndElectronicsEngineers, - /// Institute of Physics (numeric). - /// - /// Authors: Sebastian Karcher. - InstituteOfPhysicsNumeric, - /// ISO-690 (author-date, English). - /// - /// Authors: Laure Mellifluo, Raphael Grolimund, Michel Hardegger. - Iso690AuthorDate, - /// ISO-690 (numeric, English). - /// - /// Authors: Laure Mellifluo, Raphael Grolimund, Michel Hardegger. - Iso690Numeric, - /// Karger journals. - /// - /// Authors: Sebastian Karcher. - Karger, - /// Mary Ann Liebert - NLM/Vancouver. - /// - /// Authors: Patrick O'Brien. - MaryAnnLiebertVancouver, - /// MHRA Style Guide 4th edition (notes). - /// - /// Authors: Andrew Dunning. - ModernHumanitiesResearchAssociationNotes, - /// MLA Handbook 9th edition (in-text citations). - /// - /// Authors: Sebastian Karcher, Andrew Dunning. - ModernLanguageAssociation, - /// Multidisciplinary Digital Publishing Institute. - /// - /// Authors: Sebastian Karcher. - MultidisciplinaryDigitalPublishingInstitute, - /// Nature. - /// - /// Authors: Michael Berkowitz. - Nature, - /// NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence). - /// - /// Authors: Michael Berkowitz, Andrew Dunning. - NlmCitationSequence, - /// NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence, superscript). - /// - /// Authors: Michael Berkowitz, Andrew Dunning. - NlmCitationSequenceSuperscript, - /// Pensoft Journals. - /// - /// Authors: Brian Stucky, Teodor Georgiev. - Pensoft, - /// Public Library of Science. - /// - /// Authors: Sebastian Karcher. - PublicLibraryOfScience, - /// Royal Society of Chemistry. - /// - /// Authors: Julian Onions. - RoyalSocietyOfChemistry, - /// SAGE - NLM/Vancouver. - /// - /// Authors: Michael Berkowitz. - SageVancouver, - /// SIST02 (日本語). - /// - /// Authors: Shoji Takahashi. - Sist02, - /// SPIE journals. - /// - /// Authors: Yurkin Maxim. - Spie, - /// Springer - Basic (numeric, brackets). - /// - /// Authors: Charles Parnot. - SpringerBasic, - /// Springer - Basic (author-date). - /// - /// Authors: Jens Allmer. - SpringerBasicAuthorDate, - /// Springer - Fachzeitschriften Medizin Psychologie (Deutsch). - /// - /// Authors: Philipp Zumstein. - SpringerFachzeitschriftenMedizinPsychologie, - /// Springer - Humanities (author-date). - /// - /// Authors: Sebastian Karcher. - SpringerHumanitiesAuthorDate, - /// Springer - Lecture Notes in Computer Science. - /// - /// Authors: Ammar Memari. - SpringerLectureNotesInComputerScience, - /// Springer - MathPhys (numeric, brackets). - /// - /// Authors: Charles Parnot. - SpringerMathphys, - /// Springer - SocPsych (author-date). - /// - /// Authors: Charles Parnot. - SpringerSocpsychAuthorDate, - /// Springer - NLM/Vancouver (citation-sequence, brackets). - /// - /// Authors: Charles Parnot. - SpringerVancouver, - /// Taylor & Francis Journals Standard Reference Style Guide: Chicago author-date version 2.0. - /// - /// Authors: Andrew Dunning. - TaylorAndFrancisChicagoAuthorDate, - /// Taylor & Francis - NLM/Vancouver (citation-sequence, brackets). - /// - /// Authors: Sebastian Karcher. - TaylorAndFrancisNationalLibraryOfMedicine, - /// The Institution of Engineering and Technology. - /// - /// Authors: Sebastian Karcher. - TheInstitutionOfEngineeringAndTechnology, - /// The Lancet. - /// - /// Authors: Sebastian Karcher. - TheLancet, - /// Thieme-German (Deutsch). - /// - /// Authors: Sebastian Karcher. - Thieme, - /// Trends journals. - /// - /// Authors: Adam Zeilinger. - Trends, - /// Chicago Manual of Style 17th edition (author-date). - /// - /// Authors: Andrew Dunning. - TurabianAuthorDate, - /// Chicago Manual of Style 17th edition (notes and bibliography, subsequent author-title). - /// - /// Authors: Andrew Dunning. - TurabianFullnote8, -} - -#[rustfmt::skip] -impl ArchivedStyle { - /// Retrieve this style by name. - pub fn by_name(name: &str) -> Option { - match name { - "alphanumeric" => Some(Self::Alphanumeric), - "american-anthropological-association" => Some(Self::AmericanAnthropologicalAssociation), - "american-chemical-society" => Some(Self::AmericanChemicalSociety), - "american-geophysical-union" => Some(Self::AmericanGeophysicalUnion), - "american-institute-of-aeronautics-and-astronautics" => Some(Self::AmericanInstituteOfAeronauticsAndAstronautics), - "american-institute-of-physics" => Some(Self::AmericanInstituteOfPhysics), - "american-medical-association" => Some(Self::AmericanMedicalAssociation), - "american-meteorological-society" => Some(Self::AmericanMeteorologicalSociety), - "american-physics-society" => Some(Self::AmericanPhysicsSociety), - "american-physiological-society" => Some(Self::AmericanPhysiologicalSociety), - "american-political-science-association" => Some(Self::AmericanPoliticalScienceAssociation), - "american-psychological-association" => Some(Self::AmericanPsychologicalAssociation), - "apa" => Some(Self::AmericanPsychologicalAssociation), - "american-society-for-microbiology" => Some(Self::AmericanSocietyForMicrobiology), - "american-society-of-civil-engineers" => Some(Self::AmericanSocietyOfCivilEngineers), - "american-society-of-mechanical-engineers" => Some(Self::AmericanSocietyOfMechanicalEngineers), - "american-sociological-association" => Some(Self::AmericanSociologicalAssociation), - "angewandte-chemie" => Some(Self::AngewandteChemie), - "annual-reviews" => Some(Self::AnnualReviews), - "annual-reviews-author-date" => Some(Self::AnnualReviewsAuthorDate), - "associacao-brasileira-de-normas-tecnicas" => Some(Self::AssociacaoBrasileiraDeNormasTecnicas), - "association-for-computing-machinery" => Some(Self::AssociationForComputingMachinery), - "biomed-central" => Some(Self::BiomedCentral), - "bristol-university-press" => Some(Self::BristolUniversityPress), - "british-medical-journal" => Some(Self::BritishMedicalJournal), - "bmj" => Some(Self::BritishMedicalJournal), - "cell" => Some(Self::Cell), - "chicago-author-date" => Some(Self::ChicagoAuthorDate), - "chicago-notes" => Some(Self::ChicagoNotes), - "chicago-fullnotes" => Some(Self::ChicagoNotes), - "chicago-shortened-notes" => Some(Self::ChicagoShortenedNotes), - "copernicus" => Some(Self::Copernicus), - "cse-citation-sequence-brackets-8th-edition" => Some(Self::CseCitationSequenceBrackets8thEdition), - "council-of-science-editors" => Some(Self::CseCitationSequenceBrackets8thEdition), - "cse-name-year" => Some(Self::CseNameYear), - "council-of-science-editors-author-date" => Some(Self::CseNameYear), - "current-opinion" => Some(Self::CurrentOpinion), - "deutsche-gesellschaft-für-psychologie" => Some(Self::DeutscheGesellschaftFürPsychologie), - "deutsche-sprache" => Some(Self::DeutscheSprache), - "elsevier-harvard" => Some(Self::ElsevierHarvard), - "elsevier-vancouver" => Some(Self::ElsevierVancouver), - "elsevier-with-titles" => Some(Self::ElsevierWithTitles), - "frontiers" => Some(Self::Frontiers), - "future-medicine" => Some(Self::FutureMedicine), - "future-science" => Some(Self::FutureScience), - "gb-7714-2005-numeric" => Some(Self::Gb77142005Numeric), - "gb-7714-2015-author-date" => Some(Self::Gb77142015AuthorDate), - "gb-7714-2015-note" => Some(Self::Gb77142015Note), - "gb-7714-2015-numeric" => Some(Self::Gb77142015Numeric), - "gost-r-705-2008-numeric" => Some(Self::GostR7052008Numeric), - "harvard-cite-them-right" => Some(Self::HarvardCiteThemRight), - "institute-of-electrical-and-electronics-engineers" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), - "ieee" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), - "institute-of-physics-numeric" => Some(Self::InstituteOfPhysicsNumeric), - "iso-690-author-date" => Some(Self::Iso690AuthorDate), - "iso-690-numeric" => Some(Self::Iso690Numeric), - "karger" => Some(Self::Karger), - "mary-ann-liebert-vancouver" => Some(Self::MaryAnnLiebertVancouver), - "modern-humanities-research-association-notes" => Some(Self::ModernHumanitiesResearchAssociationNotes), - "modern-humanities-research-association" => Some(Self::ModernHumanitiesResearchAssociationNotes), - "modern-language-association" => Some(Self::ModernLanguageAssociation), - "mla" => Some(Self::ModernLanguageAssociation), - "modern-language-association-8" => Some(Self::ModernLanguageAssociation), - "mla-8" => Some(Self::ModernLanguageAssociation), - "multidisciplinary-digital-publishing-institute" => Some(Self::MultidisciplinaryDigitalPublishingInstitute), - "nature" => Some(Self::Nature), - "nlm-citation-sequence" => Some(Self::NlmCitationSequence), - "vancouver" => Some(Self::NlmCitationSequence), - "nlm-citation-sequence-superscript" => Some(Self::NlmCitationSequenceSuperscript), - "vancouver-superscript" => Some(Self::NlmCitationSequenceSuperscript), - "pensoft" => Some(Self::Pensoft), - "public-library-of-science" => Some(Self::PublicLibraryOfScience), - "plos" => Some(Self::PublicLibraryOfScience), - "royal-society-of-chemistry" => Some(Self::RoyalSocietyOfChemistry), - "sage-vancouver" => Some(Self::SageVancouver), - "sist02" => Some(Self::Sist02), - "spie" => Some(Self::Spie), - "springer-basic" => Some(Self::SpringerBasic), - "springer-basic-author-date" => Some(Self::SpringerBasicAuthorDate), - "springer-fachzeitschriften-medizin-psychologie" => Some(Self::SpringerFachzeitschriftenMedizinPsychologie), - "springer-humanities-author-date" => Some(Self::SpringerHumanitiesAuthorDate), - "springer-lecture-notes-in-computer-science" => Some(Self::SpringerLectureNotesInComputerScience), - "springer-mathphys" => Some(Self::SpringerMathphys), - "springer-socpsych-author-date" => Some(Self::SpringerSocpsychAuthorDate), - "springer-vancouver" => Some(Self::SpringerVancouver), - "taylor-and-francis-chicago-author-date" => Some(Self::TaylorAndFrancisChicagoAuthorDate), - "taylor-and-francis-national-library-of-medicine" => Some(Self::TaylorAndFrancisNationalLibraryOfMedicine), - "the-institution-of-engineering-and-technology" => Some(Self::TheInstitutionOfEngineeringAndTechnology), - "the-lancet" => Some(Self::TheLancet), - "thieme" => Some(Self::Thieme), - "trends" => Some(Self::Trends), - "turabian-author-date" => Some(Self::TurabianAuthorDate), - "turabian-fullnote-8" => Some(Self::TurabianFullnote8), - _ => None, - } - } - - /// Retrieve this style by CSL ID. - pub fn by_id(id: &str) -> Option { - match id { - "http://typst.org/csl/alphanumeric" => Some(Self::Alphanumeric), - "http://www.zotero.org/styles/american-anthropological-association" => Some(Self::AmericanAnthropologicalAssociation), - "http://www.zotero.org/styles/american-chemical-society" => Some(Self::AmericanChemicalSociety), - "http://www.zotero.org/styles/american-geophysical-union" => Some(Self::AmericanGeophysicalUnion), - "http://www.zotero.org/styles/american-institute-of-aeronautics-and-astronautics" => Some(Self::AmericanInstituteOfAeronauticsAndAstronautics), - "http://www.zotero.org/styles/american-institute-of-physics" => Some(Self::AmericanInstituteOfPhysics), - "http://www.zotero.org/styles/american-medical-association" => Some(Self::AmericanMedicalAssociation), - "http://www.zotero.org/styles/american-meteorological-society" => Some(Self::AmericanMeteorologicalSociety), - "http://www.zotero.org/styles/american-physics-society" => Some(Self::AmericanPhysicsSociety), - "http://www.zotero.org/styles/american-physiological-society" => Some(Self::AmericanPhysiologicalSociety), - "http://www.zotero.org/styles/american-political-science-association" => Some(Self::AmericanPoliticalScienceAssociation), - "http://www.zotero.org/styles/apa" => Some(Self::AmericanPsychologicalAssociation), - "http://www.zotero.org/styles/american-society-for-microbiology" => Some(Self::AmericanSocietyForMicrobiology), - "http://www.zotero.org/styles/american-society-of-civil-engineers" => Some(Self::AmericanSocietyOfCivilEngineers), - "http://www.zotero.org/styles/american-society-of-mechanical-engineers" => Some(Self::AmericanSocietyOfMechanicalEngineers), - "http://www.zotero.org/styles/american-sociological-association" => Some(Self::AmericanSociologicalAssociation), - "http://www.zotero.org/styles/angewandte-chemie" => Some(Self::AngewandteChemie), - "http://www.zotero.org/styles/annual-reviews" => Some(Self::AnnualReviews), - "http://www.zotero.org/styles/annual-reviews-author-date" => Some(Self::AnnualReviewsAuthorDate), - "http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas" => Some(Self::AssociacaoBrasileiraDeNormasTecnicas), - "http://www.zotero.org/styles/association-for-computing-machinery" => Some(Self::AssociationForComputingMachinery), - "http://www.zotero.org/styles/biomed-central" => Some(Self::BiomedCentral), - "http://www.zotero.org/styles/bristol-university-press" => Some(Self::BristolUniversityPress), - "http://www.zotero.org/styles/bmj" => Some(Self::BritishMedicalJournal), - "http://www.zotero.org/styles/cell" => Some(Self::Cell), - "http://www.zotero.org/styles/chicago-author-date" => Some(Self::ChicagoAuthorDate), - "http://www.zotero.org/styles/chicago-notes-bibliography" => Some(Self::ChicagoNotes), - "http://www.zotero.org/styles/chicago-shortened-notes-bibliography" => Some(Self::ChicagoShortenedNotes), - "http://www.zotero.org/styles/copernicus-publications" => Some(Self::Copernicus), - "http://www.zotero.org/styles/cse-citation-sequence-brackets-8th-edition" => Some(Self::CseCitationSequenceBrackets8thEdition), - "http://www.zotero.org/styles/cse-name-year" => Some(Self::CseNameYear), - "http://www.zotero.org/styles/current-opinion" => Some(Self::CurrentOpinion), - "http://www.zotero.org/styles/deutsche-gesellschaft-fur-psychologie" => Some(Self::DeutscheGesellschaftFürPsychologie), - "http://www.zotero.org/styles/deutsche-sprache" => Some(Self::DeutscheSprache), - "http://www.zotero.org/styles/elsevier-harvard" => Some(Self::ElsevierHarvard), - "http://www.zotero.org/styles/elsevier-vancouver" => Some(Self::ElsevierVancouver), - "http://www.zotero.org/styles/elsevier-with-titles" => Some(Self::ElsevierWithTitles), - "http://www.zotero.org/styles/frontiers" => Some(Self::Frontiers), - "http://www.zotero.org/styles/future-medicine" => Some(Self::FutureMedicine), - "http://www.zotero.org/styles/future-science-group" => Some(Self::FutureScience), - "http://www.zotero.org/styles/chinese-gb7714-2005-numeric" => Some(Self::Gb77142005Numeric), - "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-author-date" => Some(Self::Gb77142015AuthorDate), - "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-note" => Some(Self::Gb77142015Note), - "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-numeric" => Some(Self::Gb77142015Numeric), - "http://www.zotero.org/styles/gost-r-7-0-5-2008-numeric" => Some(Self::GostR7052008Numeric), - "http://www.zotero.org/styles/harvard-cite-them-right" => Some(Self::HarvardCiteThemRight), - "http://www.zotero.org/styles/ieee" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), - "http://www.zotero.org/styles/institute-of-physics-numeric" => Some(Self::InstituteOfPhysicsNumeric), - "http://www.zotero.org/styles/iso690-author-date-en" => Some(Self::Iso690AuthorDate), - "http://www.zotero.org/styles/iso690-numeric-en" => Some(Self::Iso690Numeric), - "http://www.zotero.org/styles/karger-journals" => Some(Self::Karger), - "http://www.zotero.org/styles/mary-ann-liebert-vancouver" => Some(Self::MaryAnnLiebertVancouver), - "http://www.zotero.org/styles/mhra-notes" => Some(Self::ModernHumanitiesResearchAssociationNotes), - "http://www.zotero.org/styles/modern-language-association" => Some(Self::ModernLanguageAssociation), - "http://www.zotero.org/styles/multidisciplinary-digital-publishing-institute" => Some(Self::MultidisciplinaryDigitalPublishingInstitute), - "http://www.zotero.org/styles/nature" => Some(Self::Nature), - "http://www.zotero.org/styles/nlm-citation-sequence" => Some(Self::NlmCitationSequence), - "http://www.zotero.org/styles/nlm-citation-sequence-superscript" => Some(Self::NlmCitationSequenceSuperscript), - "http://www.zotero.org/styles/pensoft-journals" => Some(Self::Pensoft), - "http://www.zotero.org/styles/plos" => Some(Self::PublicLibraryOfScience), - "http://www.zotero.org/styles/royal-society-of-chemistry" => Some(Self::RoyalSocietyOfChemistry), - "http://www.zotero.org/styles/sage-vancouver" => Some(Self::SageVancouver), - "http://www.zotero.org/styles/sist02" => Some(Self::Sist02), - "http://www.zotero.org/styles/spie-journals" => Some(Self::Spie), - "http://www.zotero.org/styles/springer-basic-brackets" => Some(Self::SpringerBasic), - "http://www.zotero.org/styles/springer-basic-author-date" => Some(Self::SpringerBasicAuthorDate), - "http://www.zotero.org/styles/springer-fachzeitschriften-medizin-psychologie" => Some(Self::SpringerFachzeitschriftenMedizinPsychologie), - "http://www.zotero.org/styles/springer-humanities-author-date" => Some(Self::SpringerHumanitiesAuthorDate), - "http://www.zotero.org/styles/springer-lecture-notes-in-computer-science" => Some(Self::SpringerLectureNotesInComputerScience), - "http://www.zotero.org/styles/springer-mathphys-brackets" => Some(Self::SpringerMathphys), - "http://www.zotero.org/styles/springer-socpsych-author-date" => Some(Self::SpringerSocpsychAuthorDate), - "http://www.zotero.org/styles/springer-vancouver-brackets" => Some(Self::SpringerVancouver), - "http://www.zotero.org/styles/taylor-and-francis-chicago-author-date" => Some(Self::TaylorAndFrancisChicagoAuthorDate), - "http://www.zotero.org/styles/taylor-and-francis-national-library-of-medicine" => Some(Self::TaylorAndFrancisNationalLibraryOfMedicine), - "http://www.zotero.org/styles/the-institution-of-engineering-and-technology" => Some(Self::TheInstitutionOfEngineeringAndTechnology), - "http://www.zotero.org/styles/the-lancet" => Some(Self::TheLancet), - "http://www.zotero.org/styles/thieme-german" => Some(Self::Thieme), - "http://www.zotero.org/styles/trends-journals" => Some(Self::Trends), - "http://www.zotero.org/styles/chicago-author-date-17th-edition" => Some(Self::TurabianAuthorDate), - "http://www.zotero.org/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition" => Some(Self::TurabianFullnote8), - _ => None - } - } - - /// Returns all variants. - pub fn all() -> &'static [Self] { - &[ - Self::Alphanumeric, - Self::AmericanAnthropologicalAssociation, - Self::AmericanChemicalSociety, - Self::AmericanGeophysicalUnion, - Self::AmericanInstituteOfAeronauticsAndAstronautics, - Self::AmericanInstituteOfPhysics, - Self::AmericanMedicalAssociation, - Self::AmericanMeteorologicalSociety, - Self::AmericanPhysicsSociety, - Self::AmericanPhysiologicalSociety, - Self::AmericanPoliticalScienceAssociation, - Self::AmericanPsychologicalAssociation, - Self::AmericanSocietyForMicrobiology, - Self::AmericanSocietyOfCivilEngineers, - Self::AmericanSocietyOfMechanicalEngineers, - Self::AmericanSociologicalAssociation, - Self::AngewandteChemie, - Self::AnnualReviews, - Self::AnnualReviewsAuthorDate, - Self::AssociacaoBrasileiraDeNormasTecnicas, - Self::AssociationForComputingMachinery, - Self::BiomedCentral, - Self::BristolUniversityPress, - Self::BritishMedicalJournal, - Self::Cell, - Self::ChicagoAuthorDate, - Self::ChicagoNotes, - Self::ChicagoShortenedNotes, - Self::Copernicus, - Self::CseCitationSequenceBrackets8thEdition, - Self::CseNameYear, - Self::CurrentOpinion, - Self::DeutscheGesellschaftFürPsychologie, - Self::DeutscheSprache, - Self::ElsevierHarvard, - Self::ElsevierVancouver, - Self::ElsevierWithTitles, - Self::Frontiers, - Self::FutureMedicine, - Self::FutureScience, - Self::Gb77142005Numeric, - Self::Gb77142015AuthorDate, - Self::Gb77142015Note, - Self::Gb77142015Numeric, - Self::GostR7052008Numeric, - Self::HarvardCiteThemRight, - Self::InstituteOfElectricalAndElectronicsEngineers, - Self::InstituteOfPhysicsNumeric, - Self::Iso690AuthorDate, - Self::Iso690Numeric, - Self::Karger, - Self::MaryAnnLiebertVancouver, - Self::ModernHumanitiesResearchAssociationNotes, - Self::ModernLanguageAssociation, - Self::MultidisciplinaryDigitalPublishingInstitute, - Self::Nature, - Self::NlmCitationSequence, - Self::NlmCitationSequenceSuperscript, - Self::Pensoft, - Self::PublicLibraryOfScience, - Self::RoyalSocietyOfChemistry, - Self::SageVancouver, - Self::Sist02, - Self::Spie, - Self::SpringerBasic, - Self::SpringerBasicAuthorDate, - Self::SpringerFachzeitschriftenMedizinPsychologie, - Self::SpringerHumanitiesAuthorDate, - Self::SpringerLectureNotesInComputerScience, - Self::SpringerMathphys, - Self::SpringerSocpsychAuthorDate, - Self::SpringerVancouver, - Self::TaylorAndFrancisChicagoAuthorDate, - Self::TaylorAndFrancisNationalLibraryOfMedicine, - Self::TheInstitutionOfEngineeringAndTechnology, - Self::TheLancet, - Self::Thieme, - Self::Trends, - Self::TurabianAuthorDate, - Self::TurabianFullnote8, - ] - } - - /// Get the CBOR representation of this style. - fn bytes(self) -> &'static [u8] { - match self { - Self::Alphanumeric => include_bytes!("../../archive/styles/alphanumeric.cbor"), - Self::AmericanAnthropologicalAssociation => include_bytes!("../../archive/styles/american-anthropological-association.cbor"), - Self::AmericanChemicalSociety => include_bytes!("../../archive/styles/american-chemical-society.cbor"), - Self::AmericanGeophysicalUnion => include_bytes!("../../archive/styles/american-geophysical-union.cbor"), - Self::AmericanInstituteOfAeronauticsAndAstronautics => include_bytes!("../../archive/styles/american-institute-of-aeronautics-and-astronautics.cbor"), - Self::AmericanInstituteOfPhysics => include_bytes!("../../archive/styles/american-institute-of-physics.cbor"), - Self::AmericanMedicalAssociation => include_bytes!("../../archive/styles/american-medical-association.cbor"), - Self::AmericanMeteorologicalSociety => include_bytes!("../../archive/styles/american-meteorological-society.cbor"), - Self::AmericanPhysicsSociety => include_bytes!("../../archive/styles/american-physics-society.cbor"), - Self::AmericanPhysiologicalSociety => include_bytes!("../../archive/styles/american-physiological-society.cbor"), - Self::AmericanPoliticalScienceAssociation => include_bytes!("../../archive/styles/american-political-science-association.cbor"), - Self::AmericanPsychologicalAssociation => include_bytes!("../../archive/styles/apa.cbor"), - Self::AmericanSocietyForMicrobiology => include_bytes!("../../archive/styles/american-society-for-microbiology.cbor"), - Self::AmericanSocietyOfCivilEngineers => include_bytes!("../../archive/styles/american-society-of-civil-engineers.cbor"), - Self::AmericanSocietyOfMechanicalEngineers => include_bytes!("../../archive/styles/american-society-of-mechanical-engineers.cbor"), - Self::AmericanSociologicalAssociation => include_bytes!("../../archive/styles/american-sociological-association.cbor"), - Self::AngewandteChemie => include_bytes!("../../archive/styles/angewandte-chemie.cbor"), - Self::AnnualReviews => include_bytes!("../../archive/styles/annual-reviews.cbor"), - Self::AnnualReviewsAuthorDate => include_bytes!("../../archive/styles/annual-reviews-author-date.cbor"), - Self::AssociacaoBrasileiraDeNormasTecnicas => include_bytes!("../../archive/styles/associacao-brasileira-de-normas-tecnicas.cbor"), - Self::AssociationForComputingMachinery => include_bytes!("../../archive/styles/association-for-computing-machinery.cbor"), - Self::BiomedCentral => include_bytes!("../../archive/styles/biomed-central.cbor"), - Self::BristolUniversityPress => include_bytes!("../../archive/styles/bristol-university-press.cbor"), - Self::BritishMedicalJournal => include_bytes!("../../archive/styles/bmj.cbor"), - Self::Cell => include_bytes!("../../archive/styles/cell.cbor"), - Self::ChicagoAuthorDate => include_bytes!("../../archive/styles/chicago-author-date.cbor"), - Self::ChicagoNotes => include_bytes!("../../archive/styles/chicago-notes-bibliography.cbor"), - Self::ChicagoShortenedNotes => include_bytes!("../../archive/styles/chicago-shortened-notes-bibliography.cbor"), - Self::Copernicus => include_bytes!("../../archive/styles/copernicus-publications.cbor"), - Self::CseCitationSequenceBrackets8thEdition => include_bytes!("../../archive/styles/cse-citation-sequence-brackets-8th-edition.cbor"), - Self::CseNameYear => include_bytes!("../../archive/styles/cse-name-year.cbor"), - Self::CurrentOpinion => include_bytes!("../../archive/styles/current-opinion.cbor"), - Self::DeutscheGesellschaftFürPsychologie => include_bytes!("../../archive/styles/deutsche-gesellschaft-fur-psychologie.cbor"), - Self::DeutscheSprache => include_bytes!("../../archive/styles/deutsche-sprache.cbor"), - Self::ElsevierHarvard => include_bytes!("../../archive/styles/elsevier-harvard.cbor"), - Self::ElsevierVancouver => include_bytes!("../../archive/styles/elsevier-vancouver.cbor"), - Self::ElsevierWithTitles => include_bytes!("../../archive/styles/elsevier-with-titles.cbor"), - Self::Frontiers => include_bytes!("../../archive/styles/frontiers.cbor"), - Self::FutureMedicine => include_bytes!("../../archive/styles/future-medicine.cbor"), - Self::FutureScience => include_bytes!("../../archive/styles/future-science-group.cbor"), - Self::Gb77142005Numeric => include_bytes!("../../archive/styles/chinese-gb7714-2005-numeric.cbor"), - Self::Gb77142015AuthorDate => include_bytes!("../../archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor"), - Self::Gb77142015Note => include_bytes!("../../archive/styles/china-national-standard-gb-t-7714-2015-note.cbor"), - Self::Gb77142015Numeric => include_bytes!("../../archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor"), - Self::GostR7052008Numeric => include_bytes!("../../archive/styles/gost-r-7-0-5-2008-numeric.cbor"), - Self::HarvardCiteThemRight => include_bytes!("../../archive/styles/harvard-cite-them-right.cbor"), - Self::InstituteOfElectricalAndElectronicsEngineers => include_bytes!("../../archive/styles/ieee.cbor"), - Self::InstituteOfPhysicsNumeric => include_bytes!("../../archive/styles/institute-of-physics-numeric.cbor"), - Self::Iso690AuthorDate => include_bytes!("../../archive/styles/iso690-author-date-en.cbor"), - Self::Iso690Numeric => include_bytes!("../../archive/styles/iso690-numeric-en.cbor"), - Self::Karger => include_bytes!("../../archive/styles/karger-journals.cbor"), - Self::MaryAnnLiebertVancouver => include_bytes!("../../archive/styles/mary-ann-liebert-vancouver.cbor"), - Self::ModernHumanitiesResearchAssociationNotes => include_bytes!("../../archive/styles/mhra-notes.cbor"), - Self::ModernLanguageAssociation => include_bytes!("../../archive/styles/modern-language-association.cbor"), - Self::MultidisciplinaryDigitalPublishingInstitute => include_bytes!("../../archive/styles/multidisciplinary-digital-publishing-institute.cbor"), - Self::Nature => include_bytes!("../../archive/styles/nature.cbor"), - Self::NlmCitationSequence => include_bytes!("../../archive/styles/nlm-citation-sequence.cbor"), - Self::NlmCitationSequenceSuperscript => include_bytes!("../../archive/styles/nlm-citation-sequence-superscript.cbor"), - Self::Pensoft => include_bytes!("../../archive/styles/pensoft-journals.cbor"), - Self::PublicLibraryOfScience => include_bytes!("../../archive/styles/plos.cbor"), - Self::RoyalSocietyOfChemistry => include_bytes!("../../archive/styles/royal-society-of-chemistry.cbor"), - Self::SageVancouver => include_bytes!("../../archive/styles/sage-vancouver.cbor"), - Self::Sist02 => include_bytes!("../../archive/styles/sist02.cbor"), - Self::Spie => include_bytes!("../../archive/styles/spie-journals.cbor"), - Self::SpringerBasic => include_bytes!("../../archive/styles/springer-basic-brackets.cbor"), - Self::SpringerBasicAuthorDate => include_bytes!("../../archive/styles/springer-basic-author-date.cbor"), - Self::SpringerFachzeitschriftenMedizinPsychologie => include_bytes!("../../archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor"), - Self::SpringerHumanitiesAuthorDate => include_bytes!("../../archive/styles/springer-humanities-author-date.cbor"), - Self::SpringerLectureNotesInComputerScience => include_bytes!("../../archive/styles/springer-lecture-notes-in-computer-science.cbor"), - Self::SpringerMathphys => include_bytes!("../../archive/styles/springer-mathphys-brackets.cbor"), - Self::SpringerSocpsychAuthorDate => include_bytes!("../../archive/styles/springer-socpsych-author-date.cbor"), - Self::SpringerVancouver => include_bytes!("../../archive/styles/springer-vancouver-brackets.cbor"), - Self::TaylorAndFrancisChicagoAuthorDate => include_bytes!("../../archive/styles/taylor-and-francis-chicago-author-date.cbor"), - Self::TaylorAndFrancisNationalLibraryOfMedicine => include_bytes!("../../archive/styles/taylor-and-francis-national-library-of-medicine.cbor"), - Self::TheInstitutionOfEngineeringAndTechnology => include_bytes!("../../archive/styles/the-institution-of-engineering-and-technology.cbor"), - Self::TheLancet => include_bytes!("../../archive/styles/the-lancet.cbor"), - Self::Thieme => include_bytes!("../../archive/styles/thieme-german.cbor"), - Self::Trends => include_bytes!("../../archive/styles/trends-journals.cbor"), - Self::TurabianAuthorDate => include_bytes!("../../archive/styles/chicago-author-date-17th-edition.cbor"), - Self::TurabianFullnote8 => include_bytes!("../../archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor"), - } - } - - /// Retrieve the style. - pub fn get(self) -> Style { - from_cbor(self.bytes()).unwrap() - } - - /// Get the style's names in Hayagriva. - pub fn names(self) -> &'static [&'static str] { - match self { - Self::Alphanumeric => &[ - "alphanumeric", - ], - Self::AmericanAnthropologicalAssociation => &[ - "american-anthropological-association", - ], - Self::AmericanChemicalSociety => &[ - "american-chemical-society", - ], - Self::AmericanGeophysicalUnion => &[ - "american-geophysical-union", - ], - Self::AmericanInstituteOfAeronauticsAndAstronautics => &[ - "american-institute-of-aeronautics-and-astronautics", - ], - Self::AmericanInstituteOfPhysics => &[ - "american-institute-of-physics", - ], - Self::AmericanMedicalAssociation => &[ - "american-medical-association", - ], - Self::AmericanMeteorologicalSociety => &[ - "american-meteorological-society", - ], - Self::AmericanPhysicsSociety => &[ - "american-physics-society", - ], - Self::AmericanPhysiologicalSociety => &[ - "american-physiological-society", - ], - Self::AmericanPoliticalScienceAssociation => &[ - "american-political-science-association", - ], - Self::AmericanPsychologicalAssociation => &[ - "american-psychological-association", - "apa", - ], - Self::AmericanSocietyForMicrobiology => &[ - "american-society-for-microbiology", - ], - Self::AmericanSocietyOfCivilEngineers => &[ - "american-society-of-civil-engineers", - ], - Self::AmericanSocietyOfMechanicalEngineers => &[ - "american-society-of-mechanical-engineers", - ], - Self::AmericanSociologicalAssociation => &[ - "american-sociological-association", - ], - Self::AngewandteChemie => &[ - "angewandte-chemie", - ], - Self::AnnualReviews => &[ - "annual-reviews", - ], - Self::AnnualReviewsAuthorDate => &[ - "annual-reviews-author-date", - ], - Self::AssociacaoBrasileiraDeNormasTecnicas => &[ - "associacao-brasileira-de-normas-tecnicas", - ], - Self::AssociationForComputingMachinery => &[ - "association-for-computing-machinery", - ], - Self::BiomedCentral => &[ - "biomed-central", - ], - Self::BristolUniversityPress => &[ - "bristol-university-press", - ], - Self::BritishMedicalJournal => &[ - "british-medical-journal", - "bmj", - ], - Self::Cell => &[ - "cell", - ], - Self::ChicagoAuthorDate => &[ - "chicago-author-date", - ], - Self::ChicagoNotes => &[ - "chicago-notes", - "chicago-fullnotes", - ], - Self::ChicagoShortenedNotes => &[ - "chicago-shortened-notes", - ], - Self::Copernicus => &[ - "copernicus", - ], - Self::CseCitationSequenceBrackets8thEdition => &[ - "cse-citation-sequence-brackets-8th-edition", - "council-of-science-editors", - ], - Self::CseNameYear => &[ - "cse-name-year", - "council-of-science-editors-author-date", - ], - Self::CurrentOpinion => &[ - "current-opinion", - ], - Self::DeutscheGesellschaftFürPsychologie => &[ - "deutsche-gesellschaft-für-psychologie", - ], - Self::DeutscheSprache => &[ - "deutsche-sprache", - ], - Self::ElsevierHarvard => &[ - "elsevier-harvard", - ], - Self::ElsevierVancouver => &[ - "elsevier-vancouver", - ], - Self::ElsevierWithTitles => &[ - "elsevier-with-titles", - ], - Self::Frontiers => &[ - "frontiers", - ], - Self::FutureMedicine => &[ - "future-medicine", - ], - Self::FutureScience => &[ - "future-science", - ], - Self::Gb77142005Numeric => &[ - "gb-7714-2005-numeric", - ], - Self::Gb77142015AuthorDate => &[ - "gb-7714-2015-author-date", - ], - Self::Gb77142015Note => &[ - "gb-7714-2015-note", - ], - Self::Gb77142015Numeric => &[ - "gb-7714-2015-numeric", - ], - Self::GostR7052008Numeric => &[ - "gost-r-705-2008-numeric", - ], - Self::HarvardCiteThemRight => &[ - "harvard-cite-them-right", - ], - Self::InstituteOfElectricalAndElectronicsEngineers => &[ - "institute-of-electrical-and-electronics-engineers", - "ieee", - ], - Self::InstituteOfPhysicsNumeric => &[ - "institute-of-physics-numeric", - ], - Self::Iso690AuthorDate => &[ - "iso-690-author-date", - ], - Self::Iso690Numeric => &[ - "iso-690-numeric", - ], - Self::Karger => &[ - "karger", - ], - Self::MaryAnnLiebertVancouver => &[ - "mary-ann-liebert-vancouver", - ], - Self::ModernHumanitiesResearchAssociationNotes => &[ - "modern-humanities-research-association-notes", - "modern-humanities-research-association", - ], - Self::ModernLanguageAssociation => &[ - "modern-language-association", - "mla", - "modern-language-association-8", - "mla-8", - ], - Self::MultidisciplinaryDigitalPublishingInstitute => &[ - "multidisciplinary-digital-publishing-institute", - ], - Self::Nature => &[ - "nature", - ], - Self::NlmCitationSequence => &[ - "nlm-citation-sequence", - "vancouver", - ], - Self::NlmCitationSequenceSuperscript => &[ - "nlm-citation-sequence-superscript", - "vancouver-superscript", - ], - Self::Pensoft => &[ - "pensoft", - ], - Self::PublicLibraryOfScience => &[ - "public-library-of-science", - "plos", - ], - Self::RoyalSocietyOfChemistry => &[ - "royal-society-of-chemistry", - ], - Self::SageVancouver => &[ - "sage-vancouver", - ], - Self::Sist02 => &[ - "sist02", - ], - Self::Spie => &[ - "spie", - ], - Self::SpringerBasic => &[ - "springer-basic", - ], - Self::SpringerBasicAuthorDate => &[ - "springer-basic-author-date", - ], - Self::SpringerFachzeitschriftenMedizinPsychologie => &[ - "springer-fachzeitschriften-medizin-psychologie", - ], - Self::SpringerHumanitiesAuthorDate => &[ - "springer-humanities-author-date", - ], - Self::SpringerLectureNotesInComputerScience => &[ - "springer-lecture-notes-in-computer-science", - ], - Self::SpringerMathphys => &[ - "springer-mathphys", - ], - Self::SpringerSocpsychAuthorDate => &[ - "springer-socpsych-author-date", - ], - Self::SpringerVancouver => &[ - "springer-vancouver", - ], - Self::TaylorAndFrancisChicagoAuthorDate => &[ - "taylor-and-francis-chicago-author-date", - ], - Self::TaylorAndFrancisNationalLibraryOfMedicine => &[ - "taylor-and-francis-national-library-of-medicine", - ], - Self::TheInstitutionOfEngineeringAndTechnology => &[ - "the-institution-of-engineering-and-technology", - ], - Self::TheLancet => &[ - "the-lancet", - ], - Self::Thieme => &[ - "thieme", - ], - Self::Trends => &[ - "trends", - ], - Self::TurabianAuthorDate => &[ - "turabian-author-date", - ], - Self::TurabianFullnote8 => &[ - "turabian-fullnote-8", - ], - } - } - - /// Get the style's full name. - pub fn display_name(self) -> &'static str { - match self { - Self::Alphanumeric => "Alphanumeric", - Self::AmericanAnthropologicalAssociation => "American Anthropological Association", - Self::AmericanChemicalSociety => "ACS Guide 2022 revision", - Self::AmericanGeophysicalUnion => "American Geophysical Union", - Self::AmericanInstituteOfAeronauticsAndAstronautics => "American Institute of Aeronautics and Astronautics", - Self::AmericanInstituteOfPhysics => "AIP Style Manual 4th edition", - Self::AmericanMedicalAssociation => "AMA Manual of Style 11th edition", - Self::AmericanMeteorologicalSociety => "American Meteorological Society", - Self::AmericanPhysicsSociety => "American Physical Society", - Self::AmericanPhysiologicalSociety => "American Physiological Society", - Self::AmericanPoliticalScienceAssociation => "APSA Style Manual revised 2018 edition", - Self::AmericanPsychologicalAssociation => "APA Style 7th edition", - Self::AmericanSocietyForMicrobiology => "American Society for Microbiology", - Self::AmericanSocietyOfCivilEngineers => "American Society of Civil Engineers", - Self::AmericanSocietyOfMechanicalEngineers => "American Society of Mechanical Engineers", - Self::AmericanSociologicalAssociation => "ASA Style Guide 6th/7th edition", - Self::AngewandteChemie => "Angewandte Chemie International Edition", - Self::AnnualReviews => "Annual Reviews (sorted by order of appearance)", - Self::AnnualReviewsAuthorDate => "Annual Reviews (author-date)", - Self::AssociacaoBrasileiraDeNormasTecnicas => "Associação Brasileira de Normas Técnicas (Português - Brasil)", - Self::AssociationForComputingMachinery => "Association for Computing Machinery", - Self::BiomedCentral => "BioMed Central", - Self::BristolUniversityPress => "Bristol University Press", - Self::BritishMedicalJournal => "BMJ", - Self::Cell => "Cell", - Self::ChicagoAuthorDate => "Chicago Manual of Style 18th edition (author-date)", - Self::ChicagoNotes => "Chicago Manual of Style 18th edition (notes and bibliography)", - Self::ChicagoShortenedNotes => "Chicago Manual of Style 18th edition (shortened notes and bibliography)", - Self::Copernicus => "Copernicus Publications", - Self::CseCitationSequenceBrackets8thEdition => "CSE Manual: Scientific Style and Format 8th edition (citation-sequence, brackets)", - Self::CseNameYear => "CSE Manual: Scientific Style and Format 9th edition (name-year)", - Self::CurrentOpinion => "Current Opinion journals", - Self::DeutscheGesellschaftFürPsychologie => "Deutsche Gesellschaft für Psychologie 5. Auflage (Deutsch)", - Self::DeutscheSprache => "Deutsche Sprache (Deutsch)", - Self::ElsevierHarvard => "Elsevier (author-date/Harvard, with titles)", - Self::ElsevierVancouver => "Elsevier - NLM/Vancouver (citation-sequence)", - Self::ElsevierWithTitles => "Elsevier (numeric, with titles)", - Self::Frontiers => "Frontiers journals", - Self::FutureMedicine => "Future Medicine journals", - Self::FutureScience => "Future Science Group", - Self::Gb77142005Numeric => "China National Standard GB/T 7714-2005 (numeric, 中文)", - Self::Gb77142015AuthorDate => "China National Standard GB/T 7714-2015 (author-date, 中文)", - Self::Gb77142015Note => "China National Standard GB/T 7714-2015 (note, 中文)", - Self::Gb77142015Numeric => "China National Standard GB/T 7714-2015 (numeric, 中文)", - Self::GostR7052008Numeric => "Russian GOST R 7.0.5-2008 (numeric)", - Self::HarvardCiteThemRight => "Cite Them Right 12th edition (author-date/Harvard)", - Self::InstituteOfElectricalAndElectronicsEngineers => "IEEE Reference Guide version 11.29.2023", - Self::InstituteOfPhysicsNumeric => "Institute of Physics (numeric)", - Self::Iso690AuthorDate => "ISO-690 (author-date, English)", - Self::Iso690Numeric => "ISO-690 (numeric, English)", - Self::Karger => "Karger journals", - Self::MaryAnnLiebertVancouver => "Mary Ann Liebert - NLM/Vancouver", - Self::ModernHumanitiesResearchAssociationNotes => "MHRA Style Guide 4th edition (notes)", - Self::ModernLanguageAssociation => "MLA Handbook 9th edition (in-text citations)", - Self::MultidisciplinaryDigitalPublishingInstitute => "Multidisciplinary Digital Publishing Institute", - Self::Nature => "Nature", - Self::NlmCitationSequence => "NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence)", - Self::NlmCitationSequenceSuperscript => "NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence, superscript)", - Self::Pensoft => "Pensoft Journals", - Self::PublicLibraryOfScience => "Public Library of Science", - Self::RoyalSocietyOfChemistry => "Royal Society of Chemistry", - Self::SageVancouver => "SAGE - NLM/Vancouver", - Self::Sist02 => "SIST02 (日本語)", - Self::Spie => "SPIE journals", - Self::SpringerBasic => "Springer - Basic (numeric, brackets)", - Self::SpringerBasicAuthorDate => "Springer - Basic (author-date)", - Self::SpringerFachzeitschriftenMedizinPsychologie => "Springer - Fachzeitschriften Medizin Psychologie (Deutsch)", - Self::SpringerHumanitiesAuthorDate => "Springer - Humanities (author-date)", - Self::SpringerLectureNotesInComputerScience => "Springer - Lecture Notes in Computer Science", - Self::SpringerMathphys => "Springer - MathPhys (numeric, brackets)", - Self::SpringerSocpsychAuthorDate => "Springer - SocPsych (author-date)", - Self::SpringerVancouver => "Springer - NLM/Vancouver (citation-sequence, brackets)", - Self::TaylorAndFrancisChicagoAuthorDate => "Taylor & Francis Journals Standard Reference Style Guide: Chicago author-date version 2.0", - Self::TaylorAndFrancisNationalLibraryOfMedicine => "Taylor & Francis - NLM/Vancouver (citation-sequence, brackets)", - Self::TheInstitutionOfEngineeringAndTechnology => "The Institution of Engineering and Technology", - Self::TheLancet => "The Lancet", - Self::Thieme => "Thieme-German (Deutsch)", - Self::Trends => "Trends journals", - Self::TurabianAuthorDate => "Chicago Manual of Style 17th edition (author-date)", - Self::TurabianFullnote8 => "Chicago Manual of Style 17th edition (notes and bibliography, subsequent author-title)", - } - } - - /// Get the style's CSL ID. - pub fn csl_id(self) -> &'static str { - match self { - Self::Alphanumeric => "http://typst.org/csl/alphanumeric", - Self::AmericanAnthropologicalAssociation => "http://www.zotero.org/styles/american-anthropological-association", - Self::AmericanChemicalSociety => "http://www.zotero.org/styles/american-chemical-society", - Self::AmericanGeophysicalUnion => "http://www.zotero.org/styles/american-geophysical-union", - Self::AmericanInstituteOfAeronauticsAndAstronautics => "http://www.zotero.org/styles/american-institute-of-aeronautics-and-astronautics", - Self::AmericanInstituteOfPhysics => "http://www.zotero.org/styles/american-institute-of-physics", - Self::AmericanMedicalAssociation => "http://www.zotero.org/styles/american-medical-association", - Self::AmericanMeteorologicalSociety => "http://www.zotero.org/styles/american-meteorological-society", - Self::AmericanPhysicsSociety => "http://www.zotero.org/styles/american-physics-society", - Self::AmericanPhysiologicalSociety => "http://www.zotero.org/styles/american-physiological-society", - Self::AmericanPoliticalScienceAssociation => "http://www.zotero.org/styles/american-political-science-association", - Self::AmericanPsychologicalAssociation => "http://www.zotero.org/styles/apa", - Self::AmericanSocietyForMicrobiology => "http://www.zotero.org/styles/american-society-for-microbiology", - Self::AmericanSocietyOfCivilEngineers => "http://www.zotero.org/styles/american-society-of-civil-engineers", - Self::AmericanSocietyOfMechanicalEngineers => "http://www.zotero.org/styles/american-society-of-mechanical-engineers", - Self::AmericanSociologicalAssociation => "http://www.zotero.org/styles/american-sociological-association", - Self::AngewandteChemie => "http://www.zotero.org/styles/angewandte-chemie", - Self::AnnualReviews => "http://www.zotero.org/styles/annual-reviews", - Self::AnnualReviewsAuthorDate => "http://www.zotero.org/styles/annual-reviews-author-date", - Self::AssociacaoBrasileiraDeNormasTecnicas => "http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas", - Self::AssociationForComputingMachinery => "http://www.zotero.org/styles/association-for-computing-machinery", - Self::BiomedCentral => "http://www.zotero.org/styles/biomed-central", - Self::BristolUniversityPress => "http://www.zotero.org/styles/bristol-university-press", - Self::BritishMedicalJournal => "http://www.zotero.org/styles/bmj", - Self::Cell => "http://www.zotero.org/styles/cell", - Self::ChicagoAuthorDate => "http://www.zotero.org/styles/chicago-author-date", - Self::ChicagoNotes => "http://www.zotero.org/styles/chicago-notes-bibliography", - Self::ChicagoShortenedNotes => "http://www.zotero.org/styles/chicago-shortened-notes-bibliography", - Self::Copernicus => "http://www.zotero.org/styles/copernicus-publications", - Self::CseCitationSequenceBrackets8thEdition => "http://www.zotero.org/styles/cse-citation-sequence-brackets-8th-edition", - Self::CseNameYear => "http://www.zotero.org/styles/cse-name-year", - Self::CurrentOpinion => "http://www.zotero.org/styles/current-opinion", - Self::DeutscheGesellschaftFürPsychologie => "http://www.zotero.org/styles/deutsche-gesellschaft-fur-psychologie", - Self::DeutscheSprache => "http://www.zotero.org/styles/deutsche-sprache", - Self::ElsevierHarvard => "http://www.zotero.org/styles/elsevier-harvard", - Self::ElsevierVancouver => "http://www.zotero.org/styles/elsevier-vancouver", - Self::ElsevierWithTitles => "http://www.zotero.org/styles/elsevier-with-titles", - Self::Frontiers => "http://www.zotero.org/styles/frontiers", - Self::FutureMedicine => "http://www.zotero.org/styles/future-medicine", - Self::FutureScience => "http://www.zotero.org/styles/future-science-group", - Self::Gb77142005Numeric => "http://www.zotero.org/styles/chinese-gb7714-2005-numeric", - Self::Gb77142015AuthorDate => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-author-date", - Self::Gb77142015Note => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-note", - Self::Gb77142015Numeric => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-numeric", - Self::GostR7052008Numeric => "http://www.zotero.org/styles/gost-r-7-0-5-2008-numeric", - Self::HarvardCiteThemRight => "http://www.zotero.org/styles/harvard-cite-them-right", - Self::InstituteOfElectricalAndElectronicsEngineers => "http://www.zotero.org/styles/ieee", - Self::InstituteOfPhysicsNumeric => "http://www.zotero.org/styles/institute-of-physics-numeric", - Self::Iso690AuthorDate => "http://www.zotero.org/styles/iso690-author-date-en", - Self::Iso690Numeric => "http://www.zotero.org/styles/iso690-numeric-en", - Self::Karger => "http://www.zotero.org/styles/karger-journals", - Self::MaryAnnLiebertVancouver => "http://www.zotero.org/styles/mary-ann-liebert-vancouver", - Self::ModernHumanitiesResearchAssociationNotes => "http://www.zotero.org/styles/mhra-notes", - Self::ModernLanguageAssociation => "http://www.zotero.org/styles/modern-language-association", - Self::MultidisciplinaryDigitalPublishingInstitute => "http://www.zotero.org/styles/multidisciplinary-digital-publishing-institute", - Self::Nature => "http://www.zotero.org/styles/nature", - Self::NlmCitationSequence => "http://www.zotero.org/styles/nlm-citation-sequence", - Self::NlmCitationSequenceSuperscript => "http://www.zotero.org/styles/nlm-citation-sequence-superscript", - Self::Pensoft => "http://www.zotero.org/styles/pensoft-journals", - Self::PublicLibraryOfScience => "http://www.zotero.org/styles/plos", - Self::RoyalSocietyOfChemistry => "http://www.zotero.org/styles/royal-society-of-chemistry", - Self::SageVancouver => "http://www.zotero.org/styles/sage-vancouver", - Self::Sist02 => "http://www.zotero.org/styles/sist02", - Self::Spie => "http://www.zotero.org/styles/spie-journals", - Self::SpringerBasic => "http://www.zotero.org/styles/springer-basic-brackets", - Self::SpringerBasicAuthorDate => "http://www.zotero.org/styles/springer-basic-author-date", - Self::SpringerFachzeitschriftenMedizinPsychologie => "http://www.zotero.org/styles/springer-fachzeitschriften-medizin-psychologie", - Self::SpringerHumanitiesAuthorDate => "http://www.zotero.org/styles/springer-humanities-author-date", - Self::SpringerLectureNotesInComputerScience => "http://www.zotero.org/styles/springer-lecture-notes-in-computer-science", - Self::SpringerMathphys => "http://www.zotero.org/styles/springer-mathphys-brackets", - Self::SpringerSocpsychAuthorDate => "http://www.zotero.org/styles/springer-socpsych-author-date", - Self::SpringerVancouver => "http://www.zotero.org/styles/springer-vancouver-brackets", - Self::TaylorAndFrancisChicagoAuthorDate => "http://www.zotero.org/styles/taylor-and-francis-chicago-author-date", - Self::TaylorAndFrancisNationalLibraryOfMedicine => "http://www.zotero.org/styles/taylor-and-francis-national-library-of-medicine", - Self::TheInstitutionOfEngineeringAndTechnology => "http://www.zotero.org/styles/the-institution-of-engineering-and-technology", - Self::TheLancet => "http://www.zotero.org/styles/the-lancet", - Self::Thieme => "http://www.zotero.org/styles/thieme-german", - Self::Trends => "http://www.zotero.org/styles/trends-journals", - Self::TurabianAuthorDate => "http://www.zotero.org/styles/chicago-author-date-17th-edition", - Self::TurabianFullnote8 => "http://www.zotero.org/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition", - } - } -} -fn from_cbor( - reader: &[u8], -) -> Result> { - ciborium::de::from_reader(reader) -} - -/// CBOR-encoded CSL locales. -pub const LOCALES: &[&[u8]] = &[ - include_bytes!("../../archive/locales/af-ZA.cbor"), - include_bytes!("../../archive/locales/ar.cbor"), - include_bytes!("../../archive/locales/bal-PK.cbor"), - include_bytes!("../../archive/locales/bg-BG.cbor"), - include_bytes!("../../archive/locales/brh-PK.cbor"), - include_bytes!("../../archive/locales/ca-AD.cbor"), - include_bytes!("../../archive/locales/cs-CZ.cbor"), - include_bytes!("../../archive/locales/cy-GB.cbor"), - include_bytes!("../../archive/locales/da-DK.cbor"), - include_bytes!("../../archive/locales/de-AT.cbor"), - include_bytes!("../../archive/locales/de-CH.cbor"), - include_bytes!("../../archive/locales/de-DE.cbor"), - include_bytes!("../../archive/locales/el-GR.cbor"), - include_bytes!("../../archive/locales/en-GB.cbor"), - include_bytes!("../../archive/locales/en-US.cbor"), - include_bytes!("../../archive/locales/es-CL.cbor"), - include_bytes!("../../archive/locales/es-ES.cbor"), - include_bytes!("../../archive/locales/es-MX.cbor"), - include_bytes!("../../archive/locales/et-EE.cbor"), - include_bytes!("../../archive/locales/eu.cbor"), - include_bytes!("../../archive/locales/fa-IR.cbor"), - include_bytes!("../../archive/locales/fi-FI.cbor"), - include_bytes!("../../archive/locales/fr-CA.cbor"), - include_bytes!("../../archive/locales/fr-FR.cbor"), - include_bytes!("../../archive/locales/gl-ES.cbor"), - include_bytes!("../../archive/locales/he-IL.cbor"), - include_bytes!("../../archive/locales/hi-IN.cbor"), - include_bytes!("../../archive/locales/hr-HR.cbor"), - include_bytes!("../../archive/locales/hu-HU.cbor"), - include_bytes!("../../archive/locales/hy-AM.cbor"), - include_bytes!("../../archive/locales/id-ID.cbor"), - include_bytes!("../../archive/locales/is-IS.cbor"), - include_bytes!("../../archive/locales/it-IT.cbor"), - include_bytes!("../../archive/locales/ja-JP.cbor"), - include_bytes!("../../archive/locales/km-KH.cbor"), - include_bytes!("../../archive/locales/ko-KR.cbor"), - include_bytes!("../../archive/locales/la.cbor"), - include_bytes!("../../archive/locales/lij-IT.cbor"), - include_bytes!("../../archive/locales/lt-LT.cbor"), - include_bytes!("../../archive/locales/lv-LV.cbor"), - include_bytes!("../../archive/locales/mn-MN.cbor"), - include_bytes!("../../archive/locales/ms-MY.cbor"), - include_bytes!("../../archive/locales/nb-NO.cbor"), - include_bytes!("../../archive/locales/nl-NL.cbor"), - include_bytes!("../../archive/locales/nn-NO.cbor"), - include_bytes!("../../archive/locales/pa-PK.cbor"), - include_bytes!("../../archive/locales/pl-PL.cbor"), - include_bytes!("../../archive/locales/pt-BR.cbor"), - include_bytes!("../../archive/locales/pt-PT.cbor"), - include_bytes!("../../archive/locales/ro-RO.cbor"), - include_bytes!("../../archive/locales/ru-RU.cbor"), - include_bytes!("../../archive/locales/sk-SK.cbor"), - include_bytes!("../../archive/locales/sl-SI.cbor"), - include_bytes!("../../archive/locales/sr-Cyrl-RS.cbor"), - include_bytes!("../../archive/locales/sr-Latn-RS.cbor"), - include_bytes!("../../archive/locales/sv-SE.cbor"), - include_bytes!("../../archive/locales/th-TH.cbor"), - include_bytes!("../../archive/locales/tl-PH.cbor"), - include_bytes!("../../archive/locales/tr-TR.cbor"), - include_bytes!("../../archive/locales/uk-UA.cbor"), - include_bytes!("../../archive/locales/vi-VN.cbor"), - include_bytes!("../../archive/locales/zh-CN.cbor"), - include_bytes!("../../archive/locales/zh-TW.cbor"), -]; - -/// Get all CSL locales. -pub fn locales() -> Vec { - LOCALES - .iter() - .map(|bytes| from_cbor::(bytes).unwrap()) - .collect() -} diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 2e16f7e3..8b137891 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,97 +1 @@ -use std::{fs, io, path::PathBuf, process::Command}; -pub const CACHE_PATH: &str = "target/haya-cache"; - -#[allow(unused)] -pub fn iter_files<'a>( - path: &'a PathBuf, - extension: &'a str, -) -> impl Iterator + 'a { - iter_files_with_name(path, extension, |_| true) -} - -pub fn iter_files_with_name<'a, F>( - path: &'a PathBuf, - extension: &'a str, - mut name_assertion: F, -) -> impl Iterator + 'a -where - F: FnMut(&str) -> bool + 'static, -{ - fs::read_dir(path).unwrap().filter_map(move |thing| { - let thing = thing.ok()?; - if !thing.file_type().ok()?.is_file() { - return None; - } - - let path = thing.path(); - let thing_ext = path.extension(); - if thing_ext?.to_str() != Some(extension) { - return None; - } - - if !name_assertion(path.file_stem()?.to_str()?) { - return None; - } - - Some(path) - }) -} - -/// Clone a repo if it does not exist, pull it otherwise. -/// -/// This function requires a `git` installation to be available in PATH. -pub fn ensure_repo( - repo_url: &str, - repo_name: &str, - branch_name: &str, -) -> Result<(), io::Error> { - let cache_path = PathBuf::from(CACHE_PATH); - fs::create_dir_all(CACHE_PATH)?; - - // Check if styles directory exists. If it does, try to git pull origin - // main. If that fails or the directory does not exist, clone the repo. - let style_path = cache_path.join(repo_name); - let clone = if style_path.exists() { - let status = Command::new("git") - .args(["pull", "origin", branch_name]) - .current_dir(&style_path) - .status() - .expect("Please ensure git is installed"); - - if !status.success() { - fs::remove_dir_all(&style_path)?; - true - } else { - false - } - } else { - true - }; - - if clone { - let status = Command::new("git") - .args([ - "clone", - repo_url, - repo_name, - "--depth", - "1", - // Do not convert LF to CRLF. - // Otherwise, CSL/XML may generate different CBOR on Unix and Windows. - "--config", - "core.autocrlf=input", - ]) - .current_dir(&cache_path) - .status() - .expect("Please ensure git is installed"); - - if !status.success() { - return Err(io::Error::other( - "Failed to clone repo. Is git installed correnctly and is the internet working?", - )); - } - } - - Ok(()) -} From badab052196f03d8b9cd123767d6e0a619152fc0 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Sat, 6 Jun 2026 09:05:24 +0200 Subject: [PATCH 02/31] Fix archive & errors --- Cargo.lock | 5 + crates/hayagriva-archive/src/lib.rs | 1210 +++++++++++++++++ crates/hayagriva-archive/tests/archiver.rs | 14 +- crates/hayagriva-cli/Cargo.toml | 4 + crates/hayagriva-cli/src/main.rs | 10 +- crates/hayagriva-core/src/lang/mod.rs | 17 +- crates/hayagriva-csl/src/elem.rs | 2 +- crates/hayagriva-csl/src/lib.rs | 9 +- crates/hayagriva-csl/src/rendering/mod.rs | 38 +- crates/hayagriva-csl/src/rendering/names.rs | 3 +- crates/hayagriva-format/Cargo.toml | 1 + .../src/citation_label.rs | 2 + crates/hayagriva-format/src/lib.rs | 1 + crates/hayagriva-format/src/taxonomy.rs | 2 + crates/hayagriva-util/src/test_util.rs | 2 +- 15 files changed, 1274 insertions(+), 46 deletions(-) rename crates/{hayagriva-csl => hayagriva-format}/src/citation_label.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index 03b4fab7..76279e0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,6 +216,10 @@ dependencies = [ "citationberg", "clap", "hayagriva-archive", + "hayagriva-biblatex", + "hayagriva-core", + "hayagriva-csl", + "hayagriva-format", "strum 0.26.3", ] @@ -248,6 +252,7 @@ dependencies = [ name = "hayagriva-format" version = "0.10.0" dependencies = [ + "biblatex", "citationberg", "hayagriva-core", "indexmap", diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index e69de29b..44b31132 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -0,0 +1,1210 @@ +//! Optional archive of included CSL styles. +// This file is generated by tests/generate.rs +// Do not edit by hand! + +use citationberg::{Locale, Style}; +use serde::de::DeserializeOwned; + +/// An embedded CSL style. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum ArchivedStyle { + /// Alphanumeric. + /// + /// Authors: Martin Haug, Laurenz Mädje. + Alphanumeric, + /// American Anthropological Association. + /// + /// Authors: Sebastian Karcher. + AmericanAnthropologicalAssociation, + /// ACS Guide 2022 revision. + /// + /// Authors: Julian Onions. + AmericanChemicalSociety, + /// American Geophysical Union. + /// + /// Authors: Julian Onions, Simon Kornblith. + AmericanGeophysicalUnion, + /// American Institute of Aeronautics and Astronautics. + /// + /// Authors: Garrett Foster. + AmericanInstituteOfAeronauticsAndAstronautics, + /// AIP Style Manual 4th edition. + /// + /// Authors: Richard Karnesky. + AmericanInstituteOfPhysics, + /// AMA Manual of Style 11th edition. + /// + /// Authors: Julian Onions. + AmericanMedicalAssociation, + /// American Meteorological Society. + /// + /// Authors: Carl J. Schreck, III. + AmericanMeteorologicalSociety, + /// American Physical Society. + /// + /// Authors: Richard Karnesky, Brenton M. Wiernik. + AmericanPhysicsSociety, + /// American Physiological Society. + /// + /// Authors: Michael Berkowitz. + AmericanPhysiologicalSociety, + /// APSA Style Manual revised 2018 edition. + /// + /// Authors: Julian Onions. + AmericanPoliticalScienceAssociation, + /// APA Style 7th edition. + /// + /// Authors: Brenton M. Wiernik, Andrew Dunning. + AmericanPsychologicalAssociation, + /// American Society for Microbiology. + /// + /// Authors: Julian Onions. + AmericanSocietyForMicrobiology, + /// American Society of Civil Engineers. + /// + /// Authors: Rintze Zelle. + AmericanSocietyOfCivilEngineers, + /// American Society of Mechanical Engineers. + /// + /// Authors: Richard Karnesky. + AmericanSocietyOfMechanicalEngineers, + /// ASA Style Guide 6th/7th edition. + /// + /// Authors: Julian Onions. + AmericanSociologicalAssociation, + /// Angewandte Chemie International Edition. + /// + /// Authors: Richard Karnesky. + AngewandteChemie, + /// Annual Reviews (sorted by order of appearance). + /// + /// Authors: Michael Berkowitz. + AnnualReviews, + /// Annual Reviews (author-date). + /// + /// Authors: Michael Berkowitz. + AnnualReviewsAuthorDate, + /// Associação Brasileira de Normas Técnicas (Português - Brasil). + /// + /// Authors: Juliana Geyna Régis. + AssociacaoBrasileiraDeNormasTecnicas, + /// Association for Computing Machinery. + /// + /// Authors: Patrick O'Brien. + AssociationForComputingMachinery, + /// BioMed Central. + /// + /// Authors: Robert M Flight. + BiomedCentral, + /// Bristol University Press. + /// + /// Authors: Patrick O'Brien. + BristolUniversityPress, + /// BMJ. + /// + /// Authors: Sebastian Karcher. + BritishMedicalJournal, + /// Cell. + /// + /// Authors: Adam Mark. + Cell, + /// Chicago Manual of Style 18th edition (author-date). + /// + /// Authors: Andrew Dunning. + ChicagoAuthorDate, + /// Chicago Manual of Style 18th edition (notes and bibliography). + /// + /// Authors: Andrew Dunning. + ChicagoNotes, + /// Chicago Manual of Style 18th edition (shortened notes and bibliography). + /// + /// Authors: Andrew Dunning. + ChicagoShortenedNotes, + /// Copernicus Publications. + /// + /// Authors: Julian Onions. + Copernicus, + /// CSE Manual: Scientific Style and Format 8th edition (citation-sequence, brackets). + /// + /// Authors: Pavel Giverts. + CseCitationSequenceBrackets8thEdition, + /// CSE Manual: Scientific Style and Format 9th edition (name-year). + /// + /// Authors: Patrick O'Brien. + CseNameYear, + /// Current Opinion journals. + /// + /// Authors: David M. Kaplan. + CurrentOpinion, + /// Deutsche Gesellschaft für Psychologie 5. Auflage (Deutsch). + /// + /// Authors: Daniel Hirsbrunner. + DeutscheGesellschaftFürPsychologie, + /// Deutsche Sprache (Deutsch). + /// + /// Authors: Philipp Zumstein. + DeutscheSprache, + /// Elsevier (author-date/Harvard, with titles). + /// + /// Authors: David Kaplan. + ElsevierHarvard, + /// Elsevier - NLM/Vancouver (citation-sequence). + /// + /// Authors: Richard Karnesky. + ElsevierVancouver, + /// Elsevier (numeric, with titles). + /// + /// Authors: Richard Karnesky. + ElsevierWithTitles, + /// Frontiers journals. + /// + /// Authors: Sebastian Karcher. + Frontiers, + /// Future Medicine journals. + /// + /// Authors: Patrick O'Bien. + FutureMedicine, + /// Future Science Group. + /// + /// Authors: Sebastian Karcher. + FutureScience, + /// China National Standard GB/T 7714-2005 (numeric, 中文). + /// + /// Authors: heromyth. + Gb77142005Numeric, + /// China National Standard GB/T 7714-2015 (author-date, 中文). + /// + /// Authors: 牛耕田. + Gb77142015AuthorDate, + /// China National Standard GB/T 7714-2015 (note, 中文). + /// + /// Authors: 牛耕田. + Gb77142015Note, + /// China National Standard GB/T 7714-2015 (numeric, 中文). + /// + /// Authors: 牛耕田. + Gb77142015Numeric, + /// Russian GOST R 7.0.5-2008 (numeric). + /// + /// Authors: Yurkin Maxim. + GostR7052008Numeric, + /// Cite Them Right 12th edition (author-date/Harvard). + /// + /// Authors: Patrick O'Brien. + HarvardCiteThemRight, + /// IEEE Reference Guide version 11.29.2023. + /// + /// Authors: Michael Berkowitz. + InstituteOfElectricalAndElectronicsEngineers, + /// Institute of Physics (numeric). + /// + /// Authors: Sebastian Karcher. + InstituteOfPhysicsNumeric, + /// ISO-690 (author-date, English). + /// + /// Authors: Laure Mellifluo, Raphael Grolimund, Michel Hardegger. + Iso690AuthorDate, + /// ISO-690 (numeric, English). + /// + /// Authors: Laure Mellifluo, Raphael Grolimund, Michel Hardegger. + Iso690Numeric, + /// Karger journals. + /// + /// Authors: Sebastian Karcher. + Karger, + /// Mary Ann Liebert - NLM/Vancouver. + /// + /// Authors: Patrick O'Brien. + MaryAnnLiebertVancouver, + /// MHRA Style Guide 4th edition (notes). + /// + /// Authors: Andrew Dunning. + ModernHumanitiesResearchAssociationNotes, + /// MLA Handbook 9th edition (in-text citations). + /// + /// Authors: Sebastian Karcher, Andrew Dunning. + ModernLanguageAssociation, + /// Multidisciplinary Digital Publishing Institute. + /// + /// Authors: Sebastian Karcher. + MultidisciplinaryDigitalPublishingInstitute, + /// Nature. + /// + /// Authors: Michael Berkowitz. + Nature, + /// NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence). + /// + /// Authors: Michael Berkowitz, Andrew Dunning. + NlmCitationSequence, + /// NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence, superscript). + /// + /// Authors: Michael Berkowitz, Andrew Dunning. + NlmCitationSequenceSuperscript, + /// Pensoft Journals. + /// + /// Authors: Brian Stucky, Teodor Georgiev. + Pensoft, + /// Public Library of Science. + /// + /// Authors: Sebastian Karcher. + PublicLibraryOfScience, + /// Royal Society of Chemistry. + /// + /// Authors: Julian Onions. + RoyalSocietyOfChemistry, + /// SAGE - NLM/Vancouver. + /// + /// Authors: Michael Berkowitz. + SageVancouver, + /// SIST02 (日本語). + /// + /// Authors: Shoji Takahashi. + Sist02, + /// SPIE journals. + /// + /// Authors: Yurkin Maxim. + Spie, + /// Springer - Basic (numeric, brackets). + /// + /// Authors: Charles Parnot. + SpringerBasic, + /// Springer - Basic (author-date). + /// + /// Authors: Jens Allmer. + SpringerBasicAuthorDate, + /// Springer - Fachzeitschriften Medizin Psychologie (Deutsch). + /// + /// Authors: Philipp Zumstein. + SpringerFachzeitschriftenMedizinPsychologie, + /// Springer - Humanities (author-date). + /// + /// Authors: Sebastian Karcher. + SpringerHumanitiesAuthorDate, + /// Springer - Lecture Notes in Computer Science. + /// + /// Authors: Ammar Memari. + SpringerLectureNotesInComputerScience, + /// Springer - MathPhys (numeric, brackets). + /// + /// Authors: Charles Parnot. + SpringerMathphys, + /// Springer - SocPsych (author-date). + /// + /// Authors: Charles Parnot. + SpringerSocpsychAuthorDate, + /// Springer - NLM/Vancouver (citation-sequence, brackets). + /// + /// Authors: Charles Parnot. + SpringerVancouver, + /// Taylor & Francis Journals Standard Reference Style Guide: Chicago author-date version 2.0. + /// + /// Authors: Andrew Dunning. + TaylorAndFrancisChicagoAuthorDate, + /// Taylor & Francis - NLM/Vancouver (citation-sequence, brackets). + /// + /// Authors: Sebastian Karcher. + TaylorAndFrancisNationalLibraryOfMedicine, + /// The Institution of Engineering and Technology. + /// + /// Authors: Sebastian Karcher. + TheInstitutionOfEngineeringAndTechnology, + /// The Lancet. + /// + /// Authors: Sebastian Karcher. + TheLancet, + /// Thieme-German (Deutsch). + /// + /// Authors: Sebastian Karcher. + Thieme, + /// Trends journals. + /// + /// Authors: Adam Zeilinger. + Trends, + /// Chicago Manual of Style 17th edition (author-date). + /// + /// Authors: Andrew Dunning. + TurabianAuthorDate, + /// Chicago Manual of Style 17th edition (notes and bibliography, subsequent author-title). + /// + /// Authors: Andrew Dunning. + TurabianFullnote8, +} + +#[rustfmt::skip] +impl ArchivedStyle { + /// Retrieve this style by name. + pub fn by_name(name: &str) -> Option { + match name { + "alphanumeric" => Some(Self::Alphanumeric), + "american-anthropological-association" => Some(Self::AmericanAnthropologicalAssociation), + "american-chemical-society" => Some(Self::AmericanChemicalSociety), + "american-geophysical-union" => Some(Self::AmericanGeophysicalUnion), + "american-institute-of-aeronautics-and-astronautics" => Some(Self::AmericanInstituteOfAeronauticsAndAstronautics), + "american-institute-of-physics" => Some(Self::AmericanInstituteOfPhysics), + "american-medical-association" => Some(Self::AmericanMedicalAssociation), + "american-meteorological-society" => Some(Self::AmericanMeteorologicalSociety), + "american-physics-society" => Some(Self::AmericanPhysicsSociety), + "american-physiological-society" => Some(Self::AmericanPhysiologicalSociety), + "american-political-science-association" => Some(Self::AmericanPoliticalScienceAssociation), + "american-psychological-association" => Some(Self::AmericanPsychologicalAssociation), + "apa" => Some(Self::AmericanPsychologicalAssociation), + "american-society-for-microbiology" => Some(Self::AmericanSocietyForMicrobiology), + "american-society-of-civil-engineers" => Some(Self::AmericanSocietyOfCivilEngineers), + "american-society-of-mechanical-engineers" => Some(Self::AmericanSocietyOfMechanicalEngineers), + "american-sociological-association" => Some(Self::AmericanSociologicalAssociation), + "angewandte-chemie" => Some(Self::AngewandteChemie), + "annual-reviews" => Some(Self::AnnualReviews), + "annual-reviews-author-date" => Some(Self::AnnualReviewsAuthorDate), + "associacao-brasileira-de-normas-tecnicas" => Some(Self::AssociacaoBrasileiraDeNormasTecnicas), + "association-for-computing-machinery" => Some(Self::AssociationForComputingMachinery), + "biomed-central" => Some(Self::BiomedCentral), + "bristol-university-press" => Some(Self::BristolUniversityPress), + "british-medical-journal" => Some(Self::BritishMedicalJournal), + "bmj" => Some(Self::BritishMedicalJournal), + "cell" => Some(Self::Cell), + "chicago-author-date" => Some(Self::ChicagoAuthorDate), + "chicago-notes" => Some(Self::ChicagoNotes), + "chicago-fullnotes" => Some(Self::ChicagoNotes), + "chicago-shortened-notes" => Some(Self::ChicagoShortenedNotes), + "copernicus" => Some(Self::Copernicus), + "cse-citation-sequence-brackets-8th-edition" => Some(Self::CseCitationSequenceBrackets8thEdition), + "council-of-science-editors" => Some(Self::CseCitationSequenceBrackets8thEdition), + "cse-name-year" => Some(Self::CseNameYear), + "council-of-science-editors-author-date" => Some(Self::CseNameYear), + "current-opinion" => Some(Self::CurrentOpinion), + "deutsche-gesellschaft-für-psychologie" => Some(Self::DeutscheGesellschaftFürPsychologie), + "deutsche-sprache" => Some(Self::DeutscheSprache), + "elsevier-harvard" => Some(Self::ElsevierHarvard), + "elsevier-vancouver" => Some(Self::ElsevierVancouver), + "elsevier-with-titles" => Some(Self::ElsevierWithTitles), + "frontiers" => Some(Self::Frontiers), + "future-medicine" => Some(Self::FutureMedicine), + "future-science" => Some(Self::FutureScience), + "gb-7714-2005-numeric" => Some(Self::Gb77142005Numeric), + "gb-7714-2015-author-date" => Some(Self::Gb77142015AuthorDate), + "gb-7714-2015-note" => Some(Self::Gb77142015Note), + "gb-7714-2015-numeric" => Some(Self::Gb77142015Numeric), + "gost-r-705-2008-numeric" => Some(Self::GostR7052008Numeric), + "harvard-cite-them-right" => Some(Self::HarvardCiteThemRight), + "institute-of-electrical-and-electronics-engineers" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), + "ieee" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), + "institute-of-physics-numeric" => Some(Self::InstituteOfPhysicsNumeric), + "iso-690-author-date" => Some(Self::Iso690AuthorDate), + "iso-690-numeric" => Some(Self::Iso690Numeric), + "karger" => Some(Self::Karger), + "mary-ann-liebert-vancouver" => Some(Self::MaryAnnLiebertVancouver), + "modern-humanities-research-association-notes" => Some(Self::ModernHumanitiesResearchAssociationNotes), + "modern-humanities-research-association" => Some(Self::ModernHumanitiesResearchAssociationNotes), + "modern-language-association" => Some(Self::ModernLanguageAssociation), + "mla" => Some(Self::ModernLanguageAssociation), + "modern-language-association-8" => Some(Self::ModernLanguageAssociation), + "mla-8" => Some(Self::ModernLanguageAssociation), + "multidisciplinary-digital-publishing-institute" => Some(Self::MultidisciplinaryDigitalPublishingInstitute), + "nature" => Some(Self::Nature), + "nlm-citation-sequence" => Some(Self::NlmCitationSequence), + "vancouver" => Some(Self::NlmCitationSequence), + "nlm-citation-sequence-superscript" => Some(Self::NlmCitationSequenceSuperscript), + "vancouver-superscript" => Some(Self::NlmCitationSequenceSuperscript), + "pensoft" => Some(Self::Pensoft), + "public-library-of-science" => Some(Self::PublicLibraryOfScience), + "plos" => Some(Self::PublicLibraryOfScience), + "royal-society-of-chemistry" => Some(Self::RoyalSocietyOfChemistry), + "sage-vancouver" => Some(Self::SageVancouver), + "sist02" => Some(Self::Sist02), + "spie" => Some(Self::Spie), + "springer-basic" => Some(Self::SpringerBasic), + "springer-basic-author-date" => Some(Self::SpringerBasicAuthorDate), + "springer-fachzeitschriften-medizin-psychologie" => Some(Self::SpringerFachzeitschriftenMedizinPsychologie), + "springer-humanities-author-date" => Some(Self::SpringerHumanitiesAuthorDate), + "springer-lecture-notes-in-computer-science" => Some(Self::SpringerLectureNotesInComputerScience), + "springer-mathphys" => Some(Self::SpringerMathphys), + "springer-socpsych-author-date" => Some(Self::SpringerSocpsychAuthorDate), + "springer-vancouver" => Some(Self::SpringerVancouver), + "taylor-and-francis-chicago-author-date" => Some(Self::TaylorAndFrancisChicagoAuthorDate), + "taylor-and-francis-national-library-of-medicine" => Some(Self::TaylorAndFrancisNationalLibraryOfMedicine), + "the-institution-of-engineering-and-technology" => Some(Self::TheInstitutionOfEngineeringAndTechnology), + "the-lancet" => Some(Self::TheLancet), + "thieme" => Some(Self::Thieme), + "trends" => Some(Self::Trends), + "turabian-author-date" => Some(Self::TurabianAuthorDate), + "turabian-fullnote-8" => Some(Self::TurabianFullnote8), + _ => None, + } + } + + /// Retrieve this style by CSL ID. + pub fn by_id(id: &str) -> Option { + match id { + "http://typst.org/csl/alphanumeric" => Some(Self::Alphanumeric), + "http://www.zotero.org/styles/american-anthropological-association" => Some(Self::AmericanAnthropologicalAssociation), + "http://www.zotero.org/styles/american-chemical-society" => Some(Self::AmericanChemicalSociety), + "http://www.zotero.org/styles/american-geophysical-union" => Some(Self::AmericanGeophysicalUnion), + "http://www.zotero.org/styles/american-institute-of-aeronautics-and-astronautics" => Some(Self::AmericanInstituteOfAeronauticsAndAstronautics), + "http://www.zotero.org/styles/american-institute-of-physics" => Some(Self::AmericanInstituteOfPhysics), + "http://www.zotero.org/styles/american-medical-association" => Some(Self::AmericanMedicalAssociation), + "http://www.zotero.org/styles/american-meteorological-society" => Some(Self::AmericanMeteorologicalSociety), + "http://www.zotero.org/styles/american-physics-society" => Some(Self::AmericanPhysicsSociety), + "http://www.zotero.org/styles/american-physiological-society" => Some(Self::AmericanPhysiologicalSociety), + "http://www.zotero.org/styles/american-political-science-association" => Some(Self::AmericanPoliticalScienceAssociation), + "http://www.zotero.org/styles/apa" => Some(Self::AmericanPsychologicalAssociation), + "http://www.zotero.org/styles/american-society-for-microbiology" => Some(Self::AmericanSocietyForMicrobiology), + "http://www.zotero.org/styles/american-society-of-civil-engineers" => Some(Self::AmericanSocietyOfCivilEngineers), + "http://www.zotero.org/styles/american-society-of-mechanical-engineers" => Some(Self::AmericanSocietyOfMechanicalEngineers), + "http://www.zotero.org/styles/american-sociological-association" => Some(Self::AmericanSociologicalAssociation), + "http://www.zotero.org/styles/angewandte-chemie" => Some(Self::AngewandteChemie), + "http://www.zotero.org/styles/annual-reviews" => Some(Self::AnnualReviews), + "http://www.zotero.org/styles/annual-reviews-author-date" => Some(Self::AnnualReviewsAuthorDate), + "http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas" => Some(Self::AssociacaoBrasileiraDeNormasTecnicas), + "http://www.zotero.org/styles/association-for-computing-machinery" => Some(Self::AssociationForComputingMachinery), + "http://www.zotero.org/styles/biomed-central" => Some(Self::BiomedCentral), + "http://www.zotero.org/styles/bristol-university-press" => Some(Self::BristolUniversityPress), + "http://www.zotero.org/styles/bmj" => Some(Self::BritishMedicalJournal), + "http://www.zotero.org/styles/cell" => Some(Self::Cell), + "http://www.zotero.org/styles/chicago-author-date" => Some(Self::ChicagoAuthorDate), + "http://www.zotero.org/styles/chicago-notes-bibliography" => Some(Self::ChicagoNotes), + "http://www.zotero.org/styles/chicago-shortened-notes-bibliography" => Some(Self::ChicagoShortenedNotes), + "http://www.zotero.org/styles/copernicus-publications" => Some(Self::Copernicus), + "http://www.zotero.org/styles/cse-citation-sequence-brackets-8th-edition" => Some(Self::CseCitationSequenceBrackets8thEdition), + "http://www.zotero.org/styles/cse-name-year" => Some(Self::CseNameYear), + "http://www.zotero.org/styles/current-opinion" => Some(Self::CurrentOpinion), + "http://www.zotero.org/styles/deutsche-gesellschaft-fur-psychologie" => Some(Self::DeutscheGesellschaftFürPsychologie), + "http://www.zotero.org/styles/deutsche-sprache" => Some(Self::DeutscheSprache), + "http://www.zotero.org/styles/elsevier-harvard" => Some(Self::ElsevierHarvard), + "http://www.zotero.org/styles/elsevier-vancouver" => Some(Self::ElsevierVancouver), + "http://www.zotero.org/styles/elsevier-with-titles" => Some(Self::ElsevierWithTitles), + "http://www.zotero.org/styles/frontiers" => Some(Self::Frontiers), + "http://www.zotero.org/styles/future-medicine" => Some(Self::FutureMedicine), + "http://www.zotero.org/styles/future-science-group" => Some(Self::FutureScience), + "http://www.zotero.org/styles/chinese-gb7714-2005-numeric" => Some(Self::Gb77142005Numeric), + "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-author-date" => Some(Self::Gb77142015AuthorDate), + "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-note" => Some(Self::Gb77142015Note), + "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-numeric" => Some(Self::Gb77142015Numeric), + "http://www.zotero.org/styles/gost-r-7-0-5-2008-numeric" => Some(Self::GostR7052008Numeric), + "http://www.zotero.org/styles/harvard-cite-them-right" => Some(Self::HarvardCiteThemRight), + "http://www.zotero.org/styles/ieee" => Some(Self::InstituteOfElectricalAndElectronicsEngineers), + "http://www.zotero.org/styles/institute-of-physics-numeric" => Some(Self::InstituteOfPhysicsNumeric), + "http://www.zotero.org/styles/iso690-author-date-en" => Some(Self::Iso690AuthorDate), + "http://www.zotero.org/styles/iso690-numeric-en" => Some(Self::Iso690Numeric), + "http://www.zotero.org/styles/karger-journals" => Some(Self::Karger), + "http://www.zotero.org/styles/mary-ann-liebert-vancouver" => Some(Self::MaryAnnLiebertVancouver), + "http://www.zotero.org/styles/mhra-notes" => Some(Self::ModernHumanitiesResearchAssociationNotes), + "http://www.zotero.org/styles/modern-language-association" => Some(Self::ModernLanguageAssociation), + "http://www.zotero.org/styles/multidisciplinary-digital-publishing-institute" => Some(Self::MultidisciplinaryDigitalPublishingInstitute), + "http://www.zotero.org/styles/nature" => Some(Self::Nature), + "http://www.zotero.org/styles/nlm-citation-sequence" => Some(Self::NlmCitationSequence), + "http://www.zotero.org/styles/nlm-citation-sequence-superscript" => Some(Self::NlmCitationSequenceSuperscript), + "http://www.zotero.org/styles/pensoft-journals" => Some(Self::Pensoft), + "http://www.zotero.org/styles/plos" => Some(Self::PublicLibraryOfScience), + "http://www.zotero.org/styles/royal-society-of-chemistry" => Some(Self::RoyalSocietyOfChemistry), + "http://www.zotero.org/styles/sage-vancouver" => Some(Self::SageVancouver), + "http://www.zotero.org/styles/sist02" => Some(Self::Sist02), + "http://www.zotero.org/styles/spie-journals" => Some(Self::Spie), + "http://www.zotero.org/styles/springer-basic-brackets" => Some(Self::SpringerBasic), + "http://www.zotero.org/styles/springer-basic-author-date" => Some(Self::SpringerBasicAuthorDate), + "http://www.zotero.org/styles/springer-fachzeitschriften-medizin-psychologie" => Some(Self::SpringerFachzeitschriftenMedizinPsychologie), + "http://www.zotero.org/styles/springer-humanities-author-date" => Some(Self::SpringerHumanitiesAuthorDate), + "http://www.zotero.org/styles/springer-lecture-notes-in-computer-science" => Some(Self::SpringerLectureNotesInComputerScience), + "http://www.zotero.org/styles/springer-mathphys-brackets" => Some(Self::SpringerMathphys), + "http://www.zotero.org/styles/springer-socpsych-author-date" => Some(Self::SpringerSocpsychAuthorDate), + "http://www.zotero.org/styles/springer-vancouver-brackets" => Some(Self::SpringerVancouver), + "http://www.zotero.org/styles/taylor-and-francis-chicago-author-date" => Some(Self::TaylorAndFrancisChicagoAuthorDate), + "http://www.zotero.org/styles/taylor-and-francis-national-library-of-medicine" => Some(Self::TaylorAndFrancisNationalLibraryOfMedicine), + "http://www.zotero.org/styles/the-institution-of-engineering-and-technology" => Some(Self::TheInstitutionOfEngineeringAndTechnology), + "http://www.zotero.org/styles/the-lancet" => Some(Self::TheLancet), + "http://www.zotero.org/styles/thieme-german" => Some(Self::Thieme), + "http://www.zotero.org/styles/trends-journals" => Some(Self::Trends), + "http://www.zotero.org/styles/chicago-author-date-17th-edition" => Some(Self::TurabianAuthorDate), + "http://www.zotero.org/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition" => Some(Self::TurabianFullnote8), + _ => None + } + } + + /// Returns all variants. + pub fn all() -> &'static [Self] { + &[ + Self::Alphanumeric, + Self::AmericanAnthropologicalAssociation, + Self::AmericanChemicalSociety, + Self::AmericanGeophysicalUnion, + Self::AmericanInstituteOfAeronauticsAndAstronautics, + Self::AmericanInstituteOfPhysics, + Self::AmericanMedicalAssociation, + Self::AmericanMeteorologicalSociety, + Self::AmericanPhysicsSociety, + Self::AmericanPhysiologicalSociety, + Self::AmericanPoliticalScienceAssociation, + Self::AmericanPsychologicalAssociation, + Self::AmericanSocietyForMicrobiology, + Self::AmericanSocietyOfCivilEngineers, + Self::AmericanSocietyOfMechanicalEngineers, + Self::AmericanSociologicalAssociation, + Self::AngewandteChemie, + Self::AnnualReviews, + Self::AnnualReviewsAuthorDate, + Self::AssociacaoBrasileiraDeNormasTecnicas, + Self::AssociationForComputingMachinery, + Self::BiomedCentral, + Self::BristolUniversityPress, + Self::BritishMedicalJournal, + Self::Cell, + Self::ChicagoAuthorDate, + Self::ChicagoNotes, + Self::ChicagoShortenedNotes, + Self::Copernicus, + Self::CseCitationSequenceBrackets8thEdition, + Self::CseNameYear, + Self::CurrentOpinion, + Self::DeutscheGesellschaftFürPsychologie, + Self::DeutscheSprache, + Self::ElsevierHarvard, + Self::ElsevierVancouver, + Self::ElsevierWithTitles, + Self::Frontiers, + Self::FutureMedicine, + Self::FutureScience, + Self::Gb77142005Numeric, + Self::Gb77142015AuthorDate, + Self::Gb77142015Note, + Self::Gb77142015Numeric, + Self::GostR7052008Numeric, + Self::HarvardCiteThemRight, + Self::InstituteOfElectricalAndElectronicsEngineers, + Self::InstituteOfPhysicsNumeric, + Self::Iso690AuthorDate, + Self::Iso690Numeric, + Self::Karger, + Self::MaryAnnLiebertVancouver, + Self::ModernHumanitiesResearchAssociationNotes, + Self::ModernLanguageAssociation, + Self::MultidisciplinaryDigitalPublishingInstitute, + Self::Nature, + Self::NlmCitationSequence, + Self::NlmCitationSequenceSuperscript, + Self::Pensoft, + Self::PublicLibraryOfScience, + Self::RoyalSocietyOfChemistry, + Self::SageVancouver, + Self::Sist02, + Self::Spie, + Self::SpringerBasic, + Self::SpringerBasicAuthorDate, + Self::SpringerFachzeitschriftenMedizinPsychologie, + Self::SpringerHumanitiesAuthorDate, + Self::SpringerLectureNotesInComputerScience, + Self::SpringerMathphys, + Self::SpringerSocpsychAuthorDate, + Self::SpringerVancouver, + Self::TaylorAndFrancisChicagoAuthorDate, + Self::TaylorAndFrancisNationalLibraryOfMedicine, + Self::TheInstitutionOfEngineeringAndTechnology, + Self::TheLancet, + Self::Thieme, + Self::Trends, + Self::TurabianAuthorDate, + Self::TurabianFullnote8, + ] + } + + /// Get the CBOR representation of this style. + fn bytes(self) -> &'static [u8] { + match self { + Self::Alphanumeric => include_bytes!("../../../archive/styles/alphanumeric.cbor"), + Self::AmericanAnthropologicalAssociation => include_bytes!("../../../archive/styles/american-anthropological-association.cbor"), + Self::AmericanChemicalSociety => include_bytes!("../../../archive/styles/american-chemical-society.cbor"), + Self::AmericanGeophysicalUnion => include_bytes!("../../../archive/styles/american-geophysical-union.cbor"), + Self::AmericanInstituteOfAeronauticsAndAstronautics => include_bytes!("../../../archive/styles/american-institute-of-aeronautics-and-astronautics.cbor"), + Self::AmericanInstituteOfPhysics => include_bytes!("../../../archive/styles/american-institute-of-physics.cbor"), + Self::AmericanMedicalAssociation => include_bytes!("../../../archive/styles/american-medical-association.cbor"), + Self::AmericanMeteorologicalSociety => include_bytes!("../../../archive/styles/american-meteorological-society.cbor"), + Self::AmericanPhysicsSociety => include_bytes!("../../../archive/styles/american-physics-society.cbor"), + Self::AmericanPhysiologicalSociety => include_bytes!("../../../archive/styles/american-physiological-society.cbor"), + Self::AmericanPoliticalScienceAssociation => include_bytes!("../../../archive/styles/american-political-science-association.cbor"), + Self::AmericanPsychologicalAssociation => include_bytes!("../../../archive/styles/apa.cbor"), + Self::AmericanSocietyForMicrobiology => include_bytes!("../../../archive/styles/american-society-for-microbiology.cbor"), + Self::AmericanSocietyOfCivilEngineers => include_bytes!("../../../archive/styles/american-society-of-civil-engineers.cbor"), + Self::AmericanSocietyOfMechanicalEngineers => include_bytes!("../../../archive/styles/american-society-of-mechanical-engineers.cbor"), + Self::AmericanSociologicalAssociation => include_bytes!("../../../archive/styles/american-sociological-association.cbor"), + Self::AngewandteChemie => include_bytes!("../../../archive/styles/angewandte-chemie.cbor"), + Self::AnnualReviews => include_bytes!("../../../archive/styles/annual-reviews.cbor"), + Self::AnnualReviewsAuthorDate => include_bytes!("../../../archive/styles/annual-reviews-author-date.cbor"), + Self::AssociacaoBrasileiraDeNormasTecnicas => include_bytes!("../../../archive/styles/associacao-brasileira-de-normas-tecnicas.cbor"), + Self::AssociationForComputingMachinery => include_bytes!("../../../archive/styles/association-for-computing-machinery.cbor"), + Self::BiomedCentral => include_bytes!("../../../archive/styles/biomed-central.cbor"), + Self::BristolUniversityPress => include_bytes!("../../../archive/styles/bristol-university-press.cbor"), + Self::BritishMedicalJournal => include_bytes!("../../../archive/styles/bmj.cbor"), + Self::Cell => include_bytes!("../../../archive/styles/cell.cbor"), + Self::ChicagoAuthorDate => include_bytes!("../../../archive/styles/chicago-author-date.cbor"), + Self::ChicagoNotes => include_bytes!("../../../archive/styles/chicago-notes-bibliography.cbor"), + Self::ChicagoShortenedNotes => include_bytes!("../../../archive/styles/chicago-shortened-notes-bibliography.cbor"), + Self::Copernicus => include_bytes!("../../../archive/styles/copernicus-publications.cbor"), + Self::CseCitationSequenceBrackets8thEdition => include_bytes!("../../../archive/styles/cse-citation-sequence-brackets-8th-edition.cbor"), + Self::CseNameYear => include_bytes!("../../../archive/styles/cse-name-year.cbor"), + Self::CurrentOpinion => include_bytes!("../../../archive/styles/current-opinion.cbor"), + Self::DeutscheGesellschaftFürPsychologie => include_bytes!("../../../archive/styles/deutsche-gesellschaft-fur-psychologie.cbor"), + Self::DeutscheSprache => include_bytes!("../../../archive/styles/deutsche-sprache.cbor"), + Self::ElsevierHarvard => include_bytes!("../../../archive/styles/elsevier-harvard.cbor"), + Self::ElsevierVancouver => include_bytes!("../../../archive/styles/elsevier-vancouver.cbor"), + Self::ElsevierWithTitles => include_bytes!("../../../archive/styles/elsevier-with-titles.cbor"), + Self::Frontiers => include_bytes!("../../../archive/styles/frontiers.cbor"), + Self::FutureMedicine => include_bytes!("../../../archive/styles/future-medicine.cbor"), + Self::FutureScience => include_bytes!("../../../archive/styles/future-science-group.cbor"), + Self::Gb77142005Numeric => include_bytes!("../../../archive/styles/chinese-gb7714-2005-numeric.cbor"), + Self::Gb77142015AuthorDate => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor"), + Self::Gb77142015Note => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-note.cbor"), + Self::Gb77142015Numeric => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor"), + Self::GostR7052008Numeric => include_bytes!("../../../archive/styles/gost-r-7-0-5-2008-numeric.cbor"), + Self::HarvardCiteThemRight => include_bytes!("../../../archive/styles/harvard-cite-them-right.cbor"), + Self::InstituteOfElectricalAndElectronicsEngineers => include_bytes!("../../../archive/styles/ieee.cbor"), + Self::InstituteOfPhysicsNumeric => include_bytes!("../../../archive/styles/institute-of-physics-numeric.cbor"), + Self::Iso690AuthorDate => include_bytes!("../../../archive/styles/iso690-author-date-en.cbor"), + Self::Iso690Numeric => include_bytes!("../../../archive/styles/iso690-numeric-en.cbor"), + Self::Karger => include_bytes!("../../../archive/styles/karger-journals.cbor"), + Self::MaryAnnLiebertVancouver => include_bytes!("../../../archive/styles/mary-ann-liebert-vancouver.cbor"), + Self::ModernHumanitiesResearchAssociationNotes => include_bytes!("../../../archive/styles/mhra-notes.cbor"), + Self::ModernLanguageAssociation => include_bytes!("../../../archive/styles/modern-language-association.cbor"), + Self::MultidisciplinaryDigitalPublishingInstitute => include_bytes!("../../../archive/styles/multidisciplinary-digital-publishing-institute.cbor"), + Self::Nature => include_bytes!("../../../archive/styles/nature.cbor"), + Self::NlmCitationSequence => include_bytes!("../../../archive/styles/nlm-citation-sequence.cbor"), + Self::NlmCitationSequenceSuperscript => include_bytes!("../../../archive/styles/nlm-citation-sequence-superscript.cbor"), + Self::Pensoft => include_bytes!("../../../archive/styles/pensoft-journals.cbor"), + Self::PublicLibraryOfScience => include_bytes!("../../../archive/styles/plos.cbor"), + Self::RoyalSocietyOfChemistry => include_bytes!("../../../archive/styles/royal-society-of-chemistry.cbor"), + Self::SageVancouver => include_bytes!("../../../archive/styles/sage-vancouver.cbor"), + Self::Sist02 => include_bytes!("../../../archive/styles/sist02.cbor"), + Self::Spie => include_bytes!("../../../archive/styles/spie-journals.cbor"), + Self::SpringerBasic => include_bytes!("../../../archive/styles/springer-basic-brackets.cbor"), + Self::SpringerBasicAuthorDate => include_bytes!("../../../archive/styles/springer-basic-author-date.cbor"), + Self::SpringerFachzeitschriftenMedizinPsychologie => include_bytes!("../../../archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor"), + Self::SpringerHumanitiesAuthorDate => include_bytes!("../../../archive/styles/springer-humanities-author-date.cbor"), + Self::SpringerLectureNotesInComputerScience => include_bytes!("../../../archive/styles/springer-lecture-notes-in-computer-science.cbor"), + Self::SpringerMathphys => include_bytes!("../../../archive/styles/springer-mathphys-brackets.cbor"), + Self::SpringerSocpsychAuthorDate => include_bytes!("../../../archive/styles/springer-socpsych-author-date.cbor"), + Self::SpringerVancouver => include_bytes!("../../../archive/styles/springer-vancouver-brackets.cbor"), + Self::TaylorAndFrancisChicagoAuthorDate => include_bytes!("../../../archive/styles/taylor-and-francis-chicago-author-date.cbor"), + Self::TaylorAndFrancisNationalLibraryOfMedicine => include_bytes!("../../../archive/styles/taylor-and-francis-national-library-of-medicine.cbor"), + Self::TheInstitutionOfEngineeringAndTechnology => include_bytes!("../../../archive/styles/the-institution-of-engineering-and-technology.cbor"), + Self::TheLancet => include_bytes!("../../../archive/styles/the-lancet.cbor"), + Self::Thieme => include_bytes!("../../../archive/styles/thieme-german.cbor"), + Self::Trends => include_bytes!("../../../archive/styles/trends-journals.cbor"), + Self::TurabianAuthorDate => include_bytes!("../../../archive/styles/chicago-author-date-17th-edition.cbor"), + Self::TurabianFullnote8 => include_bytes!("../../../archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor"), + } + } + + /// Retrieve the style. + pub fn get(self) -> Style { + from_cbor(self.bytes()).unwrap() + } + + /// Get the style's names in Hayagriva. + pub fn names(self) -> &'static [&'static str] { + match self { + Self::Alphanumeric => &[ + "alphanumeric", + ], + Self::AmericanAnthropologicalAssociation => &[ + "american-anthropological-association", + ], + Self::AmericanChemicalSociety => &[ + "american-chemical-society", + ], + Self::AmericanGeophysicalUnion => &[ + "american-geophysical-union", + ], + Self::AmericanInstituteOfAeronauticsAndAstronautics => &[ + "american-institute-of-aeronautics-and-astronautics", + ], + Self::AmericanInstituteOfPhysics => &[ + "american-institute-of-physics", + ], + Self::AmericanMedicalAssociation => &[ + "american-medical-association", + ], + Self::AmericanMeteorologicalSociety => &[ + "american-meteorological-society", + ], + Self::AmericanPhysicsSociety => &[ + "american-physics-society", + ], + Self::AmericanPhysiologicalSociety => &[ + "american-physiological-society", + ], + Self::AmericanPoliticalScienceAssociation => &[ + "american-political-science-association", + ], + Self::AmericanPsychologicalAssociation => &[ + "american-psychological-association", + "apa", + ], + Self::AmericanSocietyForMicrobiology => &[ + "american-society-for-microbiology", + ], + Self::AmericanSocietyOfCivilEngineers => &[ + "american-society-of-civil-engineers", + ], + Self::AmericanSocietyOfMechanicalEngineers => &[ + "american-society-of-mechanical-engineers", + ], + Self::AmericanSociologicalAssociation => &[ + "american-sociological-association", + ], + Self::AngewandteChemie => &[ + "angewandte-chemie", + ], + Self::AnnualReviews => &[ + "annual-reviews", + ], + Self::AnnualReviewsAuthorDate => &[ + "annual-reviews-author-date", + ], + Self::AssociacaoBrasileiraDeNormasTecnicas => &[ + "associacao-brasileira-de-normas-tecnicas", + ], + Self::AssociationForComputingMachinery => &[ + "association-for-computing-machinery", + ], + Self::BiomedCentral => &[ + "biomed-central", + ], + Self::BristolUniversityPress => &[ + "bristol-university-press", + ], + Self::BritishMedicalJournal => &[ + "british-medical-journal", + "bmj", + ], + Self::Cell => &[ + "cell", + ], + Self::ChicagoAuthorDate => &[ + "chicago-author-date", + ], + Self::ChicagoNotes => &[ + "chicago-notes", + "chicago-fullnotes", + ], + Self::ChicagoShortenedNotes => &[ + "chicago-shortened-notes", + ], + Self::Copernicus => &[ + "copernicus", + ], + Self::CseCitationSequenceBrackets8thEdition => &[ + "cse-citation-sequence-brackets-8th-edition", + "council-of-science-editors", + ], + Self::CseNameYear => &[ + "cse-name-year", + "council-of-science-editors-author-date", + ], + Self::CurrentOpinion => &[ + "current-opinion", + ], + Self::DeutscheGesellschaftFürPsychologie => &[ + "deutsche-gesellschaft-für-psychologie", + ], + Self::DeutscheSprache => &[ + "deutsche-sprache", + ], + Self::ElsevierHarvard => &[ + "elsevier-harvard", + ], + Self::ElsevierVancouver => &[ + "elsevier-vancouver", + ], + Self::ElsevierWithTitles => &[ + "elsevier-with-titles", + ], + Self::Frontiers => &[ + "frontiers", + ], + Self::FutureMedicine => &[ + "future-medicine", + ], + Self::FutureScience => &[ + "future-science", + ], + Self::Gb77142005Numeric => &[ + "gb-7714-2005-numeric", + ], + Self::Gb77142015AuthorDate => &[ + "gb-7714-2015-author-date", + ], + Self::Gb77142015Note => &[ + "gb-7714-2015-note", + ], + Self::Gb77142015Numeric => &[ + "gb-7714-2015-numeric", + ], + Self::GostR7052008Numeric => &[ + "gost-r-705-2008-numeric", + ], + Self::HarvardCiteThemRight => &[ + "harvard-cite-them-right", + ], + Self::InstituteOfElectricalAndElectronicsEngineers => &[ + "institute-of-electrical-and-electronics-engineers", + "ieee", + ], + Self::InstituteOfPhysicsNumeric => &[ + "institute-of-physics-numeric", + ], + Self::Iso690AuthorDate => &[ + "iso-690-author-date", + ], + Self::Iso690Numeric => &[ + "iso-690-numeric", + ], + Self::Karger => &[ + "karger", + ], + Self::MaryAnnLiebertVancouver => &[ + "mary-ann-liebert-vancouver", + ], + Self::ModernHumanitiesResearchAssociationNotes => &[ + "modern-humanities-research-association-notes", + "modern-humanities-research-association", + ], + Self::ModernLanguageAssociation => &[ + "modern-language-association", + "mla", + "modern-language-association-8", + "mla-8", + ], + Self::MultidisciplinaryDigitalPublishingInstitute => &[ + "multidisciplinary-digital-publishing-institute", + ], + Self::Nature => &[ + "nature", + ], + Self::NlmCitationSequence => &[ + "nlm-citation-sequence", + "vancouver", + ], + Self::NlmCitationSequenceSuperscript => &[ + "nlm-citation-sequence-superscript", + "vancouver-superscript", + ], + Self::Pensoft => &[ + "pensoft", + ], + Self::PublicLibraryOfScience => &[ + "public-library-of-science", + "plos", + ], + Self::RoyalSocietyOfChemistry => &[ + "royal-society-of-chemistry", + ], + Self::SageVancouver => &[ + "sage-vancouver", + ], + Self::Sist02 => &[ + "sist02", + ], + Self::Spie => &[ + "spie", + ], + Self::SpringerBasic => &[ + "springer-basic", + ], + Self::SpringerBasicAuthorDate => &[ + "springer-basic-author-date", + ], + Self::SpringerFachzeitschriftenMedizinPsychologie => &[ + "springer-fachzeitschriften-medizin-psychologie", + ], + Self::SpringerHumanitiesAuthorDate => &[ + "springer-humanities-author-date", + ], + Self::SpringerLectureNotesInComputerScience => &[ + "springer-lecture-notes-in-computer-science", + ], + Self::SpringerMathphys => &[ + "springer-mathphys", + ], + Self::SpringerSocpsychAuthorDate => &[ + "springer-socpsych-author-date", + ], + Self::SpringerVancouver => &[ + "springer-vancouver", + ], + Self::TaylorAndFrancisChicagoAuthorDate => &[ + "taylor-and-francis-chicago-author-date", + ], + Self::TaylorAndFrancisNationalLibraryOfMedicine => &[ + "taylor-and-francis-national-library-of-medicine", + ], + Self::TheInstitutionOfEngineeringAndTechnology => &[ + "the-institution-of-engineering-and-technology", + ], + Self::TheLancet => &[ + "the-lancet", + ], + Self::Thieme => &[ + "thieme", + ], + Self::Trends => &[ + "trends", + ], + Self::TurabianAuthorDate => &[ + "turabian-author-date", + ], + Self::TurabianFullnote8 => &[ + "turabian-fullnote-8", + ], + } + } + + /// Get the style's full name. + pub fn display_name(self) -> &'static str { + match self { + Self::Alphanumeric => "Alphanumeric", + Self::AmericanAnthropologicalAssociation => "American Anthropological Association", + Self::AmericanChemicalSociety => "ACS Guide 2022 revision", + Self::AmericanGeophysicalUnion => "American Geophysical Union", + Self::AmericanInstituteOfAeronauticsAndAstronautics => "American Institute of Aeronautics and Astronautics", + Self::AmericanInstituteOfPhysics => "AIP Style Manual 4th edition", + Self::AmericanMedicalAssociation => "AMA Manual of Style 11th edition", + Self::AmericanMeteorologicalSociety => "American Meteorological Society", + Self::AmericanPhysicsSociety => "American Physical Society", + Self::AmericanPhysiologicalSociety => "American Physiological Society", + Self::AmericanPoliticalScienceAssociation => "APSA Style Manual revised 2018 edition", + Self::AmericanPsychologicalAssociation => "APA Style 7th edition", + Self::AmericanSocietyForMicrobiology => "American Society for Microbiology", + Self::AmericanSocietyOfCivilEngineers => "American Society of Civil Engineers", + Self::AmericanSocietyOfMechanicalEngineers => "American Society of Mechanical Engineers", + Self::AmericanSociologicalAssociation => "ASA Style Guide 6th/7th edition", + Self::AngewandteChemie => "Angewandte Chemie International Edition", + Self::AnnualReviews => "Annual Reviews (sorted by order of appearance)", + Self::AnnualReviewsAuthorDate => "Annual Reviews (author-date)", + Self::AssociacaoBrasileiraDeNormasTecnicas => "Associação Brasileira de Normas Técnicas (Português - Brasil)", + Self::AssociationForComputingMachinery => "Association for Computing Machinery", + Self::BiomedCentral => "BioMed Central", + Self::BristolUniversityPress => "Bristol University Press", + Self::BritishMedicalJournal => "BMJ", + Self::Cell => "Cell", + Self::ChicagoAuthorDate => "Chicago Manual of Style 18th edition (author-date)", + Self::ChicagoNotes => "Chicago Manual of Style 18th edition (notes and bibliography)", + Self::ChicagoShortenedNotes => "Chicago Manual of Style 18th edition (shortened notes and bibliography)", + Self::Copernicus => "Copernicus Publications", + Self::CseCitationSequenceBrackets8thEdition => "CSE Manual: Scientific Style and Format 8th edition (citation-sequence, brackets)", + Self::CseNameYear => "CSE Manual: Scientific Style and Format 9th edition (name-year)", + Self::CurrentOpinion => "Current Opinion journals", + Self::DeutscheGesellschaftFürPsychologie => "Deutsche Gesellschaft für Psychologie 5. Auflage (Deutsch)", + Self::DeutscheSprache => "Deutsche Sprache (Deutsch)", + Self::ElsevierHarvard => "Elsevier (author-date/Harvard, with titles)", + Self::ElsevierVancouver => "Elsevier - NLM/Vancouver (citation-sequence)", + Self::ElsevierWithTitles => "Elsevier (numeric, with titles)", + Self::Frontiers => "Frontiers journals", + Self::FutureMedicine => "Future Medicine journals", + Self::FutureScience => "Future Science Group", + Self::Gb77142005Numeric => "China National Standard GB/T 7714-2005 (numeric, 中文)", + Self::Gb77142015AuthorDate => "China National Standard GB/T 7714-2015 (author-date, 中文)", + Self::Gb77142015Note => "China National Standard GB/T 7714-2015 (note, 中文)", + Self::Gb77142015Numeric => "China National Standard GB/T 7714-2015 (numeric, 中文)", + Self::GostR7052008Numeric => "Russian GOST R 7.0.5-2008 (numeric)", + Self::HarvardCiteThemRight => "Cite Them Right 12th edition (author-date/Harvard)", + Self::InstituteOfElectricalAndElectronicsEngineers => "IEEE Reference Guide version 11.29.2023", + Self::InstituteOfPhysicsNumeric => "Institute of Physics (numeric)", + Self::Iso690AuthorDate => "ISO-690 (author-date, English)", + Self::Iso690Numeric => "ISO-690 (numeric, English)", + Self::Karger => "Karger journals", + Self::MaryAnnLiebertVancouver => "Mary Ann Liebert - NLM/Vancouver", + Self::ModernHumanitiesResearchAssociationNotes => "MHRA Style Guide 4th edition (notes)", + Self::ModernLanguageAssociation => "MLA Handbook 9th edition (in-text citations)", + Self::MultidisciplinaryDigitalPublishingInstitute => "Multidisciplinary Digital Publishing Institute", + Self::Nature => "Nature", + Self::NlmCitationSequence => "NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence)", + Self::NlmCitationSequenceSuperscript => "NLM/Vancouver: Citing Medicine 2nd edition (citation-sequence, superscript)", + Self::Pensoft => "Pensoft Journals", + Self::PublicLibraryOfScience => "Public Library of Science", + Self::RoyalSocietyOfChemistry => "Royal Society of Chemistry", + Self::SageVancouver => "SAGE - NLM/Vancouver", + Self::Sist02 => "SIST02 (日本語)", + Self::Spie => "SPIE journals", + Self::SpringerBasic => "Springer - Basic (numeric, brackets)", + Self::SpringerBasicAuthorDate => "Springer - Basic (author-date)", + Self::SpringerFachzeitschriftenMedizinPsychologie => "Springer - Fachzeitschriften Medizin Psychologie (Deutsch)", + Self::SpringerHumanitiesAuthorDate => "Springer - Humanities (author-date)", + Self::SpringerLectureNotesInComputerScience => "Springer - Lecture Notes in Computer Science", + Self::SpringerMathphys => "Springer - MathPhys (numeric, brackets)", + Self::SpringerSocpsychAuthorDate => "Springer - SocPsych (author-date)", + Self::SpringerVancouver => "Springer - NLM/Vancouver (citation-sequence, brackets)", + Self::TaylorAndFrancisChicagoAuthorDate => "Taylor & Francis Journals Standard Reference Style Guide: Chicago author-date version 2.0", + Self::TaylorAndFrancisNationalLibraryOfMedicine => "Taylor & Francis - NLM/Vancouver (citation-sequence, brackets)", + Self::TheInstitutionOfEngineeringAndTechnology => "The Institution of Engineering and Technology", + Self::TheLancet => "The Lancet", + Self::Thieme => "Thieme-German (Deutsch)", + Self::Trends => "Trends journals", + Self::TurabianAuthorDate => "Chicago Manual of Style 17th edition (author-date)", + Self::TurabianFullnote8 => "Chicago Manual of Style 17th edition (notes and bibliography, subsequent author-title)", + } + } + + /// Get the style's CSL ID. + pub fn csl_id(self) -> &'static str { + match self { + Self::Alphanumeric => "http://typst.org/csl/alphanumeric", + Self::AmericanAnthropologicalAssociation => "http://www.zotero.org/styles/american-anthropological-association", + Self::AmericanChemicalSociety => "http://www.zotero.org/styles/american-chemical-society", + Self::AmericanGeophysicalUnion => "http://www.zotero.org/styles/american-geophysical-union", + Self::AmericanInstituteOfAeronauticsAndAstronautics => "http://www.zotero.org/styles/american-institute-of-aeronautics-and-astronautics", + Self::AmericanInstituteOfPhysics => "http://www.zotero.org/styles/american-institute-of-physics", + Self::AmericanMedicalAssociation => "http://www.zotero.org/styles/american-medical-association", + Self::AmericanMeteorologicalSociety => "http://www.zotero.org/styles/american-meteorological-society", + Self::AmericanPhysicsSociety => "http://www.zotero.org/styles/american-physics-society", + Self::AmericanPhysiologicalSociety => "http://www.zotero.org/styles/american-physiological-society", + Self::AmericanPoliticalScienceAssociation => "http://www.zotero.org/styles/american-political-science-association", + Self::AmericanPsychologicalAssociation => "http://www.zotero.org/styles/apa", + Self::AmericanSocietyForMicrobiology => "http://www.zotero.org/styles/american-society-for-microbiology", + Self::AmericanSocietyOfCivilEngineers => "http://www.zotero.org/styles/american-society-of-civil-engineers", + Self::AmericanSocietyOfMechanicalEngineers => "http://www.zotero.org/styles/american-society-of-mechanical-engineers", + Self::AmericanSociologicalAssociation => "http://www.zotero.org/styles/american-sociological-association", + Self::AngewandteChemie => "http://www.zotero.org/styles/angewandte-chemie", + Self::AnnualReviews => "http://www.zotero.org/styles/annual-reviews", + Self::AnnualReviewsAuthorDate => "http://www.zotero.org/styles/annual-reviews-author-date", + Self::AssociacaoBrasileiraDeNormasTecnicas => "http://www.zotero.org/styles/associacao-brasileira-de-normas-tecnicas", + Self::AssociationForComputingMachinery => "http://www.zotero.org/styles/association-for-computing-machinery", + Self::BiomedCentral => "http://www.zotero.org/styles/biomed-central", + Self::BristolUniversityPress => "http://www.zotero.org/styles/bristol-university-press", + Self::BritishMedicalJournal => "http://www.zotero.org/styles/bmj", + Self::Cell => "http://www.zotero.org/styles/cell", + Self::ChicagoAuthorDate => "http://www.zotero.org/styles/chicago-author-date", + Self::ChicagoNotes => "http://www.zotero.org/styles/chicago-notes-bibliography", + Self::ChicagoShortenedNotes => "http://www.zotero.org/styles/chicago-shortened-notes-bibliography", + Self::Copernicus => "http://www.zotero.org/styles/copernicus-publications", + Self::CseCitationSequenceBrackets8thEdition => "http://www.zotero.org/styles/cse-citation-sequence-brackets-8th-edition", + Self::CseNameYear => "http://www.zotero.org/styles/cse-name-year", + Self::CurrentOpinion => "http://www.zotero.org/styles/current-opinion", + Self::DeutscheGesellschaftFürPsychologie => "http://www.zotero.org/styles/deutsche-gesellschaft-fur-psychologie", + Self::DeutscheSprache => "http://www.zotero.org/styles/deutsche-sprache", + Self::ElsevierHarvard => "http://www.zotero.org/styles/elsevier-harvard", + Self::ElsevierVancouver => "http://www.zotero.org/styles/elsevier-vancouver", + Self::ElsevierWithTitles => "http://www.zotero.org/styles/elsevier-with-titles", + Self::Frontiers => "http://www.zotero.org/styles/frontiers", + Self::FutureMedicine => "http://www.zotero.org/styles/future-medicine", + Self::FutureScience => "http://www.zotero.org/styles/future-science-group", + Self::Gb77142005Numeric => "http://www.zotero.org/styles/chinese-gb7714-2005-numeric", + Self::Gb77142015AuthorDate => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-author-date", + Self::Gb77142015Note => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-note", + Self::Gb77142015Numeric => "http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-numeric", + Self::GostR7052008Numeric => "http://www.zotero.org/styles/gost-r-7-0-5-2008-numeric", + Self::HarvardCiteThemRight => "http://www.zotero.org/styles/harvard-cite-them-right", + Self::InstituteOfElectricalAndElectronicsEngineers => "http://www.zotero.org/styles/ieee", + Self::InstituteOfPhysicsNumeric => "http://www.zotero.org/styles/institute-of-physics-numeric", + Self::Iso690AuthorDate => "http://www.zotero.org/styles/iso690-author-date-en", + Self::Iso690Numeric => "http://www.zotero.org/styles/iso690-numeric-en", + Self::Karger => "http://www.zotero.org/styles/karger-journals", + Self::MaryAnnLiebertVancouver => "http://www.zotero.org/styles/mary-ann-liebert-vancouver", + Self::ModernHumanitiesResearchAssociationNotes => "http://www.zotero.org/styles/mhra-notes", + Self::ModernLanguageAssociation => "http://www.zotero.org/styles/modern-language-association", + Self::MultidisciplinaryDigitalPublishingInstitute => "http://www.zotero.org/styles/multidisciplinary-digital-publishing-institute", + Self::Nature => "http://www.zotero.org/styles/nature", + Self::NlmCitationSequence => "http://www.zotero.org/styles/nlm-citation-sequence", + Self::NlmCitationSequenceSuperscript => "http://www.zotero.org/styles/nlm-citation-sequence-superscript", + Self::Pensoft => "http://www.zotero.org/styles/pensoft-journals", + Self::PublicLibraryOfScience => "http://www.zotero.org/styles/plos", + Self::RoyalSocietyOfChemistry => "http://www.zotero.org/styles/royal-society-of-chemistry", + Self::SageVancouver => "http://www.zotero.org/styles/sage-vancouver", + Self::Sist02 => "http://www.zotero.org/styles/sist02", + Self::Spie => "http://www.zotero.org/styles/spie-journals", + Self::SpringerBasic => "http://www.zotero.org/styles/springer-basic-brackets", + Self::SpringerBasicAuthorDate => "http://www.zotero.org/styles/springer-basic-author-date", + Self::SpringerFachzeitschriftenMedizinPsychologie => "http://www.zotero.org/styles/springer-fachzeitschriften-medizin-psychologie", + Self::SpringerHumanitiesAuthorDate => "http://www.zotero.org/styles/springer-humanities-author-date", + Self::SpringerLectureNotesInComputerScience => "http://www.zotero.org/styles/springer-lecture-notes-in-computer-science", + Self::SpringerMathphys => "http://www.zotero.org/styles/springer-mathphys-brackets", + Self::SpringerSocpsychAuthorDate => "http://www.zotero.org/styles/springer-socpsych-author-date", + Self::SpringerVancouver => "http://www.zotero.org/styles/springer-vancouver-brackets", + Self::TaylorAndFrancisChicagoAuthorDate => "http://www.zotero.org/styles/taylor-and-francis-chicago-author-date", + Self::TaylorAndFrancisNationalLibraryOfMedicine => "http://www.zotero.org/styles/taylor-and-francis-national-library-of-medicine", + Self::TheInstitutionOfEngineeringAndTechnology => "http://www.zotero.org/styles/the-institution-of-engineering-and-technology", + Self::TheLancet => "http://www.zotero.org/styles/the-lancet", + Self::Thieme => "http://www.zotero.org/styles/thieme-german", + Self::Trends => "http://www.zotero.org/styles/trends-journals", + Self::TurabianAuthorDate => "http://www.zotero.org/styles/chicago-author-date-17th-edition", + Self::TurabianFullnote8 => "http://www.zotero.org/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition", + } + } +} +fn from_cbor( + reader: &[u8], +) -> Result> { + ciborium::de::from_reader(reader) +} + +/// CBOR-encoded CSL locales. +pub const LOCALES: &[&[u8]] = &[ + include_bytes!("../../../archive/locales/af-ZA.cbor"), + include_bytes!("../../../archive/locales/ar.cbor"), + include_bytes!("../../../archive/locales/bal-PK.cbor"), + include_bytes!("../../../archive/locales/bg-BG.cbor"), + include_bytes!("../../../archive/locales/brh-PK.cbor"), + include_bytes!("../../../archive/locales/ca-AD.cbor"), + include_bytes!("../../../archive/locales/cs-CZ.cbor"), + include_bytes!("../../../archive/locales/cy-GB.cbor"), + include_bytes!("../../../archive/locales/da-DK.cbor"), + include_bytes!("../../../archive/locales/de-AT.cbor"), + include_bytes!("../../../archive/locales/de-CH.cbor"), + include_bytes!("../../../archive/locales/de-DE.cbor"), + include_bytes!("../../../archive/locales/el-GR.cbor"), + include_bytes!("../../../archive/locales/en-GB.cbor"), + include_bytes!("../../../archive/locales/en-US.cbor"), + include_bytes!("../../../archive/locales/es-CL.cbor"), + include_bytes!("../../../archive/locales/es-ES.cbor"), + include_bytes!("../../../archive/locales/es-MX.cbor"), + include_bytes!("../../../archive/locales/et-EE.cbor"), + include_bytes!("../../../archive/locales/eu.cbor"), + include_bytes!("../../../archive/locales/fa-IR.cbor"), + include_bytes!("../../../archive/locales/fi-FI.cbor"), + include_bytes!("../../../archive/locales/fr-CA.cbor"), + include_bytes!("../../../archive/locales/fr-FR.cbor"), + include_bytes!("../../../archive/locales/gl-ES.cbor"), + include_bytes!("../../../archive/locales/he-IL.cbor"), + include_bytes!("../../../archive/locales/hi-IN.cbor"), + include_bytes!("../../../archive/locales/hr-HR.cbor"), + include_bytes!("../../../archive/locales/hu-HU.cbor"), + include_bytes!("../../../archive/locales/hy-AM.cbor"), + include_bytes!("../../../archive/locales/id-ID.cbor"), + include_bytes!("../../../archive/locales/is-IS.cbor"), + include_bytes!("../../../archive/locales/it-IT.cbor"), + include_bytes!("../../../archive/locales/ja-JP.cbor"), + include_bytes!("../../../archive/locales/km-KH.cbor"), + include_bytes!("../../../archive/locales/ko-KR.cbor"), + include_bytes!("../../../archive/locales/la.cbor"), + include_bytes!("../../../archive/locales/lij-IT.cbor"), + include_bytes!("../../../archive/locales/lt-LT.cbor"), + include_bytes!("../../../archive/locales/lv-LV.cbor"), + include_bytes!("../../../archive/locales/mn-MN.cbor"), + include_bytes!("../../../archive/locales/ms-MY.cbor"), + include_bytes!("../../../archive/locales/nb-NO.cbor"), + include_bytes!("../../../archive/locales/nl-NL.cbor"), + include_bytes!("../../../archive/locales/nn-NO.cbor"), + include_bytes!("../../../archive/locales/pa-PK.cbor"), + include_bytes!("../../../archive/locales/pl-PL.cbor"), + include_bytes!("../../../archive/locales/pt-BR.cbor"), + include_bytes!("../../../archive/locales/pt-PT.cbor"), + include_bytes!("../../../archive/locales/ro-RO.cbor"), + include_bytes!("../../../archive/locales/ru-RU.cbor"), + include_bytes!("../../../archive/locales/sk-SK.cbor"), + include_bytes!("../../../archive/locales/sl-SI.cbor"), + include_bytes!("../../../archive/locales/sr-Cyrl-RS.cbor"), + include_bytes!("../../../archive/locales/sr-Latn-RS.cbor"), + include_bytes!("../../../archive/locales/sv-SE.cbor"), + include_bytes!("../../../archive/locales/th-TH.cbor"), + include_bytes!("../../../archive/locales/tl-PH.cbor"), + include_bytes!("../../../archive/locales/tr-TR.cbor"), + include_bytes!("../../../archive/locales/uk-UA.cbor"), + include_bytes!("../../../archive/locales/vi-VN.cbor"), + include_bytes!("../../../archive/locales/zh-CN.cbor"), + include_bytes!("../../../archive/locales/zh-TW.cbor"), +]; + +/// Get all CSL locales. +pub fn locales() -> Vec { + LOCALES + .iter() + .map(|bytes| from_cbor::(bytes).unwrap()) + .collect() +} diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index dd5ee44f..220d5c47 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -29,17 +29,17 @@ use std::{ extern crate hayagriva_util; use hayagriva_util::test_util::{ - ensure_repo, iter_files, iter_files_with_name, CACHE_PATH, + CACHE_PATH, ensure_repo, iter_files, iter_files_with_name, }; const STYLES_REPO_NAME: &str = "styles"; const CSL_REPO: &str = "https://github.com/citation-style-language/styles"; const LOCALES_REPO: &str = "https://github.com/citation-style-language/locales"; const LOCALES_REPO_NAME: &str = "locales"; -const OWN_STYLES: &str = "styles"; -const ARCHIVE_STYLES_PATH: &str = "archive/styles/"; -const ARCHIVE_LOCALES_PATH: &str = "archive/locales/"; -const ARCHIVE_SRC_PATH: &str = "crates/hayagriva-archive/lib.rs"; +const OWN_STYLES: &str = "../../styles"; +const ARCHIVE_STYLES_PATH: &str = "../../archive/styles/"; +const ARCHIVE_LOCALES_PATH: &str = "../../archive/locales/"; +const ARCHIVE_SRC_PATH: &str = "src/lib.rs"; const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; @@ -320,7 +320,7 @@ fn write_styles_section( writeln!( w, - " Self::{variant} => include_bytes!(\"../../archive/styles/{stripped_id}.cbor\")," + " Self::{variant} => include_bytes!(\"../../../archive/styles/{stripped_id}.cbor\")," )?; } writeln!(w, " }}")?; @@ -384,7 +384,7 @@ fn write_locales_section(w: &mut String, items: &[(Vec, Locale)]) -> fmt::Re for (_, locale) in items { writeln!( w, - " include_bytes!(\"../../archive/locales/{}.cbor\"),", + " include_bytes!(\"../../../archive/locales/{}.cbor\"),", locale.lang.as_ref().unwrap() )?; } diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index a88e24ec..21e385c8 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -13,6 +13,10 @@ keywords.workspace = true citationberg = { workspace = true } clap = { version = "4", features = ["cargo"] } hayagriva-archive = { path = "../hayagriva-archive" } +hayagriva-biblatex = { path = "../hayagriva-biblatex" } +hayagriva-core = { path = "../hayagriva-core" } +hayagriva-csl = { path = "../hayagriva-csl" } +hayagriva-format = { path = "../hayagriva-format" } strum = { version = "0.26", features = ["derive"] } biblatex = { workspace = true, optional = true } diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index efa27076..376b0f06 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -12,12 +12,12 @@ use clap::builder::PossibleValue; use clap::{Arg, ArgAction, Command, ValueEnum, crate_version}; use strum::VariantNames; -use hayagriva::{ - BibliographyDriver, CitationItem, CitationRequest, LocatorPayload, SpecificLocator, - io, -}; -use hayagriva::{BibliographyRequest, Selector}; use hayagriva_archive::{ArchivedStyle, locales}; +use hayagriva_csl::{ + BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, + LocatorPayload, SpecificLocator, +}; +use hayagriva_format::{Selector, io}; #[derive(Debug, Copy, Clone, PartialEq, VariantNames)] #[strum(serialize_all = "kebab_case")] diff --git a/crates/hayagriva-core/src/lang/mod.rs b/crates/hayagriva-core/src/lang/mod.rs index e0b39bbb..92a2fd3c 100644 --- a/crates/hayagriva-core/src/lang/mod.rs +++ b/crates/hayagriva-core/src/lang/mod.rs @@ -5,6 +5,8 @@ pub(crate) mod name; use std::{fmt::Write, mem}; +use citationberg::TextCase; + use crate::types::{FoldableKind, FoldableStringChunk}; /// Rules for the title case transformation. @@ -135,6 +137,19 @@ impl From for Case { } } +impl From for Case { + fn from(case: TextCase) -> Self { + match case { + TextCase::Uppercase => Case::Uppercase, + TextCase::Lowercase => Case::Lowercase, + TextCase::TitleCase => Case::Title(TitleCase::default()), + TextCase::SentenceCase => Case::Sentence(SentenceCase::default()), + TextCase::CapitalizeFirst => Case::FirstUpper, + TextCase::CapitalizeAll => Case::AllUpper, + } + } +} + impl From for Case { fn from(props: SentenceCase) -> Self { Self::Sentence(props) @@ -653,7 +668,7 @@ impl CaseFolder { /// Yield the buffer as a mutable string. Must call [`Self::mark_changed`] /// if the length of the string is changed. - pub(crate) fn as_string_mut(&mut self) -> &mut String { + pub fn as_string_mut(&mut self) -> &mut String { &mut self.buf } diff --git a/crates/hayagriva-csl/src/elem.rs b/crates/hayagriva-csl/src/elem.rs index 84670eb8..459840cf 100644 --- a/crates/hayagriva-csl/src/elem.rs +++ b/crates/hayagriva-csl/src/elem.rs @@ -7,7 +7,7 @@ use citationberg::{ Display, FontStyle, FontVariant, FontWeight, TextDecoration, VerticalAlign, }; -use crate::types::Person; +use hayagriva_core::Person; /// A container for elements with useful methods. #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index 71420537..daf1bbe5 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -22,6 +22,7 @@ use citationberg::{ }; use citationberg::{DateForm, LongShortForm, OrdinalLookup, TextCase}; use hayagriva_core::lang::CaseFolder; +use hayagriva_core::{ChunkKind, ChunkedString, Date, EntryLike, MaybeTyped, Person}; use indexmap::IndexSet; use crate::elem::{NonEmptyStack, simplify_children}; @@ -33,9 +34,8 @@ use self::elem::last_text_mut_child; pub use self::elem::{ BufWriteFormat, Elem, ElemChild, ElemChildren, ElemMeta, Formatted, Formatting, }; -use self::taxonomy::{EntryLike, NumberVariableResult, PageVariableResult}; +use self::taxonomy::{NumberVariableResult, PageVariableResult}; -mod citation_label; mod elem; mod rendering; mod sort; @@ -3419,12 +3419,9 @@ mod tests { use std::{fs, path::Path}; use citationberg::LocaleFile; + use hayagriva_core::{Numeric, NumericValue}; use super::*; - use crate::{ - io::from_yaml_str, - types::{Numeric, NumericValue}, - }; #[test] fn test_csl() { diff --git a/crates/hayagriva-csl/src/rendering/mod.rs b/crates/hayagriva-csl/src/rendering/mod.rs index 876167d6..e5e30067 100644 --- a/crates/hayagriva-csl/src/rendering/mod.rs +++ b/crates/hayagriva-csl/src/rendering/mod.rs @@ -13,14 +13,15 @@ use citationberg::{ ToFormatting, }; use citationberg::{TermForm, TextTarget}; +use hayagriva_core::lang::{Case, SentenceCase, TitleCase}; +use hayagriva_core::{ + ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, PageRangesPart, +}; -use crate::PageRanges; use crate::Sorting; -use crate::lang::{Case, SentenceCase, TitleCase}; use crate::taxonomy::{NumberVariableResult, PageVariableResult}; -use crate::types::{ChunkedString, Date, MaybeTyped, Numeric}; -use super::taxonomy::{EntryLike, NumberOrPageVariableResult}; +use super::taxonomy::NumberOrPageVariableResult; use super::{Context, ElemMeta, IbidState, SpecialForm, UsageInfo, write_year}; pub mod names; @@ -460,12 +461,16 @@ fn render_page_range(range: &PageRanges, ctx: &mut Context) { .ranges .iter() .try_for_each(|r| match r { - crate::PageRangesPart::Ampersand => ctx.write_str(" & "), - crate::PageRangesPart::Comma => ctx.write_str(", "), - crate::PageRangesPart::EscapedRange(start, end) => PageRangeFormat::Expanded - .format(ctx, &start.to_string(), &end.to_string(), delim), - crate::PageRangesPart::SinglePage(page) => ctx.write_str(&page.to_string()), - crate::PageRangesPart::Range(start, end) => { + PageRangesPart::Ampersand => ctx.write_str(" & "), + PageRangesPart::Comma => ctx.write_str(", "), + PageRangesPart::EscapedRange(start, end) => PageRangeFormat::Expanded.format( + ctx, + &start.to_string(), + &end.to_string(), + delim, + ), + PageRangesPart::SinglePage(page) => ctx.write_str(&page.to_string()), + PageRangesPart::Range(start, end) => { format.format(ctx, &start.to_string(), &end.to_string(), delim) } }) @@ -1449,16 +1454,3 @@ impl RenderCsl for citationberg::RenderingElement { } } } - -impl From for Case { - fn from(case: TextCase) -> Self { - match case { - TextCase::Uppercase => Case::Uppercase, - TextCase::Lowercase => Case::Lowercase, - TextCase::TitleCase => Case::Title(TitleCase::default()), - TextCase::SentenceCase => Case::Sentence(SentenceCase::default()), - TextCase::CapitalizeFirst => Case::FirstUpper, - TextCase::CapitalizeAll => Case::AllUpper, - } - } -} diff --git a/crates/hayagriva-csl/src/rendering/names.rs b/crates/hayagriva-csl/src/rendering/names.rs index 2c3b36c0..ebaf0f64 100644 --- a/crates/hayagriva-csl/src/rendering/names.rs +++ b/crates/hayagriva-csl/src/rendering/names.rs @@ -10,9 +10,8 @@ use citationberg::{ ToFormatting, }; -use crate::taxonomy::EntryLike; -use crate::types::Person; use crate::{Context, DisambiguateState, ElemMeta, SpecialForm, UsageInfo}; +use hayagriva_core::{EntryLike, Person}; use super::{RenderCsl, render_label_with_var}; diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 9678d581..293c5b7b 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -10,6 +10,7 @@ readme.workspace = true keywords.workspace = true [dependencies] +biblatex = { workspace = true, optional = true } citationberg = { workspace = true } indexmap = { workspace = true } paste = "1.0.14" diff --git a/crates/hayagriva-csl/src/citation_label.rs b/crates/hayagriva-format/src/citation_label.rs similarity index 99% rename from crates/hayagriva-csl/src/citation_label.rs rename to crates/hayagriva-format/src/citation_label.rs index de94923e..f2b5457e 100644 --- a/crates/hayagriva-csl/src/citation_label.rs +++ b/crates/hayagriva-format/src/citation_label.rs @@ -5,6 +5,8 @@ use unicode_segmentation::UnicodeSegmentation; use hayagriva_core::types::{EntryType, Person, PersonRole}; +use crate::Entry; + /// Citation labels in the form of numbers. /// /// For example, the output could be Rass97 or MKG+21. \ diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 40ce7f8f..c6ef4f16 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -141,6 +141,7 @@ return `Some` even if no sub-entry was bound / if the hash map is empty. #[macro_use] mod selectors; +pub mod citation_label; pub mod io; pub mod taxonomy; diff --git a/crates/hayagriva-format/src/taxonomy.rs b/crates/hayagriva-format/src/taxonomy.rs index 282cbeec..8e5fe413 100644 --- a/crates/hayagriva-format/src/taxonomy.rs +++ b/crates/hayagriva-format/src/taxonomy.rs @@ -12,6 +12,8 @@ use hayagriva_core::{ }; use unic_langid::LanguageIdentifier; +use crate::citation_label::Alphanumerical; + use super::Entry; impl EntryLike for Entry { diff --git a/crates/hayagriva-util/src/test_util.rs b/crates/hayagriva-util/src/test_util.rs index 2e16f7e3..4c76b08a 100644 --- a/crates/hayagriva-util/src/test_util.rs +++ b/crates/hayagriva-util/src/test_util.rs @@ -1,6 +1,6 @@ use std::{fs, io, path::PathBuf, process::Command}; -pub const CACHE_PATH: &str = "target/haya-cache"; +pub const CACHE_PATH: &str = "../../target/haya-cache"; #[allow(unused)] pub fn iter_files<'a>( From de7faf7b85297352a5f91aad213d5a8f72a7a98f Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 20:53:37 +0200 Subject: [PATCH 03/31] Fix compilation errors --- Cargo.lock | 22 + crates/hayagriva-cli/Cargo.toml | 1 + crates/hayagriva-cli/src/main.rs | 490 +++++++++++++++++- crates/hayagriva-csl/src/lib.rs | 475 +---------------- crates/hayagriva-csl/src/rendering/mod.rs | 4 +- crates/hayagriva-format/Cargo.toml | 8 + crates/hayagriva-format/src/citation_label.rs | 1 + .../src/interop.rs | 193 +++---- crates/hayagriva-format/src/lib.rs | 1 + crates/hayagriva-format/src/taxonomy.rs | 2 + 10 files changed, 624 insertions(+), 573 deletions(-) rename crates/{hayagriva-cli => hayagriva-format}/src/interop.rs (86%) diff --git a/Cargo.lock b/Cargo.lock index 76279e0a..66cb1b77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,15 +254,18 @@ version = "0.10.0" dependencies = [ "biblatex", "citationberg", + "hayagriva-biblatex", "hayagriva-core", "indexmap", "paste", "serde", + "serde_json", "serde_yaml", "thiserror", "unic-langid", "unicode-segmentation", "unscanny", + "url", ] [[package]] @@ -585,6 +588,19 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + [[package]] name = "serde_path_to_error" version = "0.1.20" @@ -971,3 +987,9 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index 21e385c8..8c8424af 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -22,3 +22,4 @@ biblatex = { workspace = true, optional = true } [features] default = ["biblatex"] +biblatex = ["hayagriva-format/biblatex", "dep:biblatex"] diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 376b0f06..85ba2823 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -10,6 +10,8 @@ use citationberg::{ }; use clap::builder::PossibleValue; use clap::{Arg, ArgAction, Command, ValueEnum, crate_version}; +#[cfg(feature = "biblatex")] +use hayagriva_format::io::from_biblatex_str; use strum::VariantNames; use hayagriva_archive::{ArchivedStyle, locales}; @@ -233,7 +235,7 @@ fn main() { match format { Format::Yaml => io::from_yaml_str(&input).unwrap(), #[cfg(feature = "biblatex")] - Format::Biblatex | Format::Bibtex => io::from_biblatex_str(&input).unwrap(), + Format::Biblatex | Format::Bibtex => from_biblatex_str(&input).unwrap(), } }; @@ -485,3 +487,489 @@ fn retrieve_assets<'a>( (style, locales, locale) } + +#[cfg(test)] +mod tests { + use std::{borrow::Cow, fs, path::Path, sync::Arc}; + + use citationberg::{ + IndependentStyle, LocaleCode, LocaleFile, + taxonomy::{Locator, NumberVariable}, + }; + use hayagriva_core::{EntryLike, MaybeTyped, Numeric, NumericValue}; + use hayagriva_csl::{ + BibliographyDriver, BibliographyRequest, BufWriteFormat, CitationItem, + CitationRequest, CitePurpose, LocatorPayload, SpecificLocator, + TransparentLocator, + }; + use hayagriva_format::io::from_yaml_str; + + #[test] + fn test_csl() { + let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); + let en_locale = + fs::read_to_string(workspace.join("tests/data/locales-en-US.xml")).unwrap(); + let en_locale = LocaleFile::from_xml(&en_locale).unwrap(); + + let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); + let bib = from_yaml_str(&yaml).unwrap(); + let en_locale = [en_locale.into()]; + + for style_thing in fs::read_dir(workspace.join("styles/")).unwrap().take(100) { + let thing = style_thing.unwrap(); + if thing.file_type().unwrap().is_dir() { + continue; + } + + let path = thing.path(); + let extension = path.extension(); + if let Some(extension) = extension { + if extension.to_str() != Some("csl") { + continue; + } + } else { + continue; + } + + println!("testing {path:?}"); + let style = fs::read_to_string(path).unwrap(); + let style = IndependentStyle::from_xml(&style).unwrap(); + let mut driver = BibliographyDriver::new(); + + for n in (0..bib.len()).step_by(2) { + let items = vec![ + CitationItem::with_entry(bib.nth(n).unwrap()), + CitationItem::with_entry(bib.nth(n + 1).unwrap()), + ]; + driver.citation(CitationRequest::new( + items, &style, None, &en_locale, None, + )); + } + + driver.finish(BibliographyRequest { + style: &style, + locale: None, + locale_files: &en_locale, + }); + + // for cite in finished.citations { + // println!("{}", cite.citation.to_string(BufWriteFormat::Plain)) + // } + + // if let Some(bib) = finished.bibliography { + // for (prefix, item) in bib.items { + // if let Some(prefix) = prefix { + // print!("{} ", prefix.to_string(BufWriteFormat::Plain)) + // } + // println!("{}", item.to_string(BufWriteFormat::Html)) + // } + // } + } + } + + #[test] + fn test_transparent_locator_ibid() { + let test_data = r#" + katalog: + type: Book + title: "Book" + author: "Surname, Name" + location: Warsaw + date: 1971 + katalog2: + type: Book + title: "Book2" + author: "Surname, Name" + location: Warsaw + date: 1971 + "#; + let test_style = r#" + "#; + + let library = from_yaml_str(test_data).unwrap(); + let style = citationberg::Style::from_xml(test_style).unwrap(); + let citationberg::Style::Independent(style) = style else { unreachable!() }; + + let mut driver = BibliographyDriver::new(); + let citations = [ + ("katalog", Some([2, 3]), "first."), + ("katalog", Some([2, 3]), "ibid."), + ("katalog", Some([2, 3]), "ibid."), + ("katalog", Some([2, 4]), "ibid-with-locator."), + ("katalog", None, "subsequent."), + ("katalog", Some([2, 3]), "ibid-with-locator."), + ("katalog", Some([2, 3]), "ibid."), + ("katalog2", Some([2, 3]), "first."), + ]; + + for (entry, supplement, _) in citations { + let entry = library.get(entry).unwrap(); + driver.citation(CitationRequest::new( + vec![CitationItem::with_locator( + entry, + supplement.map(|s| { + SpecificLocator( + Locator::Supplement, + LocatorPayload::Transparent(TransparentLocator(Arc::new(s))), + ) + }), + )], + &style, + None, + &[], + None, + )); + } + + let finished = driver.finish(BibliographyRequest { + style: &style, + locale: None, + locale_files: &[], + }); + + for (citation, (_, _, expected_value)) in finished.citations.iter().zip(citations) + { + let mut s = String::new(); + citation.citation.write_buf(&mut s, BufWriteFormat::Plain).unwrap(); + assert_eq!(s, expected_value); + } + } + + #[test] + fn test_chapter_field() { + let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); + let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); + let bib = from_yaml_str(&yaml).unwrap(); + let book = bib.get("lamb").unwrap(); + assert_eq!(book.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(20))); + assert_eq!(book.volume().unwrap(), &MaybeTyped::Typed(Numeric::new(10))); + assert_eq!(book.keyed_serial_number("serial"), None); + assert_eq!(book.resolve_number_variable(NumberVariable::Number), None); + + let book = bib.get("snail").unwrap(); + assert_eq!( + book.chapter().unwrap(), + &MaybeTyped::Typed(Numeric { + value: NumericValue::Number(2), + prefix: None, + suffix: Some(Box::new("A".into())) + }) + ); + assert_eq!( + book.volume().unwrap(), + &MaybeTyped::Typed(Numeric { + value: NumericValue::Number(4), + prefix: None, + suffix: Some(Box::new("B".into())) + }) + ); + assert_eq!(book.keyed_serial_number("serial"), None); + assert_eq!(book.resolve_number_variable(NumberVariable::Number), None); + + let chapter = bib.get("lamb-chapter").unwrap(); + assert_eq!(chapter.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(3))); + assert_eq!(chapter.keyed_serial_number("serial"), None); + assert_eq!( + chapter.resolve_number_variable(NumberVariable::Number), + Some(MaybeTyped::Typed(Cow::Borrowed(&Numeric::new(3)))) + ); + assert_eq!(chapter.volume(), None); + assert_eq!( + chapter.parents().first().unwrap().volume().unwrap(), + &MaybeTyped::Typed(Numeric::new(10)) + ); + + let chapter = bib.get("snail-chapter").unwrap(); + assert_eq!(chapter.chapter(), None); + assert_eq!(chapter.keyed_serial_number("serial").unwrap(), "3"); + + assert_eq!(chapter.volume(), None); + assert_eq!( + chapter.parents().first().unwrap().volume().unwrap(), + &MaybeTyped::Typed(Numeric { + value: NumericValue::Number(4), + prefix: None, + suffix: Some(Box::new("B".into())) + }) + ); + } + + #[test] + fn test_alphanumeric_disambiguation() { + let bibtex = r#"@article{chenTransMorphTransformerUnsupervised2021, + title = {{{TransMorph}}: {{Transformer}} for Unsupervised Medical Image Registration}, + author = {Chen, Junyu and Frey, Eric C. and He, Yufan and Segars, William P. and Li, Ye and Du, Yong}, + date = {2021}, + } + + @article{chenViTVNetVisionTransformer2021, + title = {{{ViT-V-Net}}: {{Vision Transformer}} for {{Unsupervised Volumetric Medical Image Registration}}}, + author = {Chen, Junyu and He, Yufan and Frey, Eric C. and Li, Ye and Du, Yong}, + date = {2021}, + }"#; + + let library = crate::io::from_biblatex_str(bibtex).unwrap(); + let alphanumeric = hayagriva_archive::ArchivedStyle::Alphanumeric.get(); + let citationberg::Style::Independent(alphanumeric) = alphanumeric else { + unreachable!() + }; + + let mut driver = BibliographyDriver::new(); + for entry in library.iter() { + driver.citation(CitationRequest::new( + vec![CitationItem::with_entry(entry)], + &alphanumeric, + None, + &[], + None, + )); + } + + let finished = driver.finish(BibliographyRequest { + style: &alphanumeric, + locale: None, + locale_files: &[], + }); + + let mut c1 = String::new(); + let mut c2 = String::new(); + + finished.citations[0] + .citation + .write_buf(&mut c1, BufWriteFormat::Plain) + .unwrap(); + finished.citations[1] + .citation + .write_buf(&mut c2, BufWriteFormat::Plain) + .unwrap(); + + assert_eq!(c1, "[Che+21a]"); + assert_eq!(c2, "[Che+21b]"); + } + + #[test] + /// See https://github.com/typst/hayagriva/issues/243 + fn issue_243() { + let bibtex = r#"@book{downs57, + title = {An Economic Theory of Democracy}, + author = {Downs, Anthony}, + date = {1957}, + edition = {1}, + publisher = {Harper \& Row}, + location = {New York}, + langid = {english} + } + + @book{brady_collier10, + title = {Rethinking Social Inquiry. Diverse Tools, Shared Standards}, + editor = {Brady, Henry E. and Collier, David}, + date = {2010}, + edition = {2}, + publisher = {Rowman \& Littlefield Publishers}, + location = {Maryland} + }"#; + + let library = crate::io::from_biblatex_str(bibtex).unwrap(); + let apa = + hayagriva_archive::ArchivedStyle::AmericanPsychologicalAssociation.get(); + let citationberg::Style::Independent(apa) = apa else { unreachable!() }; + + let locales = hayagriva_archive::locales(); + + let mut driver = BibliographyDriver::new(); + for entry in library.iter() { + driver.citation(CitationRequest::new( + vec![CitationItem::new( + entry, + None, + Some(LocaleCode::en_us()), + false, + Some(CitePurpose::Prose), + )], + &apa, + Some(LocaleCode::en_us()), + &locales, + None, + )); + } + + let finished = driver.finish(BibliographyRequest { + style: &apa, + locale: Some(LocaleCode::en_us()), + locale_files: &locales, + }); + + let mut c1 = String::new(); + let mut c2 = String::new(); + + finished.citations[0] + .citation + .write_buf(&mut c1, BufWriteFormat::Plain) + .unwrap(); + finished.citations[1] + .citation + .write_buf(&mut c2, BufWriteFormat::Plain) + .unwrap(); + + assert_eq!(c1, "Downs (1957)"); + assert_eq!(c2, "Brady & Collier (2010)"); + } + + #[test] + /// See https://github.com/typst/hayagriva/issues/48 + fn issue_48() { + let bibtex = r#"@article{chenTransMorphTransformerUnsupervised2021, + title = {{{TransMorph}}: {{Transformer}} for Unsupervised Medical Image Registration}, + author = {Chen, Junyu and Frey, Eric C. and He, Yufan and Segars, William P. and Li, Ye and Du, Yong}, + date = {2021}, + } + + @article{chenViTVNetVisionTransformer2021, + title = {{{ViT-V-Net}}: {{Vision Transformer}} for {{Unsupervised Volumetric Medical Image Registration}}}, + author = {Chen, Junyu and He, Yufan and Frey, Eric C. and Li, Ye and Du, Yong}, + date = {2021}, + }"#; + + let library = crate::io::from_biblatex_str(bibtex).unwrap(); + let alphanumeric = hayagriva_archive::ArchivedStyle::Alphanumeric.get(); + let citationberg::Style::Independent(alphanumeric) = alphanumeric else { + unreachable!() + }; + + let mut driver = BibliographyDriver::new(); + + let locator = SpecificLocator(Locator::Custom, LocatorPayload::Str("12")); + for entry in library.iter() { + driver.citation(CitationRequest::new( + vec![CitationItem::with_locator(entry, Some(locator.clone()))], + &alphanumeric, + None, + &[], + None, + )); + } + + driver.citation(CitationRequest::new( + vec![CitationItem::with_locator(library.iter().next().unwrap(), None)], + &alphanumeric, + None, + &[], + None, + )); + + let finished = driver.finish(BibliographyRequest { + style: &alphanumeric, + locale: None, + locale_files: &[], + }); + + let mut c1 = String::new(); + let mut c2 = String::new(); + let mut c3 = String::new(); + + finished.citations[0] + .citation + .write_buf(&mut c1, BufWriteFormat::Plain) + .unwrap(); + finished.citations[1] + .citation + .write_buf(&mut c2, BufWriteFormat::Plain) + .unwrap(); + finished.citations[2] + .citation + .write_buf(&mut c3, BufWriteFormat::Plain) + .unwrap(); + + assert_eq!(c1, "[Che+21a, 12]"); + assert_eq!(c2, "[Che+21b, 12]"); + assert_eq!(c3, "[Che+21a]"); + } + + #[test] + fn ibid_handling_with_deutsche_sprache_csl() { + let bibtex = r#"@book{ITEM, + title = {A}, + type = {book}, + }"#; + + let library = crate::io::from_biblatex_str(bibtex).unwrap(); + let style = hayagriva_archive::ArchivedStyle::DeutscheSprache.get(); + let citationberg::Style::Independent(style) = style else { unreachable!() }; + + let mut driver = BibliographyDriver::new(); + let entry = library.iter().next().unwrap(); + + for locator in ["33", "33", "34"] { + driver.citation(CitationRequest::new( + vec![CitationItem::new( + entry, + Some(SpecificLocator(Locator::Page, LocatorPayload::Str(locator))), + None, + false, + Some(CitePurpose::Prose), + )], + &style, + None, + &[], + None, + )); + } + + let finished = driver.finish(BibliographyRequest { + style: &style, + locale: None, + locale_files: &[], + }); + + let actual = finished + .citations + .iter() + .map(|c| { + let mut s = String::new(); + c.citation.write_buf(&mut s, BufWriteFormat::Plain).unwrap(); + s + }) + .collect::>(); + + assert_eq!(actual, ["(33)", "()", "(34)"]); + } +} diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index daf1bbe5..045ee529 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -2741,7 +2741,7 @@ pub enum LocatorPayload<'a> { /// Wraps an object that is used to determine whether two locators are the same. #[derive(Clone)] -pub struct TransparentLocator(Arc); +pub struct TransparentLocator(pub Arc); impl TransparentLocator { /// Creates a new [`TransparentLocator`] which wraps the given payload. @@ -2762,7 +2762,7 @@ impl PartialEq for TransparentLocator { } } -trait TransparentLocatorPayload: Any { +pub trait TransparentLocatorPayload: Any { fn dyn_eq(&self, other: &dyn TransparentLocatorPayload) -> bool; } @@ -3423,128 +3423,6 @@ mod tests { use super::*; - #[test] - fn test_csl() { - let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); - let en_locale = - fs::read_to_string(workspace.join("tests/data/locales-en-US.xml")).unwrap(); - let en_locale = LocaleFile::from_xml(&en_locale).unwrap(); - - let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); - let bib = from_yaml_str(&yaml).unwrap(); - let en_locale = [en_locale.into()]; - - for style_thing in fs::read_dir(workspace.join("styles/")).unwrap().take(100) { - let thing = style_thing.unwrap(); - if thing.file_type().unwrap().is_dir() { - continue; - } - - let path = thing.path(); - let extension = path.extension(); - if let Some(extension) = extension { - if extension.to_str() != Some("csl") { - continue; - } - } else { - continue; - } - - println!("testing {path:?}"); - let style = fs::read_to_string(path).unwrap(); - let style = IndependentStyle::from_xml(&style).unwrap(); - let mut driver = BibliographyDriver::new(); - - for n in (0..bib.len()).step_by(2) { - let items = vec![ - CitationItem::with_entry(bib.nth(n).unwrap()), - CitationItem::with_entry(bib.nth(n + 1).unwrap()), - ]; - driver.citation(CitationRequest::new( - items, &style, None, &en_locale, None, - )); - } - - driver.finish(BibliographyRequest { - style: &style, - locale: None, - locale_files: &en_locale, - }); - - // for cite in finished.citations { - // println!("{}", cite.citation.to_string(BufWriteFormat::Plain)) - // } - - // if let Some(bib) = finished.bibliography { - // for (prefix, item) in bib.items { - // if let Some(prefix) = prefix { - // print!("{} ", prefix.to_string(BufWriteFormat::Plain)) - // } - // println!("{}", item.to_string(BufWriteFormat::Html)) - // } - // } - } - } - - #[test] - fn test_chapter_field() { - let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); - let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); - let bib = from_yaml_str(&yaml).unwrap(); - let book = bib.get("lamb").unwrap(); - assert_eq!(book.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(20))); - assert_eq!(book.volume().unwrap(), &MaybeTyped::Typed(Numeric::new(10))); - assert_eq!(book.keyed_serial_number("serial"), None); - assert_eq!(book.resolve_number_variable(NumberVariable::Number), None); - - let book = bib.get("snail").unwrap(); - assert_eq!( - book.chapter().unwrap(), - &MaybeTyped::Typed(Numeric { - value: NumericValue::Number(2), - prefix: None, - suffix: Some(Box::new("A".into())) - }) - ); - assert_eq!( - book.volume().unwrap(), - &MaybeTyped::Typed(Numeric { - value: NumericValue::Number(4), - prefix: None, - suffix: Some(Box::new("B".into())) - }) - ); - assert_eq!(book.keyed_serial_number("serial"), None); - assert_eq!(book.resolve_number_variable(NumberVariable::Number), None); - - let chapter = bib.get("lamb-chapter").unwrap(); - assert_eq!(chapter.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(3))); - assert_eq!(chapter.keyed_serial_number("serial"), None); - assert_eq!( - chapter.resolve_number_variable(NumberVariable::Number), - Some(MaybeTyped::Typed(Cow::Borrowed(&Numeric::new(3)))) - ); - assert_eq!(chapter.volume(), None); - assert_eq!( - chapter.parents().first().unwrap().volume().unwrap(), - &MaybeTyped::Typed(Numeric::new(10)) - ); - - let chapter = bib.get("snail-chapter").unwrap(); - assert_eq!(chapter.chapter(), None); - assert_eq!(chapter.keyed_serial_number("serial").unwrap(), "3"); - - assert_eq!(chapter.volume(), None); - assert_eq!( - chapter.parents().first().unwrap().volume().unwrap(), - &MaybeTyped::Typed(Numeric { - value: NumericValue::Number(4), - prefix: None, - suffix: Some(Box::new("B".into())) - }) - ); - } - #[test] fn low_year_test() { let yield_year = |year, short| { @@ -3562,353 +3440,4 @@ mod tests { assert_eq!(yield_year(-1, true), "2BC"); assert_eq!(yield_year(1, true), "1AD"); } - - #[test] - fn test_transparent_locator_ibid() { - let test_data = r#" - katalog: - type: Book - title: "Book" - author: "Surname, Name" - location: Warsaw - date: 1971 - katalog2: - type: Book - title: "Book2" - author: "Surname, Name" - location: Warsaw - date: 1971 - "#; - let test_style = r#" - "#; - - let library = from_yaml_str(test_data).unwrap(); - let style = citationberg::Style::from_xml(test_style).unwrap(); - let citationberg::Style::Independent(style) = style else { unreachable!() }; - - let mut driver = BibliographyDriver::new(); - let citations = [ - ("katalog", Some([2, 3]), "first."), - ("katalog", Some([2, 3]), "ibid."), - ("katalog", Some([2, 3]), "ibid."), - ("katalog", Some([2, 4]), "ibid-with-locator."), - ("katalog", None, "subsequent."), - ("katalog", Some([2, 3]), "ibid-with-locator."), - ("katalog", Some([2, 3]), "ibid."), - ("katalog2", Some([2, 3]), "first."), - ]; - - for (entry, supplement, _) in citations { - let entry = library.get(entry).unwrap(); - driver.citation(CitationRequest::new( - vec![CitationItem::with_locator( - entry, - supplement.map(|s| { - SpecificLocator( - Locator::Supplement, - LocatorPayload::Transparent(TransparentLocator(Arc::new(s))), - ) - }), - )], - &style, - None, - &[], - None, - )); - } - - let finished = driver.finish(BibliographyRequest { - style: &style, - locale: None, - locale_files: &[], - }); - - for (citation, (_, _, expected_value)) in finished.citations.iter().zip(citations) - { - let mut s = String::new(); - citation.citation.write_buf(&mut s, BufWriteFormat::Plain).unwrap(); - assert_eq!(s, expected_value); - } - } - - #[test] - #[cfg(feature = "archive")] - fn test_alphanumeric_disambiguation() { - let bibtex = r#"@article{chenTransMorphTransformerUnsupervised2021, - title = {{{TransMorph}}: {{Transformer}} for Unsupervised Medical Image Registration}, - author = {Chen, Junyu and Frey, Eric C. and He, Yufan and Segars, William P. and Li, Ye and Du, Yong}, - date = {2021}, - } - - @article{chenViTVNetVisionTransformer2021, - title = {{{ViT-V-Net}}: {{Vision Transformer}} for {{Unsupervised Volumetric Medical Image Registration}}}, - author = {Chen, Junyu and He, Yufan and Frey, Eric C. and Li, Ye and Du, Yong}, - date = {2021}, - }"#; - - let library = crate::io::from_biblatex_str(bibtex).unwrap(); - let alphanumeric = archive::ArchivedStyle::Alphanumeric.get(); - let citationberg::Style::Independent(alphanumeric) = alphanumeric else { - unreachable!() - }; - - let mut driver = BibliographyDriver::new(); - for entry in library.iter() { - driver.citation(CitationRequest::new( - vec![CitationItem::with_entry(entry)], - &alphanumeric, - None, - &[], - None, - )); - } - - let finished = driver.finish(BibliographyRequest { - style: &alphanumeric, - locale: None, - locale_files: &[], - }); - - let mut c1 = String::new(); - let mut c2 = String::new(); - - finished.citations[0] - .citation - .write_buf(&mut c1, BufWriteFormat::Plain) - .unwrap(); - finished.citations[1] - .citation - .write_buf(&mut c2, BufWriteFormat::Plain) - .unwrap(); - - assert_eq!(c1, "[Che+21a]"); - assert_eq!(c2, "[Che+21b]"); - } - - #[test] - #[cfg(feature = "archive")] - /// See https://github.com/typst/hayagriva/issues/243 - fn issue_243() { - let bibtex = r#"@book{downs57, - title = {An Economic Theory of Democracy}, - author = {Downs, Anthony}, - date = {1957}, - edition = {1}, - publisher = {Harper \& Row}, - location = {New York}, - langid = {english} - } - - @book{brady_collier10, - title = {Rethinking Social Inquiry. Diverse Tools, Shared Standards}, - editor = {Brady, Henry E. and Collier, David}, - date = {2010}, - edition = {2}, - publisher = {Rowman \& Littlefield Publishers}, - location = {Maryland} - }"#; - - let library = crate::io::from_biblatex_str(bibtex).unwrap(); - let apa = archive::ArchivedStyle::AmericanPsychologicalAssociation.get(); - let citationberg::Style::Independent(apa) = apa else { unreachable!() }; - - let locales = archive::locales(); - - let mut driver = BibliographyDriver::new(); - for entry in library.iter() { - driver.citation(CitationRequest::new( - vec![CitationItem::new( - entry, - None, - Some(LocaleCode::en_us()), - false, - Some(CitePurpose::Prose), - )], - &apa, - Some(LocaleCode::en_us()), - &locales, - None, - )); - } - - let finished = driver.finish(BibliographyRequest { - style: &apa, - locale: Some(LocaleCode::en_us()), - locale_files: &locales, - }); - - let mut c1 = String::new(); - let mut c2 = String::new(); - - finished.citations[0] - .citation - .write_buf(&mut c1, BufWriteFormat::Plain) - .unwrap(); - finished.citations[1] - .citation - .write_buf(&mut c2, BufWriteFormat::Plain) - .unwrap(); - - assert_eq!(c1, "Downs (1957)"); - assert_eq!(c2, "Brady & Collier (2010)"); - } - #[test] - #[cfg(feature = "archive")] - /// See https://github.com/typst/hayagriva/issues/48 - fn issue_48() { - let bibtex = r#"@article{chenTransMorphTransformerUnsupervised2021, - title = {{{TransMorph}}: {{Transformer}} for Unsupervised Medical Image Registration}, - author = {Chen, Junyu and Frey, Eric C. and He, Yufan and Segars, William P. and Li, Ye and Du, Yong}, - date = {2021}, - } - - @article{chenViTVNetVisionTransformer2021, - title = {{{ViT-V-Net}}: {{Vision Transformer}} for {{Unsupervised Volumetric Medical Image Registration}}}, - author = {Chen, Junyu and He, Yufan and Frey, Eric C. and Li, Ye and Du, Yong}, - date = {2021}, - }"#; - - let library = crate::io::from_biblatex_str(bibtex).unwrap(); - let alphanumeric = archive::ArchivedStyle::Alphanumeric.get(); - let citationberg::Style::Independent(alphanumeric) = alphanumeric else { - unreachable!() - }; - - let mut driver = BibliographyDriver::new(); - - let locator = SpecificLocator(Locator::Custom, LocatorPayload::Str("12")); - for entry in library.iter() { - driver.citation(CitationRequest::new( - vec![CitationItem::with_locator(entry, Some(locator.clone()))], - &alphanumeric, - None, - &[], - None, - )); - } - - driver.citation(CitationRequest::new( - vec![CitationItem::with_locator(library.iter().next().unwrap(), None)], - &alphanumeric, - None, - &[], - None, - )); - - let finished = driver.finish(BibliographyRequest { - style: &alphanumeric, - locale: None, - locale_files: &[], - }); - - let mut c1 = String::new(); - let mut c2 = String::new(); - let mut c3 = String::new(); - - finished.citations[0] - .citation - .write_buf(&mut c1, BufWriteFormat::Plain) - .unwrap(); - finished.citations[1] - .citation - .write_buf(&mut c2, BufWriteFormat::Plain) - .unwrap(); - finished.citations[2] - .citation - .write_buf(&mut c3, BufWriteFormat::Plain) - .unwrap(); - - assert_eq!(c1, "[Che+21a, 12]"); - assert_eq!(c2, "[Che+21b, 12]"); - assert_eq!(c3, "[Che+21a]"); - } - - #[test] - #[cfg(feature = "archive")] - fn ibid_handling_with_deutsche_sprache_csl() { - let bibtex = r#"@book{ITEM, - title = {A}, - type = {book}, - }"#; - - let library = crate::io::from_biblatex_str(bibtex).unwrap(); - let style = archive::ArchivedStyle::DeutscheSprache.get(); - let citationberg::Style::Independent(style) = style else { unreachable!() }; - - let mut driver = BibliographyDriver::new(); - let entry = library.iter().next().unwrap(); - - for locator in ["33", "33", "34"] { - driver.citation(CitationRequest::new( - vec![CitationItem::new( - entry, - Some(SpecificLocator(Locator::Page, LocatorPayload::Str(locator))), - None, - false, - Some(CitePurpose::Prose), - )], - &style, - None, - &[], - None, - )); - } - - let finished = driver.finish(BibliographyRequest { - style: &style, - locale: None, - locale_files: &[], - }); - - let actual = finished - .citations - .iter() - .map(|c| { - let mut s = String::new(); - c.citation.write_buf(&mut s, BufWriteFormat::Plain).unwrap(); - s - }) - .collect::>(); - - assert_eq!(actual, ["(33)", "()", "(34)"]); - } } diff --git a/crates/hayagriva-csl/src/rendering/mod.rs b/crates/hayagriva-csl/src/rendering/mod.rs index e5e30067..4cfac10c 100644 --- a/crates/hayagriva-csl/src/rendering/mod.rs +++ b/crates/hayagriva-csl/src/rendering/mod.rs @@ -9,11 +9,9 @@ use citationberg::taxonomy::{ use citationberg::{ ChooseBranch, CslMacro, DateDayForm, DateMonthForm, DatePartName, DateParts, DateStrongAnyForm, GrammarGender, LabelPluralize, LayoutRenderingElement, - LongShortForm, NumberForm, PageRangeFormat, TestPosition, TextCase, ToAffixes, - ToFormatting, + LongShortForm, NumberForm, PageRangeFormat, TestPosition, ToAffixes, ToFormatting, }; use citationberg::{TermForm, TextTarget}; -use hayagriva_core::lang::{Case, SentenceCase, TitleCase}; use hayagriva_core::{ ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, PageRangesPart, }; diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 293c5b7b..33ba53ef 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -19,5 +19,13 @@ unic-langid = { workspace = true } serde_yaml = "0.9.25" unicode-segmentation = { workspace = true } hayagriva-core = { path = "../hayagriva-core" } +hayagriva-biblatex = { path = "../hayagriva-biblatex", optional = true } thiserror = { workspace = true } unscanny = { workspace = true } +url = { workspace = true, optional = true } + +[dev-dependencies] +serde_json = "1" + +[features] +biblatex = ["dep:biblatex", "dep:hayagriva-biblatex", "dep:url"] diff --git a/crates/hayagriva-format/src/citation_label.rs b/crates/hayagriva-format/src/citation_label.rs index f2b5457e..80efc90d 100644 --- a/crates/hayagriva-format/src/citation_label.rs +++ b/crates/hayagriva-format/src/citation_label.rs @@ -78,6 +78,7 @@ impl Alphanumerical { }) } + /// Renders a citation of `entry` pub fn citation(self, entry: &Entry) -> String { let full_entry = entry.get_full(); diff --git a/crates/hayagriva-cli/src/interop.rs b/crates/hayagriva-format/src/interop.rs similarity index 86% rename from crates/hayagriva-cli/src/interop.rs rename to crates/hayagriva-format/src/interop.rs index ee719baa..e5522b59 100644 --- a/crates/hayagriva-cli/src/interop.rs +++ b/crates/hayagriva-format/src/interop.rs @@ -11,7 +11,7 @@ use tex::{ use url::Url; use super::Entry; -use super::types::*; +use hayagriva_core::types::*; macro_rules! tex_kinds { ($self:expr, $mv_attr:expr, [$({$kind:pat, $new_kind:expr, $top_level:expr, $expand_mv:expr}),* $(,)*] $(,)*) => { @@ -39,78 +39,70 @@ macro_rules! tex_kinds { }; } -impl From<&tex::Person> for Person { - fn from(person: &tex::Person) -> Self { - fn optional(part: &str) -> Option { - if !part.is_empty() { Some(part.to_string()) } else { None } - } +fn person(person: &tex::Person) -> Person { + fn optional(part: &str) -> Option { + if !part.is_empty() { Some(part.to_string()) } else { None } + } - Self { - name: person.name.clone(), - given_name: optional(&person.given_name), - prefix: optional(&person.prefix), - suffix: optional(&person.suffix), - comma_suffix: false, - alias: None, - } + Person { + name: person.name.clone(), + given_name: optional(&person.given_name), + prefix: optional(&person.prefix), + suffix: optional(&person.suffix), + comma_suffix: false, + alias: None, } } -impl From for Date { - fn from(date: tex::Date) -> Self { - let approximate = date.uncertain || date.approximate; - - match date.value { - DateValue::At(x) | DateValue::After(x) | DateValue::Before(x) => Date { - year: x.year, - month: x.month, - day: x.day, - approximate, - season: None, - }, - DateValue::Between(_, x) => Self { - year: x.year, - month: x.month, - day: x.day, - approximate, - season: None, - }, - } +fn date(date: tex::Date) -> Date { + let approximate = date.uncertain || date.approximate; + + match date.value { + DateValue::At(x) | DateValue::After(x) | DateValue::Before(x) => Date { + year: x.year, + month: x.month, + day: x.day, + approximate, + season: None, + }, + DateValue::Between(_, x) => Date { + year: x.year, + month: x.month, + day: x.day, + approximate, + season: None, + }, } } -impl From<&[Spanned]> for ChunkedString { - fn from(chunks: &[Spanned]) -> Self { - let mut res = Self::new(); - for chunk in chunks { - match &chunk.v { - Chunk::Normal(s) => res.push_str(s, ChunkKind::Normal), - Chunk::Verbatim(s) => res.push_str(s, ChunkKind::Verbatim), - Chunk::Math(s) => res.push_str(s, ChunkKind::Math), - } +fn chunks_to_chunked_str(chunks: &[Spanned]) -> ChunkedString { + let mut res = ChunkedString::new(); + for chunk in chunks { + match &chunk.v { + Chunk::Normal(s) => res.push_str(s, ChunkKind::Normal), + Chunk::Verbatim(s) => res.push_str(s, ChunkKind::Verbatim), + Chunk::Math(s) => res.push_str(s, ChunkKind::Math), } - res } + res } -impl From<&[Spanned]> for FormatString { - fn from(chunks: &[Spanned]) -> Self { - Self { value: chunks.into(), short: None } - } +fn chunks_to_fmt_str(chunks: &[Spanned]) -> FormatString { + FormatString { value: chunks_to_chunked_str(chunks), short: None } } -impl From<&[Spanned]> for MaybeTyped { - fn from(chunks: &[Spanned]) -> Self { - let verb = chunks.format_verbatim(); - MaybeTyped::infallible_from_str(&verb) - } +fn chunks_to_mby_numeric(chunks: &[Spanned]) -> MaybeTyped { + let verb = chunks.format_verbatim(); + MaybeTyped::infallible_from_str(&verb) } -impl From<&PermissiveType> for MaybeTyped { - fn from(edition_or_volume: &PermissiveType) -> Self { - match edition_or_volume { - PermissiveType::Typed(i) => Self::Typed(Numeric::new(*i as i32)), - PermissiveType::Chunks(c) => Self::infallible_from_str(&c.format_verbatim()), +fn permissive_to_mby_numeric( + edition_or_volume: &PermissiveType, +) -> MaybeTyped { + match edition_or_volume { + PermissiveType::Typed(i) => MaybeTyped::Typed(Numeric::new(*i as i32)), + PermissiveType::Chunks(c) => { + MaybeTyped::infallible_from_str(&c.format_verbatim()) } } } @@ -216,7 +208,7 @@ impl TryFrom<&tex::Entry> for Entry { { tex::EntryType::Unknown(_), EntryType::Misc, None, false }, ]); - if let Ok(a) = entry.author().map(|a| a.iter().map(Into::into).collect()) { + if let Ok(a) = entry.author().map(|a| a.iter().map(person).collect()) { item.set_authors(a); } @@ -225,9 +217,9 @@ impl TryFrom<&tex::Entry> for Entry { for (editors, role) in entry.editors()? { let ptype = ed_role(role, &entry.entry_type); match ptype { - None => eds.extend(editors.iter().map(Into::into)), + None => eds.extend(editors.iter().map(person)), Some(role) => collaborators.push(PersonsWithRoles::new( - editors.iter().map(Into::into).collect(), + editors.iter().map(person).collect(), role, )), } @@ -240,33 +232,32 @@ impl TryFrom<&tex::Entry> for Entry { item.set_affiliated(collaborators); } - if let Some(a) = - map_res(entry.holder())?.map(|a| a.iter().map(Into::into).collect()) + if let Some(a) = map_res(entry.holder())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Holder)); } if let Some(parent) = book(&mut item, parent) && let Some(a) = - map_res(entry.book_author())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.book_author())?.map(|a| a.iter().map(person).collect()) { parent.set_authors(a); } if let Some(a) = - map_res(entry.annotator())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.annotator())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Annotator)); } if let Some(a) = - map_res(entry.commentator())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.commentator())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Commentator)); } if let Some(a) = - map_res(entry.translator())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.translator())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Translator)); } @@ -291,25 +282,27 @@ impl TryFrom<&tex::Entry> for Entry { } if let Some(a) = - map_res(entry.afterword())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.afterword())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Afterword)); } if let Some(a) = - map_res(entry.foreword())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.foreword())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Foreword)); } if let Some(a) = - map_res(entry.introduction())?.map(|a| a.iter().map(Into::into).collect()) + map_res(entry.introduction())?.map(|a| a.iter().map(person).collect()) { item.add_affiliated_persons((a, PersonRole::Introduction)); } - if let Some(title) = map_res(entry.title())?.map(Into::into) { - if let Some(short_title) = map_res(entry.short_title())?.map(Into::into) { + if let Some(title) = map_res(entry.title())?.map(chunks_to_chunked_str) { + if let Some(short_title) = + map_res(entry.short_title())?.map(chunks_to_chunked_str) + { item.set_title(FormatString { value: title, short: Some(Box::new(short_title)), @@ -322,17 +315,21 @@ impl TryFrom<&tex::Entry> for Entry { // NOTE: Ignoring subtitle and titleaddon for now if let Some(parent) = mv(&mut item, parent, mv_parent) - && let Some(title) = map_res(entry.main_title())?.map(Into::into) + && let Some(title) = map_res(entry.main_title())?.map(chunks_to_fmt_str) { parent.set_title(title); } if let Some(parent) = book(&mut item, parent) { if entry.entry_type == tex::EntryType::Article { - if let Some(title) = map_res(entry.journal_title())?.map(Into::into) { + if let Some(title) = + map_res(entry.journal_title())?.map(chunks_to_fmt_str) + { parent.set_title(title); } - } else if let Some(title) = map_res(entry.book_title())?.map(Into::into) { + } else if let Some(title) = + map_res(entry.book_title())?.map(chunks_to_fmt_str) + { parent.set_title(title); } } @@ -353,14 +350,14 @@ impl TryFrom<&tex::Entry> for Entry { PermissiveType::Typed(d) => Some(d), PermissiveType::Chunks(_) => None, }) - .map(|d| d.into()) + .map(date) { conference.set_date(event_date); } - if let Some(title) = map_res(entry.eventtitle())?.map(Into::into) { + if let Some(title) = map_res(entry.eventtitle())?.map(chunks_to_fmt_str) { conference.set_title(title); } - if let Some(venue) = map_res(entry.venue())?.map(|d| d.into()) { + if let Some(venue) = map_res(entry.venue())?.map(chunks_to_fmt_str) { conference.set_location(venue); } @@ -372,12 +369,14 @@ impl TryFrom<&tex::Entry> for Entry { PermissiveType::Typed(d) => Some(d), PermissiveType::Chunks(_) => None, }) - .map(|d| d.into()) + .map(date) { item.set_date(date); } - if let Some(edition) = map_res(entry.edition())?.map(|d| (&d).into()) { + if let Some(edition) = + map_res(entry.edition())?.map(|d| permissive_to_mby_numeric(&d)) + { if let Some(parent) = book(&mut item, parent) { parent.set_edition(edition); } else { @@ -389,14 +388,14 @@ impl TryFrom<&tex::Entry> for Entry { entry.entry_type, tex::EntryType::Article | tex::EntryType::Proceedings ) { - if let Some(issue) = map_res(entry.issue())?.map(|d| d.into()) { + if let Some(issue) = map_res(entry.issue())?.map(chunks_to_mby_numeric) { if let Some(parent) = book(&mut item, parent) { parent.set_issue(issue); } else { item.set_issue(issue); } } - if let Some(ititle) = map_res(entry.issue_title())?.map(Into::into) { + if let Some(ititle) = map_res(entry.issue_title())?.map(chunks_to_fmt_str) { if let Some(parent) = book(&mut item, parent) { parent.set_title(ititle); } else { @@ -412,7 +411,7 @@ impl TryFrom<&tex::Entry> for Entry { // report, manual, and dataset, where it fits the use for patent. // Hayagriva uses "issue" for the journal/book sense of biblatex's number, // and "serial-number" for the record number / token sense. - if let Some(number) = map_res(entry.number())?.map(|d| d.into()) { + if let Some(number) = map_res(entry.number())?.map(chunks_to_mby_numeric) { if let Some(parent) = book(&mut item, parent) { parent.set_issue(number); } else { @@ -429,7 +428,7 @@ impl TryFrom<&tex::Entry> for Entry { } if let Some(volume) = map_res(entry.volume())? { - let val = (&volume).into(); + let val = permissive_to_mby_numeric(&volume); if let Some(parent) = book(&mut item, parent) { parent.set_volume(val); } else { @@ -488,21 +487,21 @@ impl TryFrom<&tex::Entry> for Entry { PermissiveType::Typed(d) => Some(d), PermissiveType::Chunks(_) => None, }) - .map(|d| d.into()); + .map(date); item.set_url(QualifiedUrl { value: url, visit_date: date }); } if let Some(publisher_name) = map_res(entry.publisher())?.map(|pubs| comma_list(&pubs)) { - let location = map_res(entry.location())?.map(|d| d.into()); + let location = map_res(entry.location())?.map(chunks_to_fmt_str); let publisher = Publisher::new(Some(publisher_name), location); if let Some(parent) = book(&mut item, parent) { parent.set_publisher(publisher); } else { item.set_publisher(publisher); } - } else if let Some(location) = map_res(entry.location())?.map(|d| d.into()) { + } else if let Some(location) = map_res(entry.location())?.map(chunks_to_fmt_str) { let publisher = Publisher::new(None, Some(location)); if let Some(parent) = book(&mut item, parent) { parent.set_publisher(publisher); @@ -519,7 +518,9 @@ impl TryFrom<&tex::Entry> for Entry { } else { item.set_organization(organization); } - } else if let Some(organization) = map_res(entry.institution())?.map(Into::into) { + } else if let Some(organization) = + map_res(entry.institution())?.map(chunks_to_fmt_str) + { if let Some(parent) = book(&mut item, parent) { parent.set_organization(organization); } else { @@ -527,7 +528,7 @@ impl TryFrom<&tex::Entry> for Entry { } } - if let Some(note) = map_res(entry.how_published())?.map(Into::into) { + if let Some(note) = map_res(entry.how_published())?.map(chunks_to_fmt_str) { if let Some(parent) = book(&mut item, parent) { parent.set_note(note); } else { @@ -568,20 +569,20 @@ impl TryFrom<&tex::Entry> for Entry { } } - if let Some(note) = map_res(entry.note())?.map(Into::into) { + if let Some(note) = map_res(entry.note())?.map(chunks_to_fmt_str) { item.set_note(note); } if let Some(note) = map_res(entry.annotation())? .or_else(|| entry.addendum().ok()) - .map(Into::into) + .map(chunks_to_fmt_str) && item.note.is_none() { item.set_note(note); } if let Some(abstract_) = map_res(entry.abstract_())? { - item.set_abstract_(abstract_.into()) + item.set_abstract_(chunks_to_fmt_str(abstract_)) } // BibLaTeX describes "type" as "The type of a manual, patent, report, or thesis. @@ -610,7 +611,7 @@ impl TryFrom<&tex::Entry> for Entry { } if let Some(series) = map_res(entry.series())? { - let title: FormatString = series.into(); + let title: FormatString = chunks_to_fmt_str(series); let mut new = Entry::new(&entry.key, item.entry_type); new.set_title(title); @@ -635,7 +636,7 @@ impl TryFrom<&tex::Entry> for Entry { // is better corresponded to by the `@InBook` BibLaTeX entry type: // "A part of a book which forms a self-contained unit with its // own title." - item.set_chapter(chapter.into()); + item.set_chapter(chunks_to_mby_numeric(chapter)); } Ok(item) @@ -649,7 +650,7 @@ fn comma_list(items: &[Vec>]) -> FormatString { value.push_str(", ", ChunkKind::Normal); } - let chunked = ChunkedString::from(entity.as_slice()); + let chunked = chunks_to_chunked_str(entity.as_slice()); value.extend(chunked); } @@ -660,7 +661,7 @@ fn comma_list(items: &[Vec>]) -> FormatString { mod tests { use unic_langid::LanguageIdentifier; - use crate::types::{EntryType, MaybeTyped, PersonRole}; + use hayagriva_core::types::{EntryType, MaybeTyped, PersonRole}; #[test] fn test_pmid_from_biblatex() { diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index c6ef4f16..94ec4003 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -142,6 +142,7 @@ return `Some` even if no sub-entry was bound / if the hash map is empty. mod selectors; pub mod citation_label; +mod interop; pub mod io; pub mod taxonomy; diff --git a/crates/hayagriva-format/src/taxonomy.rs b/crates/hayagriva-format/src/taxonomy.rs index 8e5fe413..921059ca 100644 --- a/crates/hayagriva-format/src/taxonomy.rs +++ b/crates/hayagriva-format/src/taxonomy.rs @@ -1,3 +1,5 @@ +//! Translation from Hayagriva to CSL variables + use std::{borrow::Cow, str::FromStr}; use citationberg::{ From 6392771c8d76d70fbdfabefc37ca5380b72f74d3 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 20:55:07 +0200 Subject: [PATCH 04/31] Update archive --- archive/locales/sv-SE.cbor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive/locales/sv-SE.cbor b/archive/locales/sv-SE.cbor index 812309c8..252da1cc 100644 --- a/archive/locales/sv-SE.cbor +++ b/archive/locales/sv-SE.cbor @@ -1 +1 @@ -i@xml:langesv-SEdinfojtranslatordnamegtorfeurdnamenSylvester KeildnameqSebastian KarcherdnamenUlf Harnhammarfrightse$textxQThis work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Licenseh@licensex.http://creativecommons.org/licenses/by-sa/3.0/gupdatede$textx2026-01-10T00:00:00+00:00etermsdtermOe@namehaccessede$textmåtkomstdatume@formdlonge@namexadvance-online-publicatione$textxadvance online publicatione@formdlonge@nameealbume$textealbume@formdlonge@namecande$textcoche@formdlonge@namejand-otherse$textioch andrae@formdlonge@nameianonymouse$textfanonyme@formdlonge@namebate$textcvide@formdlonge@nameoaudio-recordinge$textoaudio recordinge@formdlonge@namelavailable ate$textptillgänglig vide@formdlonge@namebbye$textbave@formdlonge@nameecircae$textecirkae@formdlonge@nameecitede$textgciterade@formdlonge@nameeet-ale$textem.fl.e@formdlonge@namedfilme$textdfilme@formdlonge@namekforthcominge$texthkommandee@formdlonge@namedfrome$textefråne@formdlonge@namejhenceforthe$textjhenceforthe@formdlonge@namedibide$texteibid.e@formdlonge@namebine$textaie@formdlonge@namehin presse$textgi trycke@formdlonge@namehinternete$texthinternete@formdlonge@nameflettere$textdbreve@formdlonge@namegloc-cite$textiloc. cit.e@formdlonge@namegno datee$textkutan årtale@formdlonge@namehno-placee$texthno placee@formdlonge@namelno-publishere$textlno publishere@formdlonge@namebone$textbone@formdlonge@namefonlinee$textfonlinee@formdlonge@namefop-cite$texthop. cit.e@formdlonge@nameworiginal-work-publishede$textworiginal work publishede@formdlonge@namevpersonal-communicatione$textwpersonlig kommunikatione@formdlonge@namegpodcaste$textgpodcaste@formdlonge@nameopodcast-episodee$textopodcast episodee@formdlonge@namehpreprinte$texthpreprinte@formdlonge@namelpresented ate$textopresenterad vide@formdlonge@nameoradio-broadcaste$textoradio broadcaste@formdlonge@namelradio-seriese$textlradio seriese@formdlonge@nametradio-series-episodee$texttradio series episodee@formdlonge@nameireferencefsinglehreferenshmultiplejreferensere@formdlonge@nameiretrievede$textghämtade@formdlonge@nameireview-ofe$textireview ofe@formdlonge@nameescalee$textescalee@formdlonge@namemspecial-issuee$textmspecial issuee@formdlonge@nameospecial-sectione$textospecial sectione@formdlonge@namettelevision-broadcaste$textttelevision broadcaste@formdlonge@nameqtelevision-seriese$textqtelevision seriese@formdlonge@namextelevision-series-episodee$textxtelevision series episodee@formdlonge@nameevideoe$textevideoe@formdlonge@namemworking-papere$textmworking papere@formdlonge@nameianonymouse$texteanon.e@formeshorte@nameecircae$textbcae@formeshorte@namegno datee$texteu.å.e@formeshorte@namehno-placee$textdn.p.e@formeshorte@namelno-publishere$textdn.p.e@formeshorte@nameireferencefsingledref.hmultipledref.e@formeshorte@nameireview-ofe$textgrev. ofe@formeshorte@namegarticlee$texthpreprinte@formdlonge@nameoarticle-journale$textojournal articlee@formdlonge@nameparticle-magazinee$textpmagazine articlee@formdlonge@nameqarticle-newspapere$textqnewspaper articlee@formdlonge@namedbille$textdbille@formdlonge@nameibroadcaste$textibroadcaste@formdlonge@namegclassice$textgclassice@formdlonge@namejcollectione$textjcollectione@formdlonge@namegdatasete$textgdatasete@formdlonge@namehdocumente$texthdocumente@formdlonge@nameeentrye$texteentrye@formdlonge@namepentry-dictionarye$textpdictionary entrye@formdlonge@namerentry-encyclopediae$textrencyclopedia entrye@formdlonge@nameeevente$texteevente@formdlonge@nameggraphice$textggraphice@formdlonge@nameghearinge$textghearinge@formdlonge@nameiinterviewe$texthintervjue@formdlonge@namejlegal_casee$textjlegal casee@formdlonge@nameklegislatione$textklegislatione@formdlonge@namejmanuscripte$textjmanuscripte@formdlonge@namecmape$textcmape@formdlonge@namenmotion_picturee$textovideo recordinge@formdlonge@namemmusical_scoree$textmmusical scoree@formdlonge@namehpamphlete$texthpamphlete@formdlonge@nameppaper-conferencee$textpconference papere@formdlonge@namefpatente$textfpatente@formdlonge@namekperformancee$textkperformancee@formdlonge@namejperiodicale$textjperiodicale@formdlonge@namevpersonal_communicatione$textwpersonlig kommunikatione@formdlonge@namedposte$textdposte@formdlonge@namekpost-webloge$textiblog poste@formdlonge@namejregulatione$textjregulatione@formdlonge@namefreporte$textfreporte@formdlonge@namefreviewe$textfreviewe@formdlonge@namekreview-booke$textkbook reviewe@formdlonge@namehsoftwaree$texthsoftwaree@formdlonge@namedsonge$textoaudio recordinge@formdlonge@namefspeeche$textlpresentatione@formdlonge@namehstandarde$texthstandarde@formdlonge@namefthesise$textfthesise@formdlonge@nameftreatye$textftreatye@formdlonge@namegwebpagee$textgwebpagee@formdlonge@nameoarticle-journale$textljournal art.e@formeshorte@nameparticle-magazinee$textimag. art.e@formeshorte@nameqarticle-newspapere$textnnewspaper art.e@formeshorte@namehdocumente$textddoc.e@formeshorte@nameggraphice$textfgraph.e@formeshorte@nameiinterviewe$textginterv.e@formeshorte@namejmanuscripte$textbMSe@formeshorte@namenmotion_picturee$textjvideo rec.e@formeshorte@namefreporte$textdrep.e@formeshorte@namefreviewe$textdrev.e@formeshorte@namekreview-booke$texthbk. rev.e@formeshorte@namedsonge$textjaudio rec.e@formeshorte@nameghearinge$textltestimony ofe@formdverbe@namefreviewe$textireview ofe@formdverbe@namekreview-booke$textrreview of the booke@formdverbe@namebade$textee.Kr.e@formdlonge@namebbce$textef.Kr.e@formdlonge@namecbcee$textcBCEe@formdlonge@namebcee$textbCEe@formdlonge@namejopen-quotee$textc”e@formdlonge@namekclose-quotee$textc”e@formdlonge@namepopen-inner-quotee$textc’e@formdlonge@nameqclose-inner-quotee$textc’e@formdlonge@nametpage-range-delimitere$textc–e@formdlonge@nameecolone$texta:e@formdlonge@nameecommae$texta,e@formdlonge@nameisemicolone$texta;e@formdlonge@namegordinale$textb:ee@formdlonge@namejordinal-01e$textb:ae@formdlonge@namejordinal-02e$textb:ae@formdlonge@namejordinal-11e$textb:ee@formdlonge@namejordinal-12e$textb:ee@formdlonge@nameolong-ordinal-01e$textgförstae@formdlonge@nameolong-ordinal-02e$texteandrae@formdlonge@nameolong-ordinal-03e$textftredjee@formdlonge@nameolong-ordinal-04e$textgfjärdee@formdlonge@nameolong-ordinal-05e$textefemtee@formdlonge@nameolong-ordinal-06e$textgsjättee@formdlonge@nameolong-ordinal-07e$textfsjundee@formdlonge@nameolong-ordinal-08e$texthåttondee@formdlonge@nameolong-ordinal-09e$textfniondee@formdlonge@nameolong-ordinal-10e$textftiondee@formdlonge@namecactfsinglecacthmultipledactse@formdlonge@namehappendixfsinglehappendixhmultiplejappendicese@formdlonge@nameoarticle-locatorfsinglegarticlehmultipleharticlese@formdlonge@namedbookfsinglecbokhmultiplegböckere@formdlonge@nameecanonfsingleecanonhmultiplefcanonse@formdlonge@namegchapterfsinglegkapitelhmultiplegkapitele@formdlonge@namefcolumnfsinglefkolumnhmultiplehkolumnere@formdlonge@nameielocationfsinglehlocationhmultipleilocationse@formdlonge@namehequationfsinglehequationhmultipleiequationse@formdlonge@nameffigurefsingleefigurhmultiplegfigurere@formdlonge@nameefoliofsingleefoliohmultipleffoliose@formdlonge@nameeissuefsinglefnummerhmultiplefnummere@formdlonge@namedlinefsinglecradhmultipleeradere@formdlonge@namednotefsinglecnothmultipleenotere@formdlonge@namedopusfsingledopushmultipleeoperae@formdlonge@namedpagefsingledsidahmultipleesidore@formdlonge@nameiparagraphfsinglefstyckehmultiplegstyckene@formdlonge@namedpartfsinglecdelhmultipleedelare@formdlonge@namedrulefsingledrulehmultipleerulese@formdlonge@nameescenefsingleescenehmultiplefscenese@formdlonge@namegsectionfsinglegavsnitthmultiplegavsnitte@formdlonge@nameisub verbofsingleisub verbohmultiplejsub verbise@formdlonge@namejsupplementfsinglejsupplementhmultipleksupplementse@formdlonge@nameetablefsingleetablehmultipleftablese@formdlonge@nameitimestampfsingle`hmultiple`e@formdlonge@namemtitle-locatorfsingleetitlehmultipleftitlese@formdlonge@nameeversefsingledvershmultiplefversere@formdlonge@namefvolumefsingleevolymhmultiplegvolymere@formdlonge@namehappendixfsingledapp.hmultipleeapps.e@formeshorte@nameoarticle-locatorfsingledart.hmultipleearts.e@formeshorte@namedbooke$textcboke@formeshorte@namegchaptere$textdkap.e@formeshorte@namefcolumne$textdkol.e@formeshorte@nameielocationfsingledloc.hmultipleelocs.e@formeshorte@namehequationfsingleceq.hmultipledeqs.e@formeshorte@nameffiguree$textdfig.e@formeshorte@nameefolioe$textbf.e@formeshorte@nameeissuee$textbnre@formeshorte@namedlinee$textbl.e@formeshorte@namednotee$textbn.e@formeshorte@namedopuse$textcop.e@formeshorte@namedpagefsinglebs.hmultiplebs.e@formeshorte@nameiparagraphe$textcst.e@formeshorte@namedparte$textcdele@formeshorte@namedrulefsinglebr.hmultiplecrr.e@formeshorte@nameescenefsinglecsc.hmultipledscs.e@formeshorte@namegsectione$textdavs.e@formeshorte@nameisub verbofsingleds.v.hmultiplees.vv.e@formeshorte@namejsupplementfsingleesupp.hmultiplefsupps.e@formeshorte@nameetablefsingledtbl.hmultipleetbls.e@formeshorte@nameitimestampfsingle`hmultiple`e@formeshorte@namemtitle-locatorfsingledtit.hmultipleetits.e@formeshorte@nameeversefsingledvershmultiplefversere@formeshorte@namefvolumefsingledvol.hmultipledvol.e@formeshorte@nameiparagraphfsingleb¶hmultipled¶¶e@formfsymbole@namegsectionfsingleb§hmultipled§§e@formfsymbole@namenchapter-numberfsinglegchapterhmultiplehchapterse@formdlonge@nameocitation-numberfsinglehcitationhmultipleicitationse@formdlonge@nameqcollection-numberfsinglefnummerhmultiplefnummere@formdlonge@namegeditionfsinglegupplagahmultiplehupplagore@formdlonge@namexfirst-reference-note-numberfsinglecnothmultipleenotere@formdlonge@namefnumberfsinglefnumberhmultiplegnumberse@formdlonge@nameonumber-of-pagesfsingledsidahmultipleesidore@formdlonge@nameqnumber-of-volumesfsinglefvolumehmultiplegvolumese@formdlonge@namejpage-firstfsingledpagehmultipleepagese@formdlonge@nameoprinting-numberfsinglehprintinghmultipleiprintingse@formdlonge@namegversione$textgversione@formdlonge@namenchapter-numberfsingleechap.hmultiplefchaps.e@formeshorte@nameocitation-numberfsingledcit.hmultipleecits.e@formeshorte@nameqcollection-numbere$textbnre@formeshorte@namegeditione$texteuppl.e@formeshorte@namexfirst-reference-note-numbere$textbn.e@formeshorte@namefnumberfsinglecno.hmultiplednos.e@formeshorte@nameonumber-of-pagesfsinglebs.hmultiplebs.e@formeshorte@nameqnumber-of-volumesfsingledvol.hmultipleevols.e@formeshorte@namejpage-firstfsinglebp.hmultiplecpp.e@formeshorte@nameoprinting-numberfsinglefprint.hmultiplegprints.e@formeshorte@namefauthore@formdlonge@nameechairfsingleechairhmultiplefchairse@formdlonge@nameqcollection-editorfsingleced.hmultiplededs.e@formdlonge@namehcompilerfsinglehcompilerhmultipleicompilerse@formdlonge@namehcomposere@formdlonge@namepcontainer-authore@formdlonge@namekcontributorfsinglekcontributorhmultiplelcontributorse@formdlonge@namegcuratorfsinglegcuratorhmultiplehcuratorse@formdlonge@namehdirectorfsinglehdirectorhmultipleidirectorse@formdlonge@namefeditorfsingleiredaktörhmultiplekredaktörere@formdlonge@nameqeditor-translatorfsinglexredaktör & översättarehmultiplexredaktörer & översättaree@formdlonge@nameqeditor-translatorfsinglexredaktör & översättarehmultiplexredaktörer & översättaree@formdlonge@namereditorial-directorfsinglefeditorhmultiplegeditorse@formdlonge@namerexecutive-producerfsinglerexecutive producerhmultiplesexecutive producerse@formdlonge@nameeguestfsingleeguesthmultiplefguestse@formdlonge@namedhostfsingledhosthmultipleehostse@formdlonge@namekillustratorfsinglelillustratörhmultiplenillustratörere@formdlonge@namekinterviewere@formdlonge@namehnarratorfsinglehnarratorhmultipleinarratorse@formdlonge@nameiorganizerfsingleiorganizerhmultiplejorganizerse@formdlonge@nameooriginal-authore@formdlonge@nameiperformerfsingleiperformerhmultiplejperformerse@formdlonge@namehproducerfsinglehproducerhmultipleiproducerse@formdlonge@nameirecipiente@formdlonge@nameoreviewed-authore@formdlonge@namemscript-writerfsinglefwriterhmultiplegwriterse@formdlonge@namenseries-creatorfsinglenseries creatorhmultipleoseries creatorse@formdlonge@namejtranslatorfsinglemöversättarehmultiplemöversättaree@formdlonge@namehcompilerfsingleecomp.hmultiplefcomps.e@formeshorte@namekcontributorfsinglehcontrib.hmultipleicontribs.e@formeshorte@namegcuratorfsingledcur.hmultipleecurs.e@formeshorte@namehdirectorfsingleddir.hmultipleedirs.e@formeshorte@namefeditorfsingledred.hmultipledred.e@formeshorte@nameqeditor-translatorfsinglenred. & övers.hmultiplenred. & övers.e@formeshorte@nameqeditor-translatorfsinglenred. & övers.hmultiplenred. & övers.e@formeshorte@namereditorial-directorfsingleced.hmultiplededs.e@formeshorte@namerexecutive-producerfsinglekexec. prod.hmultiplelexec. prods.e@formeshorte@namekillustratorfsingledill.hmultipledill.e@formeshorte@namehnarratorfsingleenarr.hmultiplefnarrs.e@formeshorte@nameiorganizerfsingledorg.hmultipleeorgs.e@formeshorte@nameiperformerfsingleeperf.hmultiplefperfs.e@formeshorte@namehproducerfsingleeprod.hmultiplefprods.e@formeshorte@namemscript-writerfsingleewrit.hmultiplefwrits.e@formeshorte@namenseries-creatorfsingledcre.hmultipleecres.e@formeshorte@namejtranslatorfsinglegövers.hmultiplegövers.e@formeshorte@nameechaire$textjchaired bye@formdverbe@nameqcollection-editore$textiedited bye@formdverbe@namehcompilere$textkcompiled bye@formdverbe@namepcontainer-authore$textbave@formdverbe@namekcontributore$textdwithe@formdverbe@namegcuratore$textjcurated bye@formdverbe@namehdirectore$textkdirected bye@formdverbe@namefeditore$textlredigerad ave@formdverbe@nameqeditor-translatore$textxredigerad & översatt ave@formdverbe@nameqeditor-translatore$textxredigerad & översatt ave@formdverbe@namereditorial-directore$textiedited bye@formdverbe@namerexecutive-producere$textuexecutive produced bye@formdverbe@nameegueste$textjwith gueste@formdverbe@namedhoste$textihosted bye@formdverbe@namekillustratore$textnillustrerad ave@formdverbe@namekinterviewere$textmintervjuad ave@formdverbe@namehnarratore$textknarrated bye@formdverbe@nameiorganizere$textlorganized bye@formdverbe@nameiperformere$textlperformed bye@formdverbe@namehproducere$textkproduced bye@formdverbe@nameirecipiente$textdtille@formdverbe@nameoreviewed-authore$textbbye@formdverbe@namemscript-writere$textjwritten bye@formdverbe@namenseries-creatore$textjcreated bye@formdverbe@namejtranslatore$textlöversatt ave@formdverbe@nameqcollection-editore$textfed. bye@formjverb-shorte@namehcompilere$texthcomp. bye@formjverb-shorte@namekcontributore$textbw.e@formjverb-shorte@namegcuratore$textgcur. bye@formjverb-shorte@namehdirectore$textddir.e@formjverb-shorte@namefeditore$textdred.e@formjverb-shorte@nameqeditor-translatore$textqred. & övers. ave@formjverb-shorte@nameqeditor-translatore$textqred. & övers. ave@formjverb-shorte@namereditorial-directore$textced.e@formjverb-shorte@namerexecutive-producere$textnexec. prod. bye@formjverb-shorte@nameegueste$texthw. gueste@formjverb-shorte@namedhoste$textihosted bye@formjverb-shorte@namekillustratore$textfillus.e@formjverb-shorte@namehnarratore$texthnarr. bye@formjverb-shorte@nameiorganizere$textgorg. bye@formjverb-shorte@nameiperformere$texthperf. bye@formjverb-shorte@namehproducere$texthprod. bye@formjverb-shorte@namemscript-writere$texthwrit. bye@formjverb-shorte@namenseries-creatore$textgcre. bye@formjverb-shorte@namejtranslatore$textgövers.e@formjverb-shorte@namehmonth-01e$textgjanuarie@formdlonge@namehmonth-02e$texthfebruarie@formdlonge@namehmonth-03e$textdmarse@formdlonge@namehmonth-04e$texteaprile@formdlonge@namehmonth-05e$textcmaje@formdlonge@namehmonth-06e$textdjunie@formdlonge@namehmonth-07e$textdjulie@formdlonge@namehmonth-08e$textgaugustie@formdlonge@namehmonth-09e$textiseptembere@formdlonge@namehmonth-10e$textgoktobere@formdlonge@namehmonth-11e$texthnovembere@formdlonge@namehmonth-12e$texthdecembere@formdlonge@namehmonth-01e$textdjan.e@formeshorte@namehmonth-02e$textdfeb.e@formeshorte@namehmonth-03e$textdmar.e@formeshorte@namehmonth-04e$textdapr.e@formeshorte@namehmonth-05e$textcmaje@formeshorte@namehmonth-06e$textdjunie@formeshorte@namehmonth-07e$textdjulie@formeshorte@namehmonth-08e$textdaug.e@formeshorte@namehmonth-09e$textdsep.e@formeshorte@namehmonth-10e$textdokt.e@formeshorte@namehmonth-11e$textdnov.e@formeshorte@namehmonth-12e$textddec.e@formeshorte@nameiseason-01e$textdvåre@formdlonge@nameiseason-02e$textfsommare@formdlonge@nameiseason-03e$textehöste@formdlonge@nameiseason-04e$textfvintere@formdlongddatee@formdtextidate-parte@namecdaye@formunumeric-leading-zerosg@suffixa n@strip-periodse@nameemonthg@suffixa n@strip-periodse@namedyearn@strip-periodse@formgnumericidate-parte@namedyearn@strip-periodse@nameemonthe@formunumeric-leading-zerosp@range-delimitera/g@prefixa-n@strip-periodse@namecdaye@formunumeric-leading-zerosp@range-delimitera/g@prefixa-n@strip-periodsmstyle-optionsu@punctuation-in-quote \ No newline at end of file +i@xml:langesv-SEdinfojtranslatordnamegtorfeurdnamenSylvester KeildnameqSebastian KarcherdnamenUlf HarnhammardnamemJulian Lenellfrightse$textxQThis work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Licenseh@licensex.http://creativecommons.org/licenses/by-sa/3.0/gupdatede$textx2026-06-01T22:29:02+00:00etermsdterm?e@namehaccessede$textmåtkomstdatume@formdlonge@namexadvance-online-publicatione$textxadvance online publicatione@formdlonge@nameealbume$textealbume@formdlonge@namecande$textcoche@formdlonge@namejand-otherse$textioch andrae@formdlonge@nameianonymouse$textfanonyme@formdlonge@namebate$textcvide@formdlonge@nameoaudio-recordinge$textnljudinspelninge@formdlonge@namelavailable ate$textptillgänglig vide@formdlonge@namebbye$textbave@formdlonge@nameecircae$textecirkae@formdlonge@nameecitede$textgciterade@formdlonge@nameeet-ale$textem.fl.e@formdlonge@namedfilme$textdfilme@formdlonge@namekforthcominge$texthkommandee@formdlonge@namedfrome$textefråne@formdlonge@namejhenceforthe$textkhädaneftere@formdlonge@namedibide$texteibid.e@formdlonge@namebine$textaie@formdlonge@namehin presse$textounder utgivninge@formdlonge@namehinternete$texthinternete@formdlonge@nameflettere$textdbreve@formdlonge@namegloc-cite$textiloc. cit.e@formdlonge@namegno datee$textkutan årtale@formdlonge@namehno-placee$texthutan orte@formdlonge@namelno-publishere$textmutan utgivaree@formdlonge@namebone@formdlonge@namefonlinee$textfonlinee@formdlonge@namefop-cite$texthop. cit.e@formdlonge@nameworiginal-work-publishede$textxoriginalarbete publicerate@formdlonge@namevpersonal-communicatione$textwpersonlig kommunikatione@formdlonge@namegpodcaste$textgpodcaste@formdlonge@nameopodcast-episodee$textnpodcastavsnitte@formdlonge@namehpreprinte$texthpreprinte@formdlonge@namelpresented ate$textopresenterad vide@formdlonge@nameoradio-broadcaste$textnradiosändninge@formdlonge@namelradio-seriese$textpradioföljetånge@formdlonge@nametradio-series-episodee$textxavsnitt ur radioföljetånge@formdlonge@nameireferencefsinglehreferenshmultiplejreferensere@formdlonge@nameiretrievede$textghämtade@formdlonge@nameireview-ofe$textlrecension ave@formdlonge@nameescalee$texteskalae@formdlonge@namemspecial-issuee$textnspecialutgåvae@formdlonge@nameospecial-sectione$textnspecialavsnitte@formdlonge@namettelevision-broadcaste$textltv-sändninge@formdlonge@nameqtelevision-seriese$texthtv-seriee@formdlonge@namextelevision-series-episodee$textotv-serieavsnitte@formdlonge@nameevideoe$textevideoe@formdlonge@namemworking-papere$textmworking papere@formdlonge@nameecircae$textbcae@formeshorte@namegno datee$texteu.å.e@formeshorte@namehno-placee$textdu.o.e@formeshorte@nameireferencee$textdref.e@formeshorte@nameireview-ofe$textgrec. ave@formeshorte@namegarticlee$texthpreprinte@formdlonge@nameoarticle-journale$textqtidskriftsartikele@formdlonge@nameparticle-magazinee$textotidningsartikele@formdlonge@nameqarticle-newspapere$textsdagstidningsartikele@formdlonge@namedbille$textklagförslage@formdlonge@nameibroadcaste$textisändninge@formdlonge@namegclassice$textiklassikere@formdlonge@namejcollectione$textgsamlinge@formdlonge@namegdatasete$textgdatasete@formdlonge@namehdocumente$texthdokumente@formdlonge@nameeentrye$textdposte@formdlonge@namepentry-dictionarye$textkuppslagsorde@formdlonge@namerentry-encyclopediae$textvartikel i uppslagsverke@formdlonge@nameeevente$texteevente@formdlonge@nameggraphice$textdbilde@formdlonge@nameghearinge$textkutfrågninge@formdlonge@nameiinterviewe$texthintervjue@formdlonge@namejlegal_casee$textjrättsfalle@formdlonge@nameklegislatione$textllagstiftninge@formdlonge@namejmanuscripte$textjmanuskripte@formdlonge@namecmape$textekartae@formdlonge@namenmotion_picturee$textovideoinspelninge@formdlonge@namemmusical_scoree$texthpartiture@formdlonge@namehpamphlete$texthbroschyre@formdlonge@nameppaper-conferencee$textokonferensbidrage@formdlonge@namefpatente$textfpatente@formdlonge@namekperformancee$textlframförandee@formdlonge@namejperiodicale$textitidskrifte@formdlonge@namevpersonal_communicatione$textwpersonlig kommunikatione@formdlonge@namedposte$textginlägge@formdlonge@namekpost-webloge$textlblogginlägge@formdlonge@namejregulatione$textkförordninge@formdlonge@namefreporte$textgrapporte@formdlonge@namefreviewe$textirecensione@formdlonge@namekreview-booke$textlbokrecensione@formdlonge@namehsoftwaree$texthmjukvarae@formdlonge@namedsonge$textnljudinspelninge@formdlonge@namefspeeche$textlpresentatione@formdlonge@namehstandarde$texthstandarde@formdlonge@namefthesise$textjavhandlinge@formdlonge@nameftreatye$texthfördrage@formdlonge@namegwebpagee$texthwebbsidae@formdlonge@nameoarticle-journale$textntidskriftsart.e@formeshorte@nameparticle-magazinee$textltidningsart.e@formeshorte@nameqarticle-newspapere$textpdagstidningsart.e@formeshorte@namehdocumente$textddok.e@formeshorte@namenmotion_picturee$textjvideoinsp.e@formeshorte@namedsonge$textiljudinsp.e@formeshorte@nameghearinge$textnutfrågning ave@formdverbe@namefreviewe$textlrecension ave@formdverbe@namekreview-booke$textobokrecension ave@formdverbe@namebade$textee.Kr.e@formdlonge@namebbce$textef.Kr.e@formdlonge@namecbcee$textcBCEe@formdlonge@namebcee$textbCEe@formdlonge@namejopen-quotee$textc”e@formdlonge@namekclose-quotee$textc”e@formdlonge@namepopen-inner-quotee$textc’e@formdlonge@nameqclose-inner-quotee$textc’e@formdlonge@nametpage-range-delimitere$textc–e@formdlonge@nameecolone$texta:e@formdlonge@nameecommae$texta,e@formdlonge@nameisemicolone$texta;e@formdlonge@namegordinale$textb:ee@formdlonge@namejordinal-01e$textb:ae@formdlonge@namejordinal-02e$textb:ae@formdlonge@namejordinal-11e$textb:ee@formdlonge@namejordinal-12e$textb:ee@formdlonge@nameolong-ordinal-01e$textgförstae@formdlonge@nameolong-ordinal-02e$texteandrae@formdlonge@nameolong-ordinal-03e$textftredjee@formdlonge@nameolong-ordinal-04e$textgfjärdee@formdlonge@nameolong-ordinal-05e$textefemtee@formdlonge@nameolong-ordinal-06e$textgsjättee@formdlonge@nameolong-ordinal-07e$textfsjundee@formdlonge@nameolong-ordinal-08e$texthåttondee@formdlonge@nameolong-ordinal-09e$textfniondee@formdlonge@nameolong-ordinal-10e$textftiondee@formdlonge@namecactfsingleclaghmultipleelagare@formdlonge@namehappendixfsinglefbilagahmultiplegbilagore@formdlonge@nameoarticle-locatorfsinglegartikelhmultiplehartiklare@formdlonge@namedbookfsinglecbokhmultiplegböckere@formdlonge@nameecanonfsingleekanonhmultiplegkanonese@formdlonge@namegchapterfsinglegkapitelhmultiplegkapitele@formdlonge@namefcolumnfsinglefkolumnhmultiplehkolumnere@formdlonge@nameielocationfsingleeplatshmultiplegplatsere@formdlonge@namehequationfsinglehekvationhmultiplejekvationere@formdlonge@nameffigurefsingleefigurhmultiplegfigurere@formdlonge@nameefoliofsingleefoliohmultipleffolione@formdlonge@nameeissuefsinglefnummerhmultiplefnummere@formdlonge@namedlinefsinglecradhmultipleeradere@formdlonge@namednotefsinglecnothmultipleenotere@formdlonge@namedopusfsingledopushmultipleeoperae@formdlonge@namedpagefsingledsidahmultipleesidore@formdlonge@nameiparagraphfsinglefstyckehmultiplegstyckene@formdlonge@namedpartfsinglecdelhmultipleedelare@formdlonge@namedrulefsingleeregelhmultiplefreglere@formdlonge@nameescenefsingledscenhmultiplefscenere@formdlonge@namegsectionfsinglegavsnitthmultiplegavsnitte@formdlonge@nameisub verbofsingleisub verbohmultiplejsub verbise@formdlonge@namejsupplemente$textjsupplemente@formdlonge@nameetablefsingleftabellhmultiplehtabellere@formdlonge@nameitimestampfsingle`hmultiple`e@formdlonge@namemtitle-locatorfsingleetitelhmultipleftitlare@formdlonge@nameeversefsingledvershmultiplefversere@formdlonge@namefvolumefsingleevolymhmultiplegvolymere@formdlonge@namehappendixe$textdbil.e@formeshorte@nameoarticle-locatore$textdart.e@formeshorte@namedbooke$textcboke@formeshorte@namegchaptere$textdkap.e@formeshorte@namefcolumne$textdkol.e@formeshorte@nameielocatione@formeshorte@namehequatione$textdekv.e@formeshorte@nameffiguree$textdfig.e@formeshorte@nameefolioe$textbf.e@formeshorte@nameeissuee$textbnre@formeshorte@namedlinee$textcrade@formeshorte@namednotee$textbn.e@formeshorte@namedopuse$textcop.e@formeshorte@namedpagee$textbs.e@formeshorte@nameiparagraphe$textcst.e@formeshorte@namedparte$textcdele@formeshorte@namegsectione$textdavs.e@formeshorte@nameisub verbofsingleds.v.hmultiplees.vv.e@formeshorte@namejsupplemente$textfsuppl.e@formeshorte@nameetablee$textdtab.e@formeshorte@nameitimestampe@formeshorte@nameeversefsingledvershmultiplefversere@formeshorte@namefvolumee$textdvol.e@formeshorte@nameiparagraphfsingleb¶hmultipled¶¶e@formfsymbole@namegsectionfsingleb§hmultipled§§e@formfsymbole@namenchapter-numbere$textgkapitele@formdlonge@nameocitation-numbere$textecitate@formdlonge@nameqcollection-numbere$textfnummere@formdlonge@namegeditionfsinglegupplagahmultiplehupplagore@formdlonge@namexfirst-reference-note-numberfsinglecnothmultipleenotere@formdlonge@namefnumbere$textfnummere@formdlonge@nameonumber-of-pagesfsingledsidahmultipleesidore@formdlonge@nameqnumber-of-volumesfsingleevolymhmultiplegvolymere@formdlonge@namejpage-firstfsingledsidahmultipleesidore@formdlonge@nameoprinting-numberfsingleitryckninghmultiplektryckningare@formdlonge@namegversione$textgversione@formdlonge@namenchapter-numbere$textdkap.e@formeshorte@nameocitation-numbere$textdref.e@formeshorte@nameqcollection-numbere$textbnre@formeshorte@namegeditione$texteuppl.e@formeshorte@namefnumbere$textbnre@formeshorte@nameonumber-of-pagese$textbs.e@formeshorte@nameqnumber-of-volumese$textdvol.e@formeshorte@namejpage-firste$textbs.e@formeshorte@nameoprinting-numbere$textctr.e@formeshorte@namefauthore@formdlonge@nameechaire$textkordförandee@formdlonge@nameqcollection-editore$textdred.e@formdlonge@namehcompilere$textosammanställaree@formdlonge@namehcomposere@formdlonge@namepcontainer-authore@formdlonge@namekcontributore$textkmedverkandee@formdlonge@namegcuratorfsinglegkuratorhmultipleikuratorere@formdlonge@namehdirectorfsingleiregissörhmultiplekregissörere@formdlonge@namefeditorfsingleiredaktörhmultiplekredaktörere@formdlonge@nameqeditor-translatorfsinglexredaktör & översättarehmultiplexredaktörer & översättaree@formdlonge@nameqeditor-translatorfsinglexredaktör & översättarehmultiplexredaktörer & översättaree@formdlonge@namereditorial-directore$textqansvarig utgivaree@formdlonge@namerexecutive-producerfsinglerexekutiv producenthmultipleuexekutiva producentere@formdlonge@nameeguestfsingleegästhmultipleggästere@formdlonge@namedhoste$textmprogramledaree@formdlonge@namekillustratorfsinglelillustratörhmultiplenillustratörere@formdlonge@namekinterviewere@formdlonge@namehnarratore$textjberättaree@formdlonge@nameiorganizerfsinglelorganisatörhmultiplenorganisatörere@formdlonge@nameooriginal-authore@formdlonge@nameiperformerfsinglefartisthmultiplehartistere@formdlonge@namehproducerfsingleiproducenthmultiplekproducentere@formdlonge@nameirecipiente@formdlonge@nameoreviewed-authore@formdlonge@namemscript-writere$textpmanusförfattaree@formdlonge@namenseries-creatore$textlserieskaparee@formdlonge@namejtranslatore$textmöversättaree@formdlonge@namehcompilere$textisammanst.e@formeshorte@namekcontributore$textemedv.e@formeshorte@namehdirectore$textdreg.e@formeshorte@namefeditore$textdred.e@formeshorte@nameqeditor-translatore$textnred. & övers.e@formeshorte@nameqeditor-translatore$textnred. & övers.e@formeshorte@namereditorial-directore$textjansv. utg.e@formeshorte@namerexecutive-producere$textkexek. prod.e@formeshorte@namekillustratore$textdill.e@formeshorte@namehnarratore$texteuppl.e@formeshorte@nameiorganizere$textdorg.e@formeshorte@namehproducere$texteprod.e@formeshorte@namemscript-writere$textemanuse@formeshorte@namenseries-creatore$textbave@formeshorte@namejtranslatore$textgövers.e@formeshorte@nameechaire$textxunder ordförandeskap ave@formdverbe@nameqcollection-editore$textlredigerad ave@formdverbe@namehcompilere$textpsammanställd ave@formdverbe@namepcontainer-authore$textbave@formdverbe@namekcontributore$textcmede@formdverbe@namegcuratore$textjkurerad ave@formdverbe@namehdirectore$textmregisserad ave@formdverbe@namefeditore$textlredigerad ave@formdverbe@nameqeditor-translatore$textxredigerad & översatt ave@formdverbe@nameqeditor-translatore$textxredigerad & översatt ave@formdverbe@namereditorial-directore$textlredigerad ave@formdverbe@namerexecutive-producere$textwexekutivt producerad ave@formdverbe@nameegueste$textimed gäste@formdverbe@namedhoste$textgledd ave@formdverbe@namekillustratore$textnillustrerad ave@formdverbe@namekinterviewere$textmintervjuad ave@formdverbe@namehnarratore$textlberättad ave@formdverbe@nameiorganizere$textnorganiserad ave@formdverbe@nameiperformere$textlframförd ave@formdverbe@namehproducere$textmproducerad ave@formdverbe@nameirecipiente$textdtille@formdverbe@nameoreviewed-authore$textbave@formdverbe@namemscript-writere$textjskriven ave@formdverbe@namenseries-creatore$textiskapad ave@formdverbe@namejtranslatore$textlöversatt ave@formdverbe@nameqcollection-editore$textgred. ave@formjverb-shorte@namehcompilere$textlsammanst. ave@formjverb-shorte@namekcontributore$textemedv.e@formjverb-shorte@namegcuratore$textjkurerad ave@formjverb-shorte@namehdirectore$textgregi ave@formjverb-shorte@namefeditore$textgred. ave@formjverb-shorte@nameqeditor-translatore$textqred. & övers. ave@formjverb-shorte@nameqeditor-translatore$textqred. & övers. ave@formjverb-shorte@namereditorial-directore$textgred. ave@formjverb-shorte@namerexecutive-producere$textnexek. prod. ave@formjverb-shorte@nameegueste$texthm. gäste@formjverb-shorte@namedhoste$textgledd ave@formjverb-shorte@namekillustratore$textfillus.e@formjverb-shorte@namehnarratore$texthuppl. ave@formjverb-shorte@nameiorganizere$textgorg. ave@formjverb-shorte@nameiperformere$textiframf. ave@formjverb-shorte@namehproducere$texthprod. ave@formjverb-shorte@namejtranslatore$textgövers.e@formjverb-shorte@namehmonth-01e$textgjanuarie@formdlonge@namehmonth-02e$texthfebruarie@formdlonge@namehmonth-03e$textdmarse@formdlonge@namehmonth-04e$texteaprile@formdlonge@namehmonth-05e$textcmaje@formdlonge@namehmonth-06e$textdjunie@formdlonge@namehmonth-07e$textdjulie@formdlonge@namehmonth-08e$textgaugustie@formdlonge@namehmonth-09e$textiseptembere@formdlonge@namehmonth-10e$textgoktobere@formdlonge@namehmonth-11e$texthnovembere@formdlonge@namehmonth-12e$texthdecembere@formdlonge@namehmonth-01e$textdjan.e@formeshorte@namehmonth-02e$textdfeb.e@formeshorte@namehmonth-03e$textdmar.e@formeshorte@namehmonth-04e$textdapr.e@formeshorte@namehmonth-05e$textcmaje@formeshorte@namehmonth-06e$textdjunie@formeshorte@namehmonth-07e$textdjulie@formeshorte@namehmonth-08e$textdaug.e@formeshorte@namehmonth-09e$textdsep.e@formeshorte@namehmonth-10e$textdokt.e@formeshorte@namehmonth-11e$textdnov.e@formeshorte@namehmonth-12e$textddec.e@formeshorte@nameiseason-01e$textdvåre@formdlonge@nameiseason-02e$textfsommare@formdlonge@nameiseason-03e$textehöste@formdlonge@nameiseason-04e$textfvintere@formdlongddatee@formdtextidate-parte@namecdaye@formunumeric-leading-zerosg@suffixa n@strip-periodse@nameemonthg@suffixa n@strip-periodse@namedyearn@strip-periodse@formgnumericidate-parte@namedyearn@strip-periodse@nameemonthe@formunumeric-leading-zerosp@range-delimitera/g@prefixa-n@strip-periodse@namecdaye@formunumeric-leading-zerosp@range-delimitera/g@prefixa-n@strip-periodsmstyle-optionsu@punctuation-in-quote \ No newline at end of file From 80506aac780fbf7ed8c48f2f944e2065deadce91 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 20:58:21 +0200 Subject: [PATCH 05/31] Remove unused dev dependencies --- Cargo.toml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 052997fe..739e0f03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,3 @@ unicode-segmentation = "1.6.0" thiserror = "2.0.16" unscanny = "0.1.0" url = { version = "2.4", features = ["serde"] } - -[workspace.dev-dependencies] -heck = "0.5" -serde_json = "1" -regex = "1" From dc9fa91822806ac295fadfa6991c4dd87530e092 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 20:58:36 +0200 Subject: [PATCH 06/31] Fix archiver path --- crates/hayagriva-archive/src/lib.rs | 2 +- crates/hayagriva-archive/tests/archiver.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index 44b31132..3b935436 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -1,5 +1,5 @@ //! Optional archive of included CSL styles. -// This file is generated by tests/generate.rs +// This file is generated by tests/archiver.rs // Do not edit by hand! use citationberg::{Locale, Style}; diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index 220d5c47..4200f6cb 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -1,5 +1,5 @@ //! Generates the archive of locales and styles for the 'archive' feature, as -//! well as the source code of 'src/csl/archive.rs', used to retrieve those +//! well as the source code of 'hayagriva-archive/src/lib.rs', used to retrieve those //! assets. The archive is downloaded from upstream CSL repositories into a //! `target` subfolder, where it's ready to be copied into the `archive` //! folder. @@ -50,7 +50,7 @@ const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; /// below: /// /// ```sh -/// cargo test --test archiver -- --ignored +/// cargo test -p hayagriva-archive --test archiver -- --ignored /// ``` #[test] #[ignore] @@ -247,7 +247,7 @@ fn write_styles_section( items: &[(Vec, IndependentStyle, Vec, String)], ) -> fmt::Result { writeln!(w, "//! Optional archive of included CSL styles.")?; - writeln!(w, "// This file is generated by tests/generate.rs")?; + writeln!(w, "// This file is generated by tests/archiver.rs")?; writeln!(w, "// Do not edit by hand!")?; writeln!(w)?; writeln!(w, "use citationberg::{{Locale, Style}};")?; From aaa07992f11ee93f9c40e87584df9c614c2097cb Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:02:37 +0200 Subject: [PATCH 07/31] Fix archive CI command --- .github/workflows/archive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/archive.yml b/.github/workflows/archive.yml index f003f2a0..b6d03acd 100644 --- a/.github/workflows/archive.yml +++ b/.github/workflows/archive.yml @@ -25,4 +25,4 @@ jobs: cd .. git clone --depth 1 https://github.com/citation-style-language/styles - name: Check if archives are up-to-date - run: cargo test --test archiver -- --ignored + run: cargo test -p hayagriva-archive --test archiver -- --ignored From 00d85d2aa6d78c8d72363358cab5e327241604e9 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:02:52 +0200 Subject: [PATCH 08/31] Clippy --- crates/hayagriva-cli/src/main.rs | 23 +++++++++++++++++++++++ crates/hayagriva-core/src/types/mod.rs | 23 ----------------------- crates/hayagriva-csl/src/lib.rs | 5 ----- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 85ba2823..84ee0738 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -972,4 +972,27 @@ mod tests { assert_eq!(actual, ["(33)", "()", "(34)"]); } + + #[test] + #[cfg(feature = "biblatex")] + fn test_issue_227() { + let yaml = r#" +AAAnonymous_AventureMortevielle_1987: + type: Book + page-range: 100"#; + + let library = crate::io::from_yaml_str(yaml).unwrap(); + let entry = library.get("AAAnonymous_AventureMortevielle_1987").unwrap(); + assert_eq!( + entry + .page_range() + .as_ref() + .unwrap() + .as_typed() + .unwrap() + .first() + .unwrap(), + &Numeric::new(100) + ); + } } diff --git a/crates/hayagriva-core/src/types/mod.rs b/crates/hayagriva-core/src/types/mod.rs index b677c023..f64a9448 100644 --- a/crates/hayagriva-core/src/types/mod.rs +++ b/crates/hayagriva-core/src/types/mod.rs @@ -640,27 +640,4 @@ mod tests { ); } } - - #[test] - #[cfg(feature = "biblatex")] - fn test_issue_227() { - let yaml = r#" -AAAnonymous_AventureMortevielle_1987: - type: Book - page-range: 100"#; - - let library = crate::io::from_yaml_str(yaml).unwrap(); - let entry = library.get("AAAnonymous_AventureMortevielle_1987").unwrap(); - assert_eq!( - entry - .page_range - .as_ref() - .unwrap() - .as_typed() - .unwrap() - .first() - .unwrap(), - &Numeric::new(100) - ); - } } diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index 045ee529..be2f0659 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -3416,11 +3416,6 @@ fn get_last_text(child: &mut ElemChild) -> Option<&mut String> { #[cfg(test)] mod tests { - use std::{fs, path::Path}; - - use citationberg::LocaleFile; - use hayagriva_core::{Numeric, NumericValue}; - use super::*; #[test] From 6c343fd8a586b364a23bffe8fb0b014cff64cb42 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:08:47 +0200 Subject: [PATCH 09/31] Fix docs --- crates/hayagriva-cli/src/main.rs | 137 ++++++++++++++++++ crates/hayagriva-core/src/util.rs | 2 +- crates/hayagriva-csl/src/lib.rs | 2 +- crates/hayagriva-format/src/citation_label.rs | 2 +- crates/hayagriva-format/src/lib.rs | 137 +----------------- crates/hayagriva-format/src/selectors/mod.rs | 2 +- 6 files changed, 142 insertions(+), 140 deletions(-) diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 84ee0738..6bd6208d 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -1,3 +1,140 @@ +/*! +Hayagriva provides a YAML-backed format and data model for various +bibliography items as well as a CSL processor formatting both in-text citations and +reference lists based on these literature databases. + +The crate is intended to assist scholarly writing and reference management +and can be used both through a CLI and an API. + +Below, there is an example of how to parse a YAML database and get a Modern +Language Association-style citation. + +# Supported styles + +Hayagriva supports all styles provided in the +[official Citation Style Language repository](https://github.com/citation-style-language/styles), +currently over 2,600. You can provide your own style files or use the ones +bundled with this library in the [`hayagriva_archive`] crate. + +# Usage + +```rust +use hayagriva::io::from_yaml_str; + +let yaml = r#" +crazy-rich: + type: Book + title: Crazy Rich Asians + author: Kwan, Kevin + date: 2014 + publisher: Anchor Books + location: New York, NY, US +"#; + +// Parse a bibliography +let bib = from_yaml_str(yaml).unwrap(); +assert_eq!(bib.get("crazy-rich").unwrap().date().unwrap().year, 2014); + +// Format the reference +use std::fs; +use hayagriva::{ + BibliographyDriver, BibliographyRequest, BufWriteFormat, + CitationItem, CitationRequest, +}; +use hayagriva::citationberg::{LocaleFile, IndependentStyle}; + +let en_locale = fs::read_to_string("tests/data/locales-en-US.xml").unwrap(); +let locales = [LocaleFile::from_xml(&en_locale).unwrap().into()]; + +let style = fs::read_to_string("tests/data/art-history.csl").unwrap(); +let style = IndependentStyle::from_xml(&style).unwrap(); + +let mut driver = BibliographyDriver::new(); + +for entry in bib.iter() { + let items = vec![CitationItem::with_entry(entry)]; + driver.citation(CitationRequest::from_items(items, &style, &locales)); +} + +let result = driver.finish(BibliographyRequest { + style: &style, + locale: None, + locale_files: &locales, +}); + +for cite in result.citations { + println!("{}", cite.citation) +} +``` + +To format entries, you need to wrap them in a [`CitationRequest`]. Each of these +can reference multiple entries in their respective [`CitationItem`]s. +Use these with a [`BibliographyDriver`] to obtain formatted citations and bibliographies. + +If the default features are enabled, Hayagriva supports BibTeX and BibLaTeX +bibliographies. You can use [`io::from_biblatex_str`] to parse such +bibliographies. + +Should you need more manual control, the library's native `Entry` struct +also offers an implementation of the `From<&biblatex::Entry>`-Trait. You will +need to depend on the [biblatex](https://docs.rs/biblatex/latest/biblatex/) +crate to obtain its `Entry`. Therefore, you could also use your BibLaTeX +content like this: + +```ignore +use hayagriva::Entry; +let converted: Entry = your_biblatex_entry.into(); +``` + +If you do not need BibLaTeX compatibility, you can use Hayagriva without the +default features by writing this in your `Cargo.toml`: + +```toml +[dependencies] +hayagriva = { version = "0.9", default-features = false } +``` + +# Selectors + +Hayagriva uses a custom selector language that enables you to filter +bibliographies by type of media. For more information about selectors, refer +to the [selectors.md +file](https://github.com/typst/hayagriva/blob/main/docs/selectors.md). While +you can parse user-defined selectors using the function `Selector::parse`, +you may instead want to use the selector macro to avoid the run time cost of +parsing a selector when working with constant selectors. + +```rust +use hayagriva::select; +use hayagriva::io::from_yaml_str; + +let yaml = r#" +quantized-vortex: + type: Article + author: Gross, E. P. + title: Structure of a Quantized Vortex in Boson Systems + date: 1961-05 + page-range: 454-477 + serial-number: + doi: 10.1007/BF02731494 + parent: + issue: 3 + volume: 20 + title: Il Nuovo Cimento +"#; + +let entries = from_yaml_str(yaml).unwrap(); +let journal = select!((Article["date"]) > ("journal":Periodical)); +assert!(journal.matches(entries.nth(0).unwrap())); +``` + +There are two ways to check if a selector matches an entry. +You should use [`Selector::matches`] if you just want to know if an item +matches a selector and [`Selector::apply`] to continue to work with the data from +parents of a matching entry. Keep in mind that the latter function will +return `Some` even if no sub-entry was bound / if the hash map is empty. +*/ + use std::borrow::Cow; use std::fs::{self, read_to_string}; use std::io::ErrorKind as IoErrorKind; diff --git a/crates/hayagriva-core/src/util.rs b/crates/hayagriva-core/src/util.rs index 772fdfbf..084c966b 100644 --- a/crates/hayagriva-core/src/util.rs +++ b/crates/hayagriva-core/src/util.rs @@ -82,7 +82,7 @@ where /// This is a wrapper for [`OneOrMany`] that assumes that the single /// representation isn't a sequence. This allows better error messages. #[derive(Clone, Debug, PartialEq, Eq)] -struct MapOneOrMany(OneOrMany); +pub struct MapOneOrMany(OneOrMany); impl From> for OneOrMany { fn from(from: MapOneOrMany) -> Self { diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index be2f0659..433a9e2c 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -2008,7 +2008,7 @@ impl<'a> BibliographyRequest<'a> { } } -/// A reference to an [`crate::Entry`] within a [`CitationRequest`]. +/// A reference to an [`EntryLike`] within a [`CitationRequest`]. #[derive(Debug, Clone, PartialEq)] pub struct CitationItem<'a, T: EntryLike> { /// The entry to format. diff --git a/crates/hayagriva-format/src/citation_label.rs b/crates/hayagriva-format/src/citation_label.rs index 80efc90d..5625e00b 100644 --- a/crates/hayagriva-format/src/citation_label.rs +++ b/crates/hayagriva-format/src/citation_label.rs @@ -25,7 +25,7 @@ impl Default for Alphanumerical { } impl Alphanumerical { - /// Create a new instance of this [`CitationStyle`]. + /// Create a new instance of this citation style. pub fn new() -> Self { Self { letters: 3 } } diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 94ec4003..b16eb59f 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -1,139 +1,4 @@ -/*! -Hayagriva provides a YAML-backed format and data model for various -bibliography items as well as a CSL processor formatting both in-text citations and -reference lists based on these literature databases. - -The crate is intended to assist scholarly writing and reference management -and can be used both through a CLI and an API. - -Below, there is an example of how to parse a YAML database and get a Modern -Language Association-style citation. - -# Supported styles - -Hayagriva supports all styles provided in the -[official Citation Style Language repository](https://github.com/citation-style-language/styles), -currently over 2,600. You can provide your own style files or use the ones -bundled with this library in the [`archive`] module. - -# Usage - -```rust -use hayagriva::io::from_yaml_str; - -let yaml = r#" -crazy-rich: - type: Book - title: Crazy Rich Asians - author: Kwan, Kevin - date: 2014 - publisher: Anchor Books - location: New York, NY, US -"#; - -// Parse a bibliography -let bib = from_yaml_str(yaml).unwrap(); -assert_eq!(bib.get("crazy-rich").unwrap().date().unwrap().year, 2014); - -// Format the reference -use std::fs; -use hayagriva::{ - BibliographyDriver, BibliographyRequest, BufWriteFormat, - CitationItem, CitationRequest, -}; -use hayagriva::citationberg::{LocaleFile, IndependentStyle}; - -let en_locale = fs::read_to_string("tests/data/locales-en-US.xml").unwrap(); -let locales = [LocaleFile::from_xml(&en_locale).unwrap().into()]; - -let style = fs::read_to_string("tests/data/art-history.csl").unwrap(); -let style = IndependentStyle::from_xml(&style).unwrap(); - -let mut driver = BibliographyDriver::new(); - -for entry in bib.iter() { - let items = vec![CitationItem::with_entry(entry)]; - driver.citation(CitationRequest::from_items(items, &style, &locales)); -} - -let result = driver.finish(BibliographyRequest { - style: &style, - locale: None, - locale_files: &locales, -}); - -for cite in result.citations { - println!("{}", cite.citation) -} -``` - -To format entries, you need to wrap them in a [`CitationRequest`]. Each of these -can reference multiple entries in their respective [`CitationItem`]s. -Use these with a [`BibliographyDriver`] to obtain formatted citations and bibliographies. - -If the default features are enabled, Hayagriva supports BibTeX and BibLaTeX -bibliographies. You can use [`io::from_biblatex_str`] to parse such -bibliographies. - -Should you need more manual control, the library's native `Entry` struct -also offers an implementation of the `From<&biblatex::Entry>`-Trait. You will -need to depend on the [biblatex](https://docs.rs/biblatex/latest/biblatex/) -crate to obtain its `Entry`. Therefore, you could also use your BibLaTeX -content like this: - -```ignore -use hayagriva::Entry; -let converted: Entry = your_biblatex_entry.into(); -``` - -If you do not need BibLaTeX compatibility, you can use Hayagriva without the -default features by writing this in your `Cargo.toml`: - -```toml -[dependencies] -hayagriva = { version = "0.9", default-features = false } -``` - -# Selectors - -Hayagriva uses a custom selector language that enables you to filter -bibliographies by type of media. For more information about selectors, refer -to the [selectors.md -file](https://github.com/typst/hayagriva/blob/main/docs/selectors.md). While -you can parse user-defined selectors using the function `Selector::parse`, -you may instead want to use the selector macro to avoid the run time cost of -parsing a selector when working with constant selectors. - -```rust -use hayagriva::select; -use hayagriva::io::from_yaml_str; - -let yaml = r#" -quantized-vortex: - type: Article - author: Gross, E. P. - title: Structure of a Quantized Vortex in Boson Systems - date: 1961-05 - page-range: 454-477 - serial-number: - doi: 10.1007/BF02731494 - parent: - issue: 3 - volume: 20 - title: Il Nuovo Cimento -"#; - -let entries = from_yaml_str(yaml).unwrap(); -let journal = select!((Article["date"]) > ("journal":Periodical)); -assert!(journal.matches(entries.nth(0).unwrap())); -``` - -There are two ways to check if a selector matches an entry. -You should use [`Selector::matches`] if you just want to know if an item -matches a selector and [`Selector::apply`] to continue to work with the data from -parents of a matching entry. Keep in mind that the latter function will -return `Some` even if no sub-entry was bound / if the hash map is empty. -*/ +//! The Hayagriva format #![warn(missing_docs)] #![allow(clippy::comparison_chain)] diff --git a/crates/hayagriva-format/src/selectors/mod.rs b/crates/hayagriva-format/src/selectors/mod.rs index 9576062f..51cb16d8 100644 --- a/crates/hayagriva-format/src/selectors/mod.rs +++ b/crates/hayagriva-format/src/selectors/mod.rs @@ -39,7 +39,7 @@ /// ``` /// /// [intro]: https://github.com/typst/hayagriva/blob/main/docs/selectors.md -/// [EType]: crate::types::EntryType +/// [EType]: hayagriva_core::types::EntryType #[macro_export] macro_rules! select { (($($tts:tt)*)) => { From c57e3f2268208f64572950a9f89f8e6c13a2dc73 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:16:21 +0200 Subject: [PATCH 10/31] Fix tests --- .github/workflows/ci.yml | 2 +- crates/hayagriva-cli/src/main.rs | 5 +++-- crates/hayagriva-format/src/io.rs | 4 ++-- crates/hayagriva-format/src/lib.rs | 4 ++-- crates/hayagriva-format/src/selectors/mod.rs | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acf18642..70b258e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: dtolnay/rust-toolchain@3056ad9b1fc916cb9a55f7f72ae4a848b7d50249 # 1.91.0 - run: cargo build - - run: cargo test --features csl-json + - run: cargo test --all-features checks: name: Check clippy, formatting, and documentation diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 6bd6208d..46c76e6d 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -643,7 +643,7 @@ mod tests { #[test] fn test_csl() { - let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); + let workspace = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../"); let en_locale = fs::read_to_string(workspace.join("tests/data/locales-en-US.xml")).unwrap(); let en_locale = LocaleFile::from_xml(&en_locale).unwrap(); @@ -814,7 +814,8 @@ mod tests { #[test] fn test_chapter_field() { let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); - let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); + let yaml = + fs::read_to_string(workspace.join("../../tests/data/basic.yml")).unwrap(); let bib = from_yaml_str(&yaml).unwrap(); let book = bib.get("lamb").unwrap(); assert_eq!(book.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(20))); diff --git a/crates/hayagriva-format/src/io.rs b/crates/hayagriva-format/src/io.rs index fbee6f4e..cb99832c 100644 --- a/crates/hayagriva-format/src/io.rs +++ b/crates/hayagriva-format/src/io.rs @@ -10,7 +10,7 @@ use crate::Library; /// Parse a bibliography from a YAML string. /// /// ``` -/// use hayagriva::io::from_yaml_str; +/// use hayagriva_format::io::from_yaml_str; /// /// let yaml = r#" /// crazy-rich: @@ -90,7 +90,7 @@ mod tests { #[test] fn roundtrip() { - let contents = fs::read_to_string("tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); let yaml = to_yaml_str(&entries).unwrap(); println!("{}", &yaml); diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index b16eb59f..82efe3d9 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -797,7 +797,7 @@ mod tests { #[test] fn selectors() { - let contents = fs::read_to_string("tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select_all!("article > proceedings", entries, ["zygos"]); @@ -865,7 +865,7 @@ mod tests { #[test] fn selector_bindings() { - let contents = fs::read_to_string("tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select!( diff --git a/crates/hayagriva-format/src/selectors/mod.rs b/crates/hayagriva-format/src/selectors/mod.rs index 51cb16d8..41270051 100644 --- a/crates/hayagriva-format/src/selectors/mod.rs +++ b/crates/hayagriva-format/src/selectors/mod.rs @@ -21,8 +21,8 @@ /// This example illustrates some of the differences: /// /// ```rust -/// use hayagriva::select; -/// use hayagriva::Selector; +/// use hayagriva_format::select; +/// use hayagriva_format::Selector; /// /// // finds an article that is parented by a conference proceedings volume /// assert_eq!(Selector::parse("article > proceedings").unwrap(), select!(Article > Proceedings)); From add2339985e6cb5eb792a3bafeea3828c75ea162 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:27:07 +0200 Subject: [PATCH 11/31] Rework citeproc tests --- Cargo.lock | 12 ++++++++++ Cargo.toml | 2 +- crates/tests/Cargo.toml | 22 +++++++++++++++++++ .../common/mod.rs => crates/tests/src/lib.rs | 0 .../tests/tests}/citeproc-pass.txt | 0 {tests => crates/tests/tests}/citeproc.rs | 11 +++++----- .../tests/tests}/data/art-history.csl | 0 {tests => crates/tests/tests}/data/basic.yml | 0 .../tests/tests}/data/locales-en-US.xml | 0 {tests => crates/tests/tests}/data/lotr.bib | 0 .../tests/tests}/local/affix_DoiUrlPrefix.txt | 0 .../local/choose_UseAncestorsDelimiter.txt | 0 ...collapse_CitationNumberRangesSeparated.txt | 0 .../collapse_CitationNumberRangesSort.txt | 0 .../tests}/local/date_DateBCAdjusted.txt | 0 .../local/date_LocalizedDateDelimiters.txt | 0 .../tests}/local/date_NegativeDateSort.txt | 0 .../local/date_NegativeDateSortViaMacro.txt | 0 ...egativeDateSortViaMacroOnYearMonthOnly.txt | 0 .../local/name_PartInheritsFormatting.txt | 0 .../local/name_SubsequentAuthorSubstitute.txt | 0 .../tests/tests}/local/page_NumberPage.txt | 0 .../tests}/local/page_NumberPageMacroSort.txt | 0 .../tests}/local/page_NumberPageSort.txt | 0 .../position_IbidIsNotIbidWithLocator.txt | 0 .../local/position_IbidWithLocatorIsIbid.txt | 0 .../tests/tests}/local/sort_Unicode.txt | 0 27 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 crates/tests/Cargo.toml rename tests/common/mod.rs => crates/tests/src/lib.rs (100%) rename {tests => crates/tests/tests}/citeproc-pass.txt (100%) rename {tests => crates/tests/tests}/citeproc.rs (99%) rename {tests => crates/tests/tests}/data/art-history.csl (100%) rename {tests => crates/tests/tests}/data/basic.yml (100%) rename {tests => crates/tests/tests}/data/locales-en-US.xml (100%) rename {tests => crates/tests/tests}/data/lotr.bib (100%) rename {tests => crates/tests/tests}/local/affix_DoiUrlPrefix.txt (100%) rename {tests => crates/tests/tests}/local/choose_UseAncestorsDelimiter.txt (100%) rename {tests => crates/tests/tests}/local/collapse_CitationNumberRangesSeparated.txt (100%) rename {tests => crates/tests/tests}/local/collapse_CitationNumberRangesSort.txt (100%) rename {tests => crates/tests/tests}/local/date_DateBCAdjusted.txt (100%) rename {tests => crates/tests/tests}/local/date_LocalizedDateDelimiters.txt (100%) rename {tests => crates/tests/tests}/local/date_NegativeDateSort.txt (100%) rename {tests => crates/tests/tests}/local/date_NegativeDateSortViaMacro.txt (100%) rename {tests => crates/tests/tests}/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt (100%) rename {tests => crates/tests/tests}/local/name_PartInheritsFormatting.txt (100%) rename {tests => crates/tests/tests}/local/name_SubsequentAuthorSubstitute.txt (100%) rename {tests => crates/tests/tests}/local/page_NumberPage.txt (100%) rename {tests => crates/tests/tests}/local/page_NumberPageMacroSort.txt (100%) rename {tests => crates/tests/tests}/local/page_NumberPageSort.txt (100%) rename {tests => crates/tests/tests}/local/position_IbidIsNotIbidWithLocator.txt (100%) rename {tests => crates/tests/tests}/local/position_IbidWithLocatorIsIbid.txt (100%) rename {tests => crates/tests/tests}/local/sort_Unicode.txt (100%) diff --git a/Cargo.lock b/Cargo.lock index 66cb1b77..bf81a392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,6 +708,18 @@ dependencies = [ "syn", ] +[[package]] +name = "tests" +version = "0.10.0" +dependencies = [ + "citationberg", + "hayagriva-archive", + "hayagriva-csl", + "hayagriva-format", + "hayagriva-util", + "unscanny", +] + [[package]] name = "thiserror" version = "2.0.18" diff --git a/Cargo.toml b/Cargo.toml index 739e0f03..bf744f8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ "crates/hayagriva-csl", "crates/hayagriva-format", "crates/hayagriva-json", - "crates/hayagriva-util", + "crates/hayagriva-util", "crates/tests", ] resolver = "2" diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml new file mode 100644 index 00000000..ab44d201 --- /dev/null +++ b/crates/tests/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "tests" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +readme.workspace = true +keywords.workspace = true +publish = false + +[dev-dependencies] +citationberg = { workspace = true, features = ["json"] } +hayagriva-archive = { path = "../hayagriva-archive" } +hayagriva-csl = { path = "../hayagriva-csl" } +hayagriva-format = { path = "../hayagriva-format" } +hayagriva-util = { path = "../hayagriva-util" } +unscanny = { workspace = true } + +[[test]] +name = "citeproc" +path = "tests/citeproc.rs" diff --git a/tests/common/mod.rs b/crates/tests/src/lib.rs similarity index 100% rename from tests/common/mod.rs rename to crates/tests/src/lib.rs diff --git a/tests/citeproc-pass.txt b/crates/tests/tests/citeproc-pass.txt similarity index 100% rename from tests/citeproc-pass.txt rename to crates/tests/tests/citeproc-pass.txt diff --git a/tests/citeproc.rs b/crates/tests/tests/citeproc.rs similarity index 99% rename from tests/citeproc.rs rename to crates/tests/tests/citeproc.rs index c827311f..3aa4a10b 100644 --- a/tests/citeproc.rs +++ b/crates/tests/tests/citeproc.rs @@ -6,18 +6,17 @@ use std::str::FromStr; use std::sync::OnceLock; use std::{fmt, fs}; -mod common; use citationberg::taxonomy::Locator; use citationberg::{Locale, LocaleCode, Style, XmlDeError}; -use common::{CACHE_PATH, ensure_repo, iter_files_with_name}; +use hayagriva_util::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; use citationberg::json as csl_json; -use hayagriva::archive::{ArchivedStyle, locales}; -use hayagriva::io::from_biblatex_str; -use hayagriva::{ +use hayagriva_archive::{ArchivedStyle, locales}; +use hayagriva_csl::{ BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, CitePurpose, - Entry, LocatorPayload, SpecificLocator, + LocatorPayload, SpecificLocator, }; +use hayagriva_format::{Entry, io::from_biblatex_str}; use unscanny::Scanner; const TEST_REPO_NAME: &str = "test-suite"; diff --git a/tests/data/art-history.csl b/crates/tests/tests/data/art-history.csl similarity index 100% rename from tests/data/art-history.csl rename to crates/tests/tests/data/art-history.csl diff --git a/tests/data/basic.yml b/crates/tests/tests/data/basic.yml similarity index 100% rename from tests/data/basic.yml rename to crates/tests/tests/data/basic.yml diff --git a/tests/data/locales-en-US.xml b/crates/tests/tests/data/locales-en-US.xml similarity index 100% rename from tests/data/locales-en-US.xml rename to crates/tests/tests/data/locales-en-US.xml diff --git a/tests/data/lotr.bib b/crates/tests/tests/data/lotr.bib similarity index 100% rename from tests/data/lotr.bib rename to crates/tests/tests/data/lotr.bib diff --git a/tests/local/affix_DoiUrlPrefix.txt b/crates/tests/tests/local/affix_DoiUrlPrefix.txt similarity index 100% rename from tests/local/affix_DoiUrlPrefix.txt rename to crates/tests/tests/local/affix_DoiUrlPrefix.txt diff --git a/tests/local/choose_UseAncestorsDelimiter.txt b/crates/tests/tests/local/choose_UseAncestorsDelimiter.txt similarity index 100% rename from tests/local/choose_UseAncestorsDelimiter.txt rename to crates/tests/tests/local/choose_UseAncestorsDelimiter.txt diff --git a/tests/local/collapse_CitationNumberRangesSeparated.txt b/crates/tests/tests/local/collapse_CitationNumberRangesSeparated.txt similarity index 100% rename from tests/local/collapse_CitationNumberRangesSeparated.txt rename to crates/tests/tests/local/collapse_CitationNumberRangesSeparated.txt diff --git a/tests/local/collapse_CitationNumberRangesSort.txt b/crates/tests/tests/local/collapse_CitationNumberRangesSort.txt similarity index 100% rename from tests/local/collapse_CitationNumberRangesSort.txt rename to crates/tests/tests/local/collapse_CitationNumberRangesSort.txt diff --git a/tests/local/date_DateBCAdjusted.txt b/crates/tests/tests/local/date_DateBCAdjusted.txt similarity index 100% rename from tests/local/date_DateBCAdjusted.txt rename to crates/tests/tests/local/date_DateBCAdjusted.txt diff --git a/tests/local/date_LocalizedDateDelimiters.txt b/crates/tests/tests/local/date_LocalizedDateDelimiters.txt similarity index 100% rename from tests/local/date_LocalizedDateDelimiters.txt rename to crates/tests/tests/local/date_LocalizedDateDelimiters.txt diff --git a/tests/local/date_NegativeDateSort.txt b/crates/tests/tests/local/date_NegativeDateSort.txt similarity index 100% rename from tests/local/date_NegativeDateSort.txt rename to crates/tests/tests/local/date_NegativeDateSort.txt diff --git a/tests/local/date_NegativeDateSortViaMacro.txt b/crates/tests/tests/local/date_NegativeDateSortViaMacro.txt similarity index 100% rename from tests/local/date_NegativeDateSortViaMacro.txt rename to crates/tests/tests/local/date_NegativeDateSortViaMacro.txt diff --git a/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt b/crates/tests/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt similarity index 100% rename from tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt rename to crates/tests/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt diff --git a/tests/local/name_PartInheritsFormatting.txt b/crates/tests/tests/local/name_PartInheritsFormatting.txt similarity index 100% rename from tests/local/name_PartInheritsFormatting.txt rename to crates/tests/tests/local/name_PartInheritsFormatting.txt diff --git a/tests/local/name_SubsequentAuthorSubstitute.txt b/crates/tests/tests/local/name_SubsequentAuthorSubstitute.txt similarity index 100% rename from tests/local/name_SubsequentAuthorSubstitute.txt rename to crates/tests/tests/local/name_SubsequentAuthorSubstitute.txt diff --git a/tests/local/page_NumberPage.txt b/crates/tests/tests/local/page_NumberPage.txt similarity index 100% rename from tests/local/page_NumberPage.txt rename to crates/tests/tests/local/page_NumberPage.txt diff --git a/tests/local/page_NumberPageMacroSort.txt b/crates/tests/tests/local/page_NumberPageMacroSort.txt similarity index 100% rename from tests/local/page_NumberPageMacroSort.txt rename to crates/tests/tests/local/page_NumberPageMacroSort.txt diff --git a/tests/local/page_NumberPageSort.txt b/crates/tests/tests/local/page_NumberPageSort.txt similarity index 100% rename from tests/local/page_NumberPageSort.txt rename to crates/tests/tests/local/page_NumberPageSort.txt diff --git a/tests/local/position_IbidIsNotIbidWithLocator.txt b/crates/tests/tests/local/position_IbidIsNotIbidWithLocator.txt similarity index 100% rename from tests/local/position_IbidIsNotIbidWithLocator.txt rename to crates/tests/tests/local/position_IbidIsNotIbidWithLocator.txt diff --git a/tests/local/position_IbidWithLocatorIsIbid.txt b/crates/tests/tests/local/position_IbidWithLocatorIsIbid.txt similarity index 100% rename from tests/local/position_IbidWithLocatorIsIbid.txt rename to crates/tests/tests/local/position_IbidWithLocatorIsIbid.txt diff --git a/tests/local/sort_Unicode.txt b/crates/tests/tests/local/sort_Unicode.txt similarity index 100% rename from tests/local/sort_Unicode.txt rename to crates/tests/tests/local/sort_Unicode.txt From da6a64a0178bb3b10f08486b889eeeb3e2adbb6b Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 16 Jun 2026 21:49:03 +0200 Subject: [PATCH 12/31] Citeproc tests --- Cargo.lock | 43 ++++++++++++++++++++++ crates/hayagriva-cli/src/main.rs | 13 ++++--- crates/hayagriva-format/src/io.rs | 2 +- crates/hayagriva-format/src/lib.rs | 5 +-- crates/hayagriva-json/Cargo.toml | 1 + crates/hayagriva-json/src/lib.rs | 3 ++ crates/tests/Cargo.toml | 6 +++- crates/tests/tests/citeproc.rs | 58 ++++++++++++++++-------------- 8 files changed, 97 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf81a392..2ad1a167 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "anstream" version = "1.0.0" @@ -274,6 +283,7 @@ version = "0.10.0" dependencies = [ "citationberg", "hayagriva-core", + "serde", ] [[package]] @@ -540,6 +550,35 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + [[package]] name = "roman-numerals-rs" version = "3.1.0" @@ -714,9 +753,13 @@ version = "0.10.0" dependencies = [ "citationberg", "hayagriva-archive", + "hayagriva-core", "hayagriva-csl", "hayagriva-format", + "hayagriva-json", "hayagriva-util", + "regex", + "serde_json", "unscanny", ] diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 46c76e6d..05ca9dd4 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -644,11 +644,15 @@ mod tests { #[test] fn test_csl() { let workspace = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../"); - let en_locale = - fs::read_to_string(workspace.join("tests/data/locales-en-US.xml")).unwrap(); + let en_locale = fs::read_to_string( + workspace.join("crates/tests/tests/data/locales-en-US.xml"), + ) + .unwrap(); let en_locale = LocaleFile::from_xml(&en_locale).unwrap(); - let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); + let yaml = + fs::read_to_string(workspace.join("crates/tests/tests/data/basic.yml")) + .unwrap(); let bib = from_yaml_str(&yaml).unwrap(); let en_locale = [en_locale.into()]; @@ -815,7 +819,8 @@ mod tests { fn test_chapter_field() { let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); let yaml = - fs::read_to_string(workspace.join("../../tests/data/basic.yml")).unwrap(); + fs::read_to_string(workspace.join("../../crates/tests/tests/data/basic.yml")) + .unwrap(); let bib = from_yaml_str(&yaml).unwrap(); let book = bib.get("lamb").unwrap(); assert_eq!(book.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(20))); diff --git a/crates/hayagriva-format/src/io.rs b/crates/hayagriva-format/src/io.rs index cb99832c..3962ca28 100644 --- a/crates/hayagriva-format/src/io.rs +++ b/crates/hayagriva-format/src/io.rs @@ -90,7 +90,7 @@ mod tests { #[test] fn roundtrip() { - let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); let yaml = to_yaml_str(&entries).unwrap(); println!("{}", &yaml); diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 82efe3d9..7eee0009 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -7,6 +7,7 @@ mod selectors; pub mod citation_label; +#[cfg(feature = "biblatex")] mod interop; pub mod io; pub mod taxonomy; @@ -797,7 +798,7 @@ mod tests { #[test] fn selectors() { - let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select_all!("article > proceedings", entries, ["zygos"]); @@ -865,7 +866,7 @@ mod tests { #[test] fn selector_bindings() { - let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select!( diff --git a/crates/hayagriva-json/Cargo.toml b/crates/hayagriva-json/Cargo.toml index 5af04919..f8bb5f93 100644 --- a/crates/hayagriva-json/Cargo.toml +++ b/crates/hayagriva-json/Cargo.toml @@ -12,3 +12,4 @@ keywords.workspace = true [dependencies] citationberg = { workspace = true, features = ["json"] } hayagriva-core = { path = "../hayagriva-core" } +serde = { workspace = true, features = ["derive"] } diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-json/src/lib.rs index fe1e4ac1..24ed73ce 100644 --- a/crates/hayagriva-json/src/lib.rs +++ b/crates/hayagriva-json/src/lib.rs @@ -9,7 +9,10 @@ use citationberg::{ use hayagriva_core::{ ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, Person, StringChunk, }; +use serde::{Deserialize, Serialize}; +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] +#[serde(transparent)] pub struct Item(pub csl_json::Item); fn resolve_csl_json_standard_variable( diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index ab44d201..7b7a064b 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -12,9 +12,13 @@ publish = false [dev-dependencies] citationberg = { workspace = true, features = ["json"] } hayagriva-archive = { path = "../hayagriva-archive" } +hayagriva-core = { path = "../hayagriva-core" } hayagriva-csl = { path = "../hayagriva-csl" } -hayagriva-format = { path = "../hayagriva-format" } +hayagriva-format = { path = "../hayagriva-format", features = ["biblatex"] } +hayagriva-json = { path = "../hayagriva-json" } hayagriva-util = { path = "../hayagriva-util" } +serde_json = "1" +regex = "1" unscanny = { workspace = true } [[test]] diff --git a/crates/tests/tests/citeproc.rs b/crates/tests/tests/citeproc.rs index 3aa4a10b..2d1869e9 100644 --- a/crates/tests/tests/citeproc.rs +++ b/crates/tests/tests/citeproc.rs @@ -222,7 +222,7 @@ struct TestCase { mode: TestMode, result: String, csl: Style, - input: Vec, + input: Vec, bib_entries: Option>>, bib_section: Option, citation_items: Option>>, @@ -494,7 +494,7 @@ where let contains_date_ranges = case .input .iter() - .flat_map(|i| i.0.values()) + .flat_map(|i| i.0.0.values()) .filter_map(|v| if let csl_json::Value::Date(d) = v { Some(d) } else { None }) .any(|d| { csl_json::FixedDateRange::try_from(d.clone()).is_ok_and(|d| d.end.is_some()) @@ -518,7 +518,7 @@ where eprintln!("Skipping test {}\t(cause: date ranges)", display()); } false - } else if case.input.iter().any(|i| i.has_html() || i.may_have_hack()) { + } else if case.input.iter().any(|i| i.0.has_html() || i.0.may_have_hack()) { if print { eprintln!("Skipping test {}\t(cause: HTML suspected in input)", display()); } @@ -537,7 +537,8 @@ where panic!("test {} has dependent style", display()); }; - let mut driver: BibliographyDriver<'_, csl_json::Item> = BibliographyDriver::new(); + let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = + BibliographyDriver::new(); let mut output = String::new(); if let Some(cites) = &case.citation_items { for cite in cites { @@ -547,7 +548,7 @@ where CitationItem::new( case.input .iter() - .find(|e| e.id().unwrap_or_default() == i.id.as_str()) + .find(|e| e.0.id().unwrap_or_default() == i.id.as_str()) .unwrap(), i.locator.as_deref().map(|lo| { SpecificLocator( @@ -561,7 +562,7 @@ where None, false, if i.suppress_author { - Some(hayagriva::CitePurpose::Author) + Some(hayagriva_csl::CitePurpose::Author) } else { None }, @@ -591,7 +592,7 @@ where for citation in rendered.citations { citation .citation - .write_buf(&mut output, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut output, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); output.push('\n'); } @@ -641,10 +642,10 @@ mod citeproc_bib { use citationberg::{ Display, FontStyle, FontVariant, FontWeight, TextDecoration, VerticalAlign, }; - use hayagriva::{BufWriteFormat, Elem, ElemChild, Formatting}; + use hayagriva_csl::{BufWriteFormat, Elem, ElemChild, Formatting}; pub(super) fn render( - bib: &hayagriva::RenderedBibliography, + bib: &hayagriva_csl::RenderedBibliography, output: &mut String, is_full: bool, ) -> Result<(), fmt::Error> { @@ -657,7 +658,7 @@ mod citeproc_bib { } fn render_item( - item: &hayagriva::BibliographyItem, + item: &hayagriva_csl::BibliographyItem, output: &mut String, is_full: bool, ) -> Result<(), fmt::Error> { @@ -712,7 +713,7 @@ mod citeproc_bib { /// this notation, especially since we do not expose csl-json input to /// hayagriva users anyway. fn render_formatted_text( - text: &hayagriva::Formatted, + text: &hayagriva_csl::Formatted, output: &mut String, ) -> Result<(), fmt::Error> { let formatting = text.formatting; @@ -830,8 +831,9 @@ fn purposes() { panic!("test has dependent style"); }; - let item: csl_json::Item = serde_json::from_str( - r#"{ + let item = hayagriva_json::Item( + serde_json::from_str( + r#"{ "id": "ITEM-1", "title": "Book A", "author": [ @@ -849,8 +851,9 @@ fn purposes() { }, "type": "book" }"#, - ) - .unwrap(); + ) + .unwrap(), + ); for (purpose, res) in [ (CitePurpose::Author, "Doe"), @@ -858,7 +861,7 @@ fn purposes() { (CitePurpose::Year, "2000"), (CitePurpose::Full, "Doe, J. (2000). Book A."), ] { - let mut driver: BibliographyDriver<'_, csl_json::Item> = + let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = BibliographyDriver::new(); driver.citation(CitationRequest::new( vec![CitationItem::new(&item, None, None, false, Some(purpose))], @@ -872,7 +875,7 @@ fn purposes() { let mut buf = String::new(); rendered.citations[0] .citation - .write_buf(&mut buf, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut buf, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); assert_eq!(buf, res); } @@ -920,16 +923,19 @@ fn case_folding() { panic!("test has dependent style"); }; - let item: csl_json::Item = serde_json::from_str( - r#"{ + let item: hayagriva_json::Item = hayagriva_json::Item( + serde_json::from_str( + r#"{ "id": "ITEM-1", "container-title": "my lowercase container title", "type": "paper-conference" }"#, - ) - .unwrap(); + ) + .unwrap(), + ); - let mut driver: BibliographyDriver<'_, csl_json::Item> = BibliographyDriver::new(); + let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = + BibliographyDriver::new(); driver.citation(CitationRequest::new( vec![CitationItem::new(&item, None, None, false, None)], &style, @@ -946,7 +952,7 @@ fn case_folding() { let mut buf = String::new(); rendered.bibliography.unwrap().items[0] .content - .write_buf(&mut buf, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut buf, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); assert_eq!(buf, "my lowercase container title."); } @@ -982,7 +988,7 @@ fn access_date() { let mut buf = String::new(); rendered.bibliography.unwrap().items[0] .content - .write_buf(&mut buf, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut buf, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); assert_eq!(buf, "(n.d.). Retrieved 2021, from https://example.com/"); } @@ -1023,7 +1029,7 @@ fn no_author() { let mut buf = String::new(); rendered.bibliography.unwrap().items[0] .content - .write_buf(&mut buf, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut buf, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); assert_eq!( @@ -1034,7 +1040,7 @@ fn no_author() { let mut buf = String::new(); rendered.citations[0] .citation - .write_buf(&mut buf, hayagriva::BufWriteFormat::Plain) + .write_buf(&mut buf, hayagriva_csl::BufWriteFormat::Plain) .unwrap(); assert_eq!(buf, "(Definition and Objectives of Systems Development, 2016)"); } From 01db8fd0daf7c32e6fb0d3eb0321622b0f1a1f04 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Wed, 17 Jun 2026 21:51:02 +0200 Subject: [PATCH 13/31] Remove hayagriva-util --- Cargo.lock | 7 +------ Cargo.toml | 1 - crates/hayagriva-archive/Cargo.toml | 2 +- crates/hayagriva-core/src/lib.rs | 1 + .../src/test_util.rs | 0 crates/hayagriva-util/Cargo.toml | 11 ----------- crates/hayagriva-util/src/lib.rs | 1 - crates/tests/Cargo.toml | 1 - crates/tests/tests/citeproc.rs | 2 +- 9 files changed, 4 insertions(+), 22 deletions(-) rename crates/{hayagriva-util => hayagriva-core}/src/test_util.rs (100%) delete mode 100644 crates/hayagriva-util/Cargo.toml delete mode 100644 crates/hayagriva-util/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 5c3eae06..dbd7ff97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,7 +208,7 @@ version = "0.10.1" dependencies = [ "ciborium", "citationberg", - "hayagriva-util", + "hayagriva-core", "heck", "serde", ] @@ -286,10 +286,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hayagriva-util" -version = "0.10.1" - [[package]] name = "heck" version = "0.5.0" @@ -757,7 +753,6 @@ dependencies = [ "hayagriva-csl", "hayagriva-format", "hayagriva-json", - "hayagriva-util", "regex", "serde_json", "unscanny", diff --git a/Cargo.toml b/Cargo.toml index 18cd60dc..48003a13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ members = [ "crates/hayagriva-csl", "crates/hayagriva-format", "crates/hayagriva-json", - "crates/hayagriva-util", "crates/tests", ] resolver = "2" diff --git a/crates/hayagriva-archive/Cargo.toml b/crates/hayagriva-archive/Cargo.toml index 2e9a6de2..4262a62f 100644 --- a/crates/hayagriva-archive/Cargo.toml +++ b/crates/hayagriva-archive/Cargo.toml @@ -12,7 +12,7 @@ keywords.workspace = true [dependencies] citationberg = { workspace = true } serde = { workspace = true } -hayagriva-util = { path = "../hayagriva-util" } +hayagriva-core = { path = "../hayagriva-core" } ciborium = { workspace = true } [dev-dependencies] diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs index e387ac2a..af21ad02 100644 --- a/crates/hayagriva-core/src/lib.rs +++ b/crates/hayagriva-core/src/lib.rs @@ -1,4 +1,5 @@ pub mod lang; +pub mod test_util; pub mod types; pub mod util; diff --git a/crates/hayagriva-util/src/test_util.rs b/crates/hayagriva-core/src/test_util.rs similarity index 100% rename from crates/hayagriva-util/src/test_util.rs rename to crates/hayagriva-core/src/test_util.rs diff --git a/crates/hayagriva-util/Cargo.toml b/crates/hayagriva-util/Cargo.toml deleted file mode 100644 index 25ffc24e..00000000 --- a/crates/hayagriva-util/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "hayagriva-util" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -readme.workspace = true -keywords.workspace = true - -[dependencies] diff --git a/crates/hayagriva-util/src/lib.rs b/crates/hayagriva-util/src/lib.rs deleted file mode 100644 index 1528db7d..00000000 --- a/crates/hayagriva-util/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod test_util; diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 7b7a064b..9e13a131 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -16,7 +16,6 @@ hayagriva-core = { path = "../hayagriva-core" } hayagriva-csl = { path = "../hayagriva-csl" } hayagriva-format = { path = "../hayagriva-format", features = ["biblatex"] } hayagriva-json = { path = "../hayagriva-json" } -hayagriva-util = { path = "../hayagriva-util" } serde_json = "1" regex = "1" unscanny = { workspace = true } diff --git a/crates/tests/tests/citeproc.rs b/crates/tests/tests/citeproc.rs index 2d1869e9..85b32f6a 100644 --- a/crates/tests/tests/citeproc.rs +++ b/crates/tests/tests/citeproc.rs @@ -8,7 +8,7 @@ use std::{fmt, fs}; use citationberg::taxonomy::Locator; use citationberg::{Locale, LocaleCode, Style, XmlDeError}; -use hayagriva_util::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; +use hayagriva_core::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; use citationberg::json as csl_json; use hayagriva_archive::{ArchivedStyle, locales}; From 3868159ad188be4aaf9963bfa0039ee79a644edd Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Wed, 17 Jun 2026 21:53:13 +0200 Subject: [PATCH 14/31] Fix import --- crates/hayagriva-archive/tests/archiver.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index 68bb6bc2..d7021bce 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -27,8 +27,7 @@ use std::{ iter::{self, FromIterator}, }; -extern crate hayagriva_util; -use hayagriva_util::test_util::{ +use hayagriva_core::test_util::{ CACHE_PATH, ensure_repo, iter_files, iter_files_with_name, }; From 5b6d1a6edbc71a8795d3c91b6ddd4a42f4faf607 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Wed, 24 Jun 2026 21:29:41 +0200 Subject: [PATCH 15/31] Doc changes --- Cargo.lock | 1 + crates/hayagriva-archive/src/lib.rs | 2 +- crates/hayagriva-archive/tests/archiver.rs | 2 +- crates/hayagriva-cli/Cargo.toml | 4 + crates/hayagriva-cli/src/main.rs | 107 +-------------------- crates/hayagriva-csl/Cargo.toml | 3 + crates/hayagriva-csl/src/lib.rs | 63 ++++++++++++ crates/hayagriva-format/src/interop.rs | 3 + crates/hayagriva-format/src/lib.rs | 64 +++++++++++- crates/hayagriva-json/src/lib.rs | 5 + 10 files changed, 144 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dbd7ff97..47aa45e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,6 +251,7 @@ version = "0.10.1" dependencies = [ "citationberg", "hayagriva-core", + "hayagriva-format", "icu_collator", "icu_locale", "indexmap", diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index 97998f49..975ebdd3 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -1,4 +1,4 @@ -//! Optional archive of included CSL styles. +//! Archive CSL styles. Included in Typst // This file is generated by tests/archiver.rs // Do not edit by hand! diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index d7021bce..6c6d4aa5 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -257,7 +257,7 @@ fn write_styles_section( w: &mut String, items: &[(Vec, IndependentStyle, Vec, String)], ) -> fmt::Result { - writeln!(w, "//! Optional archive of included CSL styles.")?; + writeln!(w, "//! Archive CSL styles. Included in Typst")?; writeln!(w, "// This file is generated by tests/archiver.rs")?; writeln!(w, "// Do not edit by hand!")?; writeln!(w)?; diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index 8c8424af..95a7310c 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -23,3 +23,7 @@ biblatex = { workspace = true, optional = true } [features] default = ["biblatex"] biblatex = ["hayagriva-format/biblatex", "dep:biblatex"] + +[[bin]] +name = "hayagriva" +path = "src/main.rs" diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 05ca9dd4..03172700 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -16,73 +16,8 @@ Hayagriva supports all styles provided in the currently over 2,600. You can provide your own style files or use the ones bundled with this library in the [`hayagriva_archive`] crate. -# Usage - -```rust -use hayagriva::io::from_yaml_str; - -let yaml = r#" -crazy-rich: - type: Book - title: Crazy Rich Asians - author: Kwan, Kevin - date: 2014 - publisher: Anchor Books - location: New York, NY, US -"#; - -// Parse a bibliography -let bib = from_yaml_str(yaml).unwrap(); -assert_eq!(bib.get("crazy-rich").unwrap().date().unwrap().year, 2014); - -// Format the reference -use std::fs; -use hayagriva::{ - BibliographyDriver, BibliographyRequest, BufWriteFormat, - CitationItem, CitationRequest, -}; -use hayagriva::citationberg::{LocaleFile, IndependentStyle}; - -let en_locale = fs::read_to_string("tests/data/locales-en-US.xml").unwrap(); -let locales = [LocaleFile::from_xml(&en_locale).unwrap().into()]; - -let style = fs::read_to_string("tests/data/art-history.csl").unwrap(); -let style = IndependentStyle::from_xml(&style).unwrap(); - -let mut driver = BibliographyDriver::new(); - -for entry in bib.iter() { - let items = vec![CitationItem::with_entry(entry)]; - driver.citation(CitationRequest::from_items(items, &style, &locales)); -} - -let result = driver.finish(BibliographyRequest { - style: &style, - locale: None, - locale_files: &locales, -}); - -for cite in result.citations { - println!("{}", cite.citation) -} -``` - -To format entries, you need to wrap them in a [`CitationRequest`]. Each of these -can reference multiple entries in their respective [`CitationItem`]s. -Use these with a [`BibliographyDriver`] to obtain formatted citations and bibliographies. - -If the default features are enabled, Hayagriva supports BibTeX and BibLaTeX -bibliographies. You can use [`io::from_biblatex_str`] to parse such -bibliographies. - -Should you need more manual control, the library's native `Entry` struct -also offers an implementation of the `From<&biblatex::Entry>`-Trait. You will -need to depend on the [biblatex](https://docs.rs/biblatex/latest/biblatex/) -crate to obtain its `Entry`. Therefore, you could also use your BibLaTeX -content like this: - ```ignore -use hayagriva::Entry; +use hayagriva_format::Entry; let converted: Entry = your_biblatex_entry.into(); ``` @@ -93,46 +28,6 @@ default features by writing this in your `Cargo.toml`: [dependencies] hayagriva = { version = "0.9", default-features = false } ``` - -# Selectors - -Hayagriva uses a custom selector language that enables you to filter -bibliographies by type of media. For more information about selectors, refer -to the [selectors.md -file](https://github.com/typst/hayagriva/blob/main/docs/selectors.md). While -you can parse user-defined selectors using the function `Selector::parse`, -you may instead want to use the selector macro to avoid the run time cost of -parsing a selector when working with constant selectors. - -```rust -use hayagriva::select; -use hayagriva::io::from_yaml_str; - -let yaml = r#" -quantized-vortex: - type: Article - author: Gross, E. P. - title: Structure of a Quantized Vortex in Boson Systems - date: 1961-05 - page-range: 454-477 - serial-number: - doi: 10.1007/BF02731494 - parent: - issue: 3 - volume: 20 - title: Il Nuovo Cimento -"#; - -let entries = from_yaml_str(yaml).unwrap(); -let journal = select!((Article["date"]) > ("journal":Periodical)); -assert!(journal.matches(entries.nth(0).unwrap())); -``` - -There are two ways to check if a selector matches an entry. -You should use [`Selector::matches`] if you just want to know if an item -matches a selector and [`Selector::apply`] to continue to work with the data from -parents of a matching entry. Keep in mind that the latter function will -return `Some` even if no sub-entry was bound / if the hash map is empty. */ use std::borrow::Cow; diff --git a/crates/hayagriva-csl/Cargo.toml b/crates/hayagriva-csl/Cargo.toml index a9a92505..49a1eb60 100644 --- a/crates/hayagriva-csl/Cargo.toml +++ b/crates/hayagriva-csl/Cargo.toml @@ -16,3 +16,6 @@ icu_collator = "2.2.0" icu_locale = "2.2.0" hayagriva-core = { path = "../hayagriva-core" } unic-langid = { workspace = true } + +[dev-dependencies] +hayagriva-format = { path = "../hayagriva-format" } diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index e8982837..b304f65f 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -1,3 +1,66 @@ +//! Hayagriva CSL rendering +//! +//! # Usage +//! +//! We show a simple example using the Hayagriva format but the usage is similar for CSL-JSON. +//! +//! ```rust +//! use hayagriva_format::io::from_yaml_str; +//! +//! let yaml = r#" +//! crazy-rich: +//! type: Book +//! title: Crazy Rich Asians +//! author: Kwan, Kevin +//! date: 2014 +//! publisher: Anchor Books +//! location: New York, NY, US +//! "#; +//! +//! // Parse a bibliography +//! let bib = from_yaml_str(yaml).unwrap(); +//! assert_eq!(bib.get("crazy-rich").unwrap().date().unwrap().year, 2014); +//! +//! // Format the reference +//! use std::fs; +//! use hayagriva_csl::{ +//! BibliographyDriver, BibliographyRequest, BufWriteFormat, +//! CitationItem, CitationRequest, +//! }; +//! use citationberg::{LocaleFile, IndependentStyle}; +//! +//! let en_locale = fs::read_to_string("../tests/tests/data/locales-en-US.xml").unwrap(); +//! let locales = [LocaleFile::from_xml(&en_locale).unwrap().into()]; +//! +//! let style = fs::read_to_string("../tests/tests/data/art-history.csl").unwrap(); +//! let style = IndependentStyle::from_xml(&style).unwrap(); +//! +//! let mut driver = BibliographyDriver::new(); +//! +//! for entry in bib.iter() { +//! let items = vec![CitationItem::with_entry(entry)]; +//! driver.citation(CitationRequest::from_items(items, &style, &locales)); +//! } +//! +//! let result = driver.finish(BibliographyRequest { +//! style: &style, +//! locale: None, +//! locale_files: &locales, +//! }); +//! +//! for cite in result.citations { +//! println!("{}", cite.citation) +//! } +//! ``` +//! +//! To format entries, you need to wrap them in a [`CitationRequest`]. Each of these +//! can reference multiple entries in their respective [`CitationItem`]s. +//! Use these with a [`BibliographyDriver`] to obtain formatted citations and bibliographies. +//! +//! Hayagriva supports BibTeX and BibLaTeX bibliographies via translation to +//! the Hayagriva format. You can use +//! [`hayagriva_format::io::from_biblatex_str`] to parse such bibliographies. + use std::any::Any; use std::borrow::Cow; use std::cell::RefCell; diff --git a/crates/hayagriva-format/src/interop.rs b/crates/hayagriva-format/src/interop.rs index e5522b59..00dd39d0 100644 --- a/crates/hayagriva-format/src/interop.rs +++ b/crates/hayagriva-format/src/interop.rs @@ -1,4 +1,7 @@ //! Provides conversion methods for BibLaTeX. +//! +//! Should you need more manual control of the conversion from Bib(la)TeX to +//! Hayagriva, use the conversion functions in this module. use std::convert::TryFrom; diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 7eee0009..a4e8fc0b 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -1,4 +1,64 @@ -//! The Hayagriva format +//! The Hayagriva YAML-backed format. +//! +//! # Usage +//! +//! ```rust +//! use hayagriva_format::io::from_yaml_str; +//! +//! let yaml = r#" +//! crazy-rich: +//! type: Book +//! title: Crazy Rich Asians +//! author: Kwan, Kevin +//! date: 2014 +//! publisher: Anchor Books +//! location: New York, NY, US +//! "#; +//! +//! // Parse a bibliography +//! let bib = from_yaml_str(yaml).unwrap(); +//! assert_eq!(bib.get("crazy-rich").unwrap().date().unwrap().year, 2014); +//! ``` +//! +//! # Selectors +//! +//! Hayagriva uses a custom selector language that enables you to filter +//! bibliographies by type of media. For more information about selectors, refer +//! to the [selectors.md +//! file](https://github.com/typst/hayagriva/blob/main/docs/selectors.md). While +//! you can parse user-defined selectors using the function `Selector::parse`, +//! you may instead want to use the selector macro to avoid the run time cost of +//! parsing a selector when working with constant selectors. +//! +//! ```rust +//! use hayagriva_format::select; +//! use hayagriva_format::io::from_yaml_str; +//! +//! let yaml = r#" +//! quantized-vortex: +//! type: Article +//! author: Gross, E. P. +//! title: Structure of a Quantized Vortex in Boson Systems +//! date: 1961-05 +//! page-range: 454-477 +//! serial-number: +//! doi: 10.1007/BF02731494 +//! parent: +//! issue: 3 +//! volume: 20 +//! title: Il Nuovo Cimento +//! "#; +//! +//! let entries = from_yaml_str(yaml).unwrap(); +//! let journal = select!((Article["date"]) > ("journal":Periodical)); +//! assert!(journal.matches(entries.nth(0).unwrap())); +//! ``` +//! +//! There are two ways to check if a selector matches an entry. +//! You should use [`Selector::matches`] if you just want to know if an item +//! matches a selector and [`Selector::apply`] to continue to work with the data from +//! parents of a matching entry. Keep in mind that the latter function will +//! return `Some` even if no sub-entry was bound / if the hash map is empty. #![warn(missing_docs)] #![allow(clippy::comparison_chain)] @@ -8,7 +68,7 @@ mod selectors; pub mod citation_label; #[cfg(feature = "biblatex")] -mod interop; +pub mod interop; pub mod io; pub mod taxonomy; diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-json/src/lib.rs index 24ed73ce..3d138fa5 100644 --- a/crates/hayagriva-json/src/lib.rs +++ b/crates/hayagriva-json/src/lib.rs @@ -1,3 +1,8 @@ +//! Hayagriva CSL-JSON handling. +//! +//! This crate contains a wrapper around [citationberg]'s [csl_json::Item] and +//! handles the resolution of CSL variables from [Item]. + use std::{borrow::Cow, str::FromStr}; use citationberg::{ From 43bbe042596c208d5d59f93b7e9e29dff9f973ba Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Sun, 28 Jun 2026 13:36:20 +0200 Subject: [PATCH 16/31] Remove broken doc link --- crates/hayagriva-csl/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index b304f65f..954ac3d6 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -56,10 +56,6 @@ //! To format entries, you need to wrap them in a [`CitationRequest`]. Each of these //! can reference multiple entries in their respective [`CitationItem`]s. //! Use these with a [`BibliographyDriver`] to obtain formatted citations and bibliographies. -//! -//! Hayagriva supports BibTeX and BibLaTeX bibliographies via translation to -//! the Hayagriva format. You can use -//! [`hayagriva_format::io::from_biblatex_str`] to parse such bibliographies. use std::any::Any; use std::borrow::Cow; From 2ded97e4fd3dd042a13f66cd5535f114bb0a2ee5 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 21 Jul 2026 20:48:06 +0200 Subject: [PATCH 17/31] Update locale --- archive/locales/it-IT.cbor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive/locales/it-IT.cbor b/archive/locales/it-IT.cbor index 9da24090..0cdafeb8 100644 --- a/archive/locales/it-IT.cbor +++ b/archive/locales/it-IT.cbor @@ -1 +1 @@ -i@xml:langeit-ITdinfojtranslatordnameoFilippo Vomieroeemailxfilippo.vomiero@unipd.itfrightse$textxQThis work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Licenseh@licensex.http://creativecommons.org/licenses/by-sa/3.0/gupdatede$textx2026-01-10T00:00:00+00:00etermsdtermce@namehaccessede$textjconsultatoe@formdlonge@namexadvance-online-publicatione$textx*pubblicazione online ad accesso anticipatoe@formdlonge@nameealbume$textealbume@formdlonge@namecande$textaee@formdlonge@namejand-otherse$textge altrie@formdlonge@nameianonymouse$textganonimoe@formdlonge@namebate$textaae@formdlonge@nameoaudio-recordinge$textsregistrazione audioe@formdlonge@namelavailable ate$textndisponibile sue@formdlonge@namebbye$textbdie@formdlonge@nameecircae$textecircae@formdlonge@nameecitede$textfcitatoe@formdlonge@nameeet-ale$textfet al.e@formdlonge@namedfilme$textdfilme@formdlonge@namekforthcominge$textxin corso di pubblicazionee@formdlonge@namedfrome$textbdae@formdlonge@namejhenceforthe$textld'ora in poie@formdlonge@namedibide$textfibideme@formdlonge@namebine$textbine@formdlonge@namehin presse$textiin stampae@formdlonge@namehinternete$texthinternete@formdlonge@nameflettere$textgletterae@formdlonge@namegloc-cite$textiloc. cit.e@formdlonge@namegno datee$textisine datae@formdlonge@namehno-placee$textisine locoe@formdlonge@namelno-publishere$textksine nominee@formdlonge@namebone$textbsue@formdlonge@namefonlinee$textfonlinee@formdlonge@namefop-cite$texthop. cit.e@formdlonge@nameworiginal-work-publishede$textxopera originale pubblicatae@formdlonge@namevpersonal-communicatione$textwcomunicazione personalee@formdlonge@namegpodcaste$textgpodcaste@formdlonge@nameopodcast-episodee$textsepisodio di podcaste@formdlonge@namehpreprinte$texthpreprinte@formdlonge@namelpresented ate$textmpresentato ale@formdlonge@nameoradio-broadcaste$textxtrasmissione radiofonicae@formdlonge@namelradio-seriese$textqserie radiofonicae@formdlonge@nametradio-series-episodee$textxepisodio di serie radiofonicae@formdlonge@nameireferencefsinglekriferimentohmultiplekriferimentie@formdlonge@nameiretrievede$textjrecuperatoe@formdlonge@nameireview-ofe$textireview ofe@formdlonge@nameescalee$textescalae@formdlonge@namemspecial-issuee$textqedizione specialee@formdlonge@nameospecial-sectione$textpsezione specialee@formdlonge@namettelevision-broadcaste$textwtrasmissione televisivae@formdlonge@nameqtelevision-seriese$textpserie televisivae@formdlonge@namextelevision-series-episodee$textxepisodio di serie televisivae@formdlonge@nameevideoe$textevideoe@formdlonge@namemworking-papere$textsdocumento di lavoroe@formdlonge@nameianonymouse$texteanon.e@formeshorte@namelavailable ate$textbsue@formeshorte@nameecircae$textbc.e@formeshorte@namedibide$texteibid.e@formeshorte@namegno datee$textds.d.e@formeshorte@namehno-placee$textds.l.e@formeshorte@namelno-publishere$textds.n.e@formeshorte@nameireferencefsingledrif.hmultipledrif.e@formeshorte@nameireview-ofe$textgrev. ofe@formeshorte@namegarticlee$texthpreprinte@formdlonge@nameoarticle-journale$textsarticolo di rivistae@formdlonge@nameparticle-magazinee$textxarticolo di rivista generalistae@formdlonge@nameqarticle-newspapere$texttarticolo di giornalee@formdlonge@namedbille$textqproposta di leggee@formdlonge@nameibroadcaste$textibroadcaste@formdlonge@namegclassice$texthclassicoe@formdlonge@namejcollectione$textjcollezionee@formdlonge@namegdatasete$textgdatasete@formdlonge@namehdocumente$textidocumentoe@formdlonge@nameeentrye$textdvocee@formdlonge@namepentry-dictionarye$textrvoce di dizionarioe@formdlonge@namerentry-encyclopediae$texttvoce di enciclopediae@formdlonge@nameeevente$textfeventoe@formdlonge@nameggraphice$textlopera d'artee@formdlonge@nameghearinge$textgudienzae@formdlonge@nameiinterviewe$textjintervistae@formdlonge@namejlegal_casee$textecausae@formdlonge@nameklegislatione$textllegislazionee@formdlonge@namejmanuscripte$textkmanoscrittoe@formdlonge@namecmape$textemappae@formdlonge@namenmotion_picturee$textdfilme@formdlonge@namemmusical_scoree$textqspartito musicalee@formdlonge@namehpamphlete$texthopuscoloe@formdlonge@nameppaper-conferencee$textpatto di convegnoe@formdlonge@namefpatente$texthbrevettoe@formdlonge@namekperformancee$textjesecuzionee@formdlonge@namejperiodicale$textiperiodicoe@formdlonge@namevpersonal_communicatione$textwcomunicazione personalee@formdlonge@namedposte$textimessaggioe@formdlonge@namekpost-webloge$textqmessaggio di bloge@formdlonge@namejregulatione$textgdecretoe@formdlonge@namefreporte$textfreporte@formdlonge@namefreviewe$textfreviewe@formdlonge@namekreview-booke$textsrecensione di libroe@formdlonge@namehsoftwaree$texthsoftwaree@formdlonge@namedsonge$textsregistrazione audioe@formdlonge@namefspeeche$textmpresentazionee@formdlonge@namehstandarde$textenormae@formdlonge@namefthesise$textdtesie@formdlonge@nameftreatye$texthtrattatoe@formdlonge@namegwebpagee$textjpagina webe@formdlonge@nameoarticle-journale$textlart. di riv.e@formeshorte@nameparticle-magazinee$textkart. di rive@formeshorte@nameqarticle-newspapere$textjart. di g.e@formeshorte@namehdocumente$textddoc.e@formeshorte@nameggraphice$textjop. d'artee@formeshorte@nameiinterviewe$textginterv.e@formeshorte@namejmanuscripte$textcms.e@formeshorte@namenmotion_picturee$textdfilme@formeshorte@namefreporte$textdrep.e@formeshorte@namefreviewe$textdrev.e@formeshorte@namekreview-booke$textjrec. di l.e@formeshorte@namedsonge$textjreg. audioe@formeshorte@nameghearinge$textltestimony ofe@formdverbe@namefreviewe$textireview ofe@formdverbe@namekreview-booke$textrreview of the booke@formdverbe@namebade$textdd.C.e@formdlonge@namebbce$textda.C.e@formdlonge@namecbcee$textcBCEe@formdlonge@namebcee$textbCEe@formdlonge@namejopen-quotee$textb«e@formdlonge@namekclose-quotee$textb»e@formdlonge@namepopen-inner-quotee$textc“e@formdlonge@nameqclose-inner-quotee$textc”e@formdlonge@nametpage-range-delimitere$textc–e@formdlonge@nameecolone$texta:e@formdlonge@nameecommae$texta,e@formdlonge@nameisemicolone$texta;e@formdlonge@namegordinale$textbºe@formdlonge@namegordinale$textbºe@formdlongl@gender-formimasculinee@namegordinale$textbªe@formdlongl@gender-formhfemininee@nameolong-ordinal-01e$texteprimae@formdlonge@nameolong-ordinal-02e$textgsecondae@formdlonge@nameolong-ordinal-03e$texteterzae@formdlonge@nameolong-ordinal-04e$textfquartae@formdlonge@nameolong-ordinal-05e$textfquintae@formdlonge@nameolong-ordinal-06e$textesestae@formdlonge@nameolong-ordinal-07e$textgsettimae@formdlonge@nameolong-ordinal-08e$textfottavae@formdlonge@nameolong-ordinal-09e$textdnonae@formdlonge@nameolong-ordinal-10e$textfdecimae@formdlonge@nameolong-ordinal-01e$texteprimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-02e$textgsecondoe@formdlongl@gender-formimasculinee@nameolong-ordinal-03e$texteterzoe@formdlongl@gender-formimasculinee@nameolong-ordinal-04e$textfquartoe@formdlongl@gender-formimasculinee@nameolong-ordinal-05e$textfquintoe@formdlongl@gender-formimasculinee@nameolong-ordinal-06e$textesestoe@formdlongl@gender-formimasculinee@nameolong-ordinal-07e$textgsettimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-08e$textfottavoe@formdlongl@gender-formimasculinee@nameolong-ordinal-09e$textdnonoe@formdlongl@gender-formimasculinee@nameolong-ordinal-10e$textfdecimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-01e$texteprimae@formdlongl@gender-formhfemininee@nameolong-ordinal-02e$textgsecondae@formdlongl@gender-formhfemininee@nameolong-ordinal-03e$texteterzae@formdlongl@gender-formhfemininee@nameolong-ordinal-04e$textfquartae@formdlongl@gender-formhfemininee@nameolong-ordinal-05e$textfquintae@formdlongl@gender-formhfemininee@nameolong-ordinal-06e$textesestae@formdlongl@gender-formhfemininee@nameolong-ordinal-07e$textgsettimae@formdlongl@gender-formhfemininee@nameolong-ordinal-08e$textfottavae@formdlongl@gender-formhfemininee@nameolong-ordinal-09e$textdnonae@formdlongl@gender-formhfemininee@nameolong-ordinal-10e$textfdecimae@formdlongl@gender-formhfemininee@namecactfsingledattohmultipledattoe@formdlonge@namehappendixfsingleiappendicehmultipleiappendicie@formdlonge@nameoarticle-locatorfsingleharticolohmultipleharticolie@formdlonge@namedbookfsingleelibrohmultipleelibrie@formdlonge@nameecanonfsinglefcanonehmultiplefcanonie@formdlonge@namegchapterfsinglehcapitolohmultiplehcapitolie@formdlonge@namefcolumnfsinglegcolonnahmultiplegcolonnee@formdlonge@nameielocationfsingleiindirizzohmultipleiindirizzie@formdlonge@namehequationfsingleiequazionehmultipleiequazionie@formdlonge@nameffigurefsingleffigurahmultipleffiguree@formdlonge@nameefoliofsingleffogliohmultipleefoglie@formdlonge@nameeissuefsingleifascicolohmultipleifascicolie@formdlongg@genderimasculinee@namedlinefsingledrigahmultipleerighee@formdlonge@namednotefsinglednotahmultiplednotee@formdlonge@namedopusfsingleeoperahmultipleeoperee@formdlonge@namedpagefsinglefpaginahmultiplefpaginee@formdlonge@nameiparagraphfsingleiparagrafohmultipleiparagrafie@formdlonge@namedpartfsingleepartehmultipleepartie@formdlonge@namedrulefsinglefregolahmultiplefregolee@formdlonge@nameescenefsingleescenahmultipleescenee@formdlonge@namegsectionfsinglegsezionehmultiplegsezionie@formdlonge@nameisub verbofsingleisub verbohmultiplejsub verbise@formdlonge@namejsupplementfsinglejsupplementhmultipleksupplementse@formdlonge@nameetablefsingleftavolahmultipleftavolee@formdlonge@nameitimestampfsingle`hmultiple`e@formdlonge@namemtitle-locatorfsingleftitolohmultipleftitolie@formdlonge@nameeversefsingleeversohmultipleeversie@formdlonge@namefvolumefsinglefvolumehmultiplefvolumie@formdlongg@genderimasculinee@namehappendixfsingledapp.hmultipledapp.e@formeshorte@nameoarticle-locatorfsingledart.hmultipledart.e@formeshorte@namedbooke$textdlib.e@formeshorte@namegchapterfsingledcap.hmultipleecapp.e@formeshorte@namefcolumne$textdcol.e@formeshorte@nameielocationfsingledloc.hmultipleelocs.e@formeshorte@namehequationfsingleceq.hmultipleceq.e@formeshorte@nameffiguree$textdfig.e@formeshorte@nameefolioe$textdfgl.e@formeshorte@nameeissuee$textefasc.e@formeshorte@namedlinee$textbr.e@formeshorte@namednotee$textbn.e@formeshorte@namedopuse$textcop.e@formeshorte@namedpagefsinglebp.hmultiplecpp.e@formeshorte@nameiparagraphe$textdpar.e@formeshorte@namedparte$textcpt.e@formeshorte@namedrulefsinglebr.hmultiplebr.e@formeshorte@nameescenefsinglecsc.hmultiplecsc.e@formeshorte@namegsectione$textdsez.e@formeshorte@nameisub verbofsingleds.v.hmultiplees.vv.e@formeshorte@namejsupplementfsingleesupp.hmultiplefsupps.e@formeshorte@nameetablefsingledtab.hmultipledtab.e@formeshorte@nameitimestampfsingle`hmultiple`e@formeshorte@namemtitle-locatorfsingledtit.hmultipleetits.e@formeshorte@nameeversefsinglebv.hmultiplecvv.e@formeshorte@namefvolumefsingledvol.hmultipleevoll.e@formeshorte@nameiparagraphfsingleb¶hmultipled¶¶e@formfsymbole@namegsectionfsingleb§hmultipled§§e@formfsymbole@namenchapter-numberfsinglegchapterhmultiplehchapterse@formdlonge@nameocitation-numberfsinglehcitationhmultipleicitationse@formdlonge@nameqcollection-numberfsingleifascicolohmultipleifascicolie@formdlongg@genderimasculinee@namegeditionfsinglehedizionehmultiplehedizionie@formdlongg@genderhfemininee@namexfirst-reference-note-numberfsinglednotahmultiplednotee@formdlonge@namefnumberfsinglefnumberhmultiplegnumberse@formdlonge@nameonumber-of-pagesfsinglefpaginahmultiplefpaginee@formdlonge@nameqnumber-of-volumesfsinglefvolumehmultiplegvolumese@formdlonge@namejpage-firstfsingledpagehmultipleepagese@formdlonge@nameoprinting-numberfsinglehprintinghmultipleiprintingse@formdlonge@namegversione$texthversionee@formdlonge@namenchapter-numberfsingleechap.hmultiplefchaps.e@formeshorte@nameocitation-numberfsingledcit.hmultipleecits.e@formeshorte@nameqcollection-numbere$textefasc.e@formeshorte@namegeditione$textced.e@formeshorte@namexfirst-reference-note-numbere$textbn.e@formeshorte@namefnumberfsinglecno.hmultiplednos.e@formeshorte@nameonumber-of-pagesfsinglebp.hmultiplecpp.e@formeshorte@nameqnumber-of-volumesfsingledvol.hmultipleevols.e@formeshorte@namejpage-firstfsinglebp.hmultiplecpp.e@formeshorte@nameoprinting-numberfsinglefprint.hmultiplegprints.e@formeshorte@namefauthore@formdlonge@nameechairfsinglejpresidentehmultiplejpresidentie@formdlonge@nameqcollection-editorfsingleced.hmultiplededs.e@formdlonge@namehcompilerfsinglekcompilatorehmultiplekcompilatorie@formdlonge@namehcomposere@formdlonge@namepcontainer-authore@formdlonge@namekcontributorfsinglemcollaboratorehmultiplemcollaboratorie@formdlonge@namegcuratorfsinglehcuratorehmultiplehcuratorie@formdlonge@namehdirectorfsinglegregistahmultiplegregistie@formdlonge@namefeditorfsinglehcuratorehmultiplehcuratorie@formdlonge@nameqeditor-translatorfsingleucuratore e traduttorehmultipletcuratori e tradutorie@formdlonge@nameqeditor-translatorfsingleucuratore e traduttorehmultipletcuratori e tradutorie@formdlonge@namereditorial-directorfsingletdirettore editorialehmultipletdirettori editorialie@formdlonge@namerexecutive-producerfsingletproduttore esecutivohmultipletproduttori esecutivie@formdlonge@nameeguestfsinglefospitehmultiplefospitie@formdlonge@namedhostfsinglejconduttorehmultiplejconduttorie@formdlonge@namekillustratorfsinglelillustratorehmultiplelillustratorie@formdlonge@namekinterviewere@formdlonge@namehnarratorfsingleinarratorehmultipleinarratorie@formdlonge@nameiorganizerfsinglemorganizzatorehmultiplemorganizzatorie@formdlonge@nameooriginal-authore@formdlonge@nameiperformerfsingleiesecutorehmultipleiesecutorie@formdlonge@namehproducerfsinglejproduttorehmultiplejproduttorie@formdlonge@nameirecipiente@formdlonge@nameoreviewed-authore@formdlonge@namemscript-writerfsinglemsceneggiatorehmultiplemsceneggiatorie@formdlonge@namenseries-creatorfsinglerautore della seriehmultiplerautori della seriee@formdlonge@namejtranslatorfsinglejtraduttorehmultiplejtraduttorie@formdlonge@namehcompilerfsingleecomp.hmultipleecomp.e@formeshorte@namekcontributorfsinglegcollab.hmultiplegcollab.e@formeshorte@namegcuratorfsingledcur.hmultipledcur.e@formeshorte@namehdirectorfsingledreg.hmultipledreg.e@formeshorte@namefeditorfsinglega c. dihmultiplega c. die@formeshorte@nameqeditor-translatorfsinglelcur. e trad.hmultiplelcur. e trad.e@formeshorte@nameqeditor-translatorfsinglelcur. e trad.hmultiplelcur. e trad.e@formeshorte@namereditorial-directorfsinglehdir. ed.hmultiplehdir. ed.e@formeshorte@namerexecutive-producerfsinglehprod.es.hmultipleiprod. es.e@formeshorte@namekillustratorfsingledill.hmultipledill.e@formeshorte@namehnarratorfsingleenarr.hmultipleenarr.e@formeshorte@nameiorganizerfsingledorg.hmultipledorg.e@formeshorte@nameiperformerfsingleeesec.hmultipleeesec.e@formeshorte@namehproducerfsingleeprod.hmultipleeprod.e@formeshorte@namemscript-writerfsingleescen.hmultipleescen.e@formeshorte@namenseries-creatorfsinglemaut. d. seriehmultiplemaut. d. seriee@formeshorte@namejtranslatorfsingleetrad.hmultipleetrad.e@formeshorte@nameechaire$textmpresieduto dae@formdverbe@nameqcollection-editore$textiedited bye@formdverbe@namehcompilere$textlcompilato dae@formdverbe@namepcontainer-authore$textbdie@formdverbe@namekcontributore$texttcon un contributo die@formdverbe@namegcuratore$textia cura die@formdverbe@namehdirectore$textjdiretto dae@formdverbe@namefeditore$textia cura die@formdverbe@nameqeditor-translatore$textwa cura di e tradotto dae@formdverbe@nameqeditor-translatore$textwa cura di e tradotto dae@formdverbe@namereditorial-directore$textwdirezione editoriale die@formdverbe@namerexecutive-producere$textwproduzione esecutiva die@formdverbe@nameegueste$textjcon ospitee@formdverbe@namedhoste$textkcondotto dae@formdverbe@namekillustratore$textmillustrato dae@formdverbe@namekinterviewere$textmintervista die@formdverbe@namehnarratore$textjnarrato dae@formdverbe@nameiorganizere$textnorganizzato dae@formdverbe@nameiperformere$textmesecuzione die@formdverbe@namehproducere$textkprodotto dae@formdverbe@nameirecipiente$textaae@formdverbe@nameoreviewed-authore$textbdie@formdverbe@namemscript-writere$textjscritto dae@formdverbe@namenseries-creatore$texticreato dae@formdverbe@namejtranslatore$textktradotto dae@formdverbe@nameqcollection-editore$textfed. bye@formjverb-shorte@namehcompilere$texthcomp. dae@formjverb-shorte@namekcontributore$textrcon un contrib. die@formjverb-shorte@namegcuratore$textga c. die@formjverb-shorte@namehdirectore$textgdir. dae@formjverb-shorte@namefeditore$textga c. die@formjverb-shorte@nameqeditor-translatore$textra c. di e trad. dae@formjverb-shorte@nameqeditor-translatore$textra c. di e trad. dae@formjverb-shorte@namereditorial-directore$textkdir. ed. die@formjverb-shorte@namerexecutive-producere$textnprod. esec. die@formjverb-shorte@nameegueste$texthcon osp.e@formjverb-shorte@namedhoste$texthcond. dae@formjverb-shorte@namekillustratore$textgill. dae@formjverb-shorte@namehnarratore$texthnarr. dae@formjverb-shorte@nameiorganizere$textgorg. dae@formjverb-shorte@nameiperformere$texthesec. die@formjverb-shorte@namehproducere$texthprod. dae@formjverb-shorte@namemscript-writere$textgscr. dae@formjverb-shorte@namenseries-creatore$textgcre. dae@formjverb-shorte@namejtranslatore$texthtrad. dae@formjverb-shorte@namehmonth-01e$textggennaioe@formdlongg@genderimasculinee@namehmonth-02e$texthfebbraioe@formdlongg@genderimasculinee@namehmonth-03e$textemarzoe@formdlongg@genderimasculinee@namehmonth-04e$textfaprilee@formdlongg@genderimasculinee@namehmonth-05e$textfmaggioe@formdlongg@genderimasculinee@namehmonth-06e$textfgiugnoe@formdlongg@genderimasculinee@namehmonth-07e$textfluglioe@formdlongg@genderimasculinee@namehmonth-08e$textfagostoe@formdlongg@genderimasculinee@namehmonth-09e$textisettembree@formdlongg@genderimasculinee@namehmonth-10e$textgottobree@formdlongg@genderimasculinee@namehmonth-11e$texthnovembree@formdlongg@genderimasculinee@namehmonth-12e$texthdicembree@formdlongg@genderimasculinee@namehmonth-01e$textdgen.e@formeshorte@namehmonth-02e$textdfeb.e@formeshorte@namehmonth-03e$textdmar.e@formeshorte@namehmonth-04e$textdapr.e@formeshorte@namehmonth-05e$textdmag.e@formeshorte@namehmonth-06e$textdgiu.e@formeshorte@namehmonth-07e$textdlug.e@formeshorte@namehmonth-08e$textdago.e@formeshorte@namehmonth-09e$textdset.e@formeshorte@namehmonth-10e$textdott.e@formeshorte@namehmonth-11e$textdnov.e@formeshorte@namehmonth-12e$textddic.e@formeshorte@nameiseason-01e$textiprimaverae@formdlonge@nameiseason-02e$textfestatee@formdlonge@nameiseason-03e$textgautunnoe@formdlonge@nameiseason-04e$textginvernoe@formdlongddatee@formdtextidate-parte@namecdayg@suffixa n@strip-periodse@nameemonthg@suffixa n@strip-periodse@namedyearn@strip-periodse@formgnumericidate-parte@namecdaye@formunumeric-leading-zerosg@suffixa/n@strip-periodse@nameemonthe@formunumeric-leading-zerosg@suffixa/n@strip-periodse@namedyearn@strip-periodsmstyle-optionsu@punctuation-in-quote \ No newline at end of file +i@xml:langeit-ITdinfojtranslatordnameoFilippo Vomieroeemailxfilippo.vomiero@unipd.itfrightse$textxQThis work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Licenseh@licensex.http://creativecommons.org/licenses/by-sa/3.0/gupdatede$textx2026-06-30T00:00:00+00:00etermsdtermce@namehaccessede$textjconsultatoe@formdlonge@namexadvance-online-publicatione$textx*pubblicazione online ad accesso anticipatoe@formdlonge@nameealbume$textealbume@formdlonge@namecande$textaee@formdlonge@namejand-otherse$textge altrie@formdlonge@nameianonymouse$textganonimoe@formdlonge@namebate$textaae@formdlonge@nameoaudio-recordinge$textsregistrazione audioe@formdlonge@namelavailable ate$textndisponibile sue@formdlonge@namebbye$textbdie@formdlonge@nameecircae$textecircae@formdlonge@nameecitede$textfcitatoe@formdlonge@nameeet-ale$textfet al.e@formdlonge@namedfilme$textdfilme@formdlonge@namekforthcominge$textxin corso di pubblicazionee@formdlonge@namedfrome$textbdae@formdlonge@namejhenceforthe$textld'ora in poie@formdlonge@namedibide$textfibideme@formdlonge@namebine$textbine@formdlonge@namehin presse$textiin stampae@formdlonge@namehinternete$texthinternete@formdlonge@nameflettere$textgletterae@formdlonge@namegloc-cite$textiloc. cit.e@formdlonge@namegno datee$textisine datae@formdlonge@namehno-placee$textisine locoe@formdlonge@namelno-publishere$textksine nominee@formdlonge@namebone$textbsue@formdlonge@namefonlinee$textfonlinee@formdlonge@namefop-cite$texthop. cit.e@formdlonge@nameworiginal-work-publishede$textxopera originale pubblicatae@formdlonge@namevpersonal-communicatione$textwcomunicazione personalee@formdlonge@namegpodcaste$textgpodcaste@formdlonge@nameopodcast-episodee$textsepisodio di podcaste@formdlonge@namehpreprinte$texthpreprinte@formdlonge@namelpresented ate$textmpresentato ale@formdlonge@nameoradio-broadcaste$textxtrasmissione radiofonicae@formdlonge@namelradio-seriese$textqserie radiofonicae@formdlonge@nametradio-series-episodee$textxepisodio di serie radiofonicae@formdlonge@nameireferencefsinglekriferimentohmultiplekriferimentie@formdlonge@nameiretrievede$textjrecuperatoe@formdlonge@nameireview-ofe$textireview ofe@formdlonge@nameescalee$textescalae@formdlonge@namemspecial-issuee$textqedizione specialee@formdlonge@nameospecial-sectione$textpsezione specialee@formdlonge@namettelevision-broadcaste$textwtrasmissione televisivae@formdlonge@nameqtelevision-seriese$textpserie televisivae@formdlonge@namextelevision-series-episodee$textxepisodio di serie televisivae@formdlonge@nameevideoe$textevideoe@formdlonge@namemworking-papere$textsdocumento di lavoroe@formdlonge@nameianonymouse$texteanon.e@formeshorte@namelavailable ate$textbsue@formeshorte@nameecircae$textbc.e@formeshorte@namedibide$texteibid.e@formeshorte@namegno datee$textds.d.e@formeshorte@namehno-placee$textds.l.e@formeshorte@namelno-publishere$textds.n.e@formeshorte@nameireferencefsingledrif.hmultipledrif.e@formeshorte@nameireview-ofe$textgrev. ofe@formeshorte@namegarticlee$texthpreprinte@formdlonge@nameoarticle-journale$textsarticolo di rivistae@formdlonge@nameparticle-magazinee$textxarticolo di rivista generalistae@formdlonge@nameqarticle-newspapere$texttarticolo di giornalee@formdlonge@namedbille$textqproposta di leggee@formdlonge@nameibroadcaste$textibroadcaste@formdlonge@namegclassice$texthclassicoe@formdlonge@namejcollectione$textjcollezionee@formdlonge@namegdatasete$textgdatasete@formdlonge@namehdocumente$textidocumentoe@formdlonge@nameeentrye$textdvocee@formdlonge@namepentry-dictionarye$textrvoce di dizionarioe@formdlonge@namerentry-encyclopediae$texttvoce di enciclopediae@formdlonge@nameeevente$textfeventoe@formdlonge@nameggraphice$textlopera d'artee@formdlonge@nameghearinge$textgudienzae@formdlonge@nameiinterviewe$textjintervistae@formdlonge@namejlegal_casee$textecausae@formdlonge@nameklegislatione$textllegislazionee@formdlonge@namejmanuscripte$textkmanoscrittoe@formdlonge@namecmape$textemappae@formdlonge@namenmotion_picturee$textdfilme@formdlonge@namemmusical_scoree$textqspartito musicalee@formdlonge@namehpamphlete$texthopuscoloe@formdlonge@nameppaper-conferencee$textpatto di convegnoe@formdlonge@namefpatente$texthbrevettoe@formdlonge@namekperformancee$textjesecuzionee@formdlonge@namejperiodicale$textiperiodicoe@formdlonge@namevpersonal_communicatione$textwcomunicazione personalee@formdlonge@namedposte$textimessaggioe@formdlonge@namekpost-webloge$textqmessaggio di bloge@formdlonge@namejregulatione$textgdecretoe@formdlonge@namefreporte$textfreporte@formdlonge@namefreviewe$textfreviewe@formdlonge@namekreview-booke$textsrecensione di libroe@formdlonge@namehsoftwaree$texthsoftwaree@formdlonge@namedsonge$textsregistrazione audioe@formdlonge@namefspeeche$textmpresentazionee@formdlonge@namehstandarde$textenormae@formdlonge@namefthesise$textdtesie@formdlonge@nameftreatye$texthtrattatoe@formdlonge@namegwebpagee$textjpagina webe@formdlonge@nameoarticle-journale$textlart. di riv.e@formeshorte@nameparticle-magazinee$textkart. di rive@formeshorte@nameqarticle-newspapere$textjart. di g.e@formeshorte@namehdocumente$textddoc.e@formeshorte@nameggraphice$textjop. d'artee@formeshorte@nameiinterviewe$textginterv.e@formeshorte@namejmanuscripte$textcms.e@formeshorte@namenmotion_picturee$textdfilme@formeshorte@namefreporte$textdrep.e@formeshorte@namefreviewe$textdrev.e@formeshorte@namekreview-booke$textjrec. di l.e@formeshorte@namedsonge$textjreg. audioe@formeshorte@nameghearinge$textltestimony ofe@formdverbe@namefreviewe$textireview ofe@formdverbe@namekreview-booke$textrreview of the booke@formdverbe@namebade$textdd.C.e@formdlonge@namebbce$textda.C.e@formdlonge@namecbcee$textcBCEe@formdlonge@namebcee$textbCEe@formdlonge@namejopen-quotee$textb«e@formdlonge@namekclose-quotee$textb»e@formdlonge@namepopen-inner-quotee$textc“e@formdlonge@nameqclose-inner-quotee$textc”e@formdlonge@nametpage-range-delimitere$textc–e@formdlonge@nameecolone$texta:e@formdlonge@nameecommae$texta,e@formdlonge@nameisemicolone$texta;e@formdlonge@namegordinale$textbºe@formdlonge@namegordinale$textbºe@formdlongl@gender-formimasculinee@namegordinale$textbªe@formdlongl@gender-formhfemininee@nameolong-ordinal-01e$texteprimae@formdlonge@nameolong-ordinal-02e$textgsecondae@formdlonge@nameolong-ordinal-03e$texteterzae@formdlonge@nameolong-ordinal-04e$textfquartae@formdlonge@nameolong-ordinal-05e$textfquintae@formdlonge@nameolong-ordinal-06e$textesestae@formdlonge@nameolong-ordinal-07e$textgsettimae@formdlonge@nameolong-ordinal-08e$textfottavae@formdlonge@nameolong-ordinal-09e$textdnonae@formdlonge@nameolong-ordinal-10e$textfdecimae@formdlonge@nameolong-ordinal-01e$texteprimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-02e$textgsecondoe@formdlongl@gender-formimasculinee@nameolong-ordinal-03e$texteterzoe@formdlongl@gender-formimasculinee@nameolong-ordinal-04e$textfquartoe@formdlongl@gender-formimasculinee@nameolong-ordinal-05e$textfquintoe@formdlongl@gender-formimasculinee@nameolong-ordinal-06e$textesestoe@formdlongl@gender-formimasculinee@nameolong-ordinal-07e$textgsettimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-08e$textfottavoe@formdlongl@gender-formimasculinee@nameolong-ordinal-09e$textdnonoe@formdlongl@gender-formimasculinee@nameolong-ordinal-10e$textfdecimoe@formdlongl@gender-formimasculinee@nameolong-ordinal-01e$texteprimae@formdlongl@gender-formhfemininee@nameolong-ordinal-02e$textgsecondae@formdlongl@gender-formhfemininee@nameolong-ordinal-03e$texteterzae@formdlongl@gender-formhfemininee@nameolong-ordinal-04e$textfquartae@formdlongl@gender-formhfemininee@nameolong-ordinal-05e$textfquintae@formdlongl@gender-formhfemininee@nameolong-ordinal-06e$textesestae@formdlongl@gender-formhfemininee@nameolong-ordinal-07e$textgsettimae@formdlongl@gender-formhfemininee@nameolong-ordinal-08e$textfottavae@formdlongl@gender-formhfemininee@nameolong-ordinal-09e$textdnonae@formdlongl@gender-formhfemininee@nameolong-ordinal-10e$textfdecimae@formdlongl@gender-formhfemininee@namecactfsingledattohmultipledattoe@formdlonge@namehappendixfsingleiappendicehmultipleiappendicie@formdlonge@nameoarticle-locatorfsingleharticolohmultipleharticolie@formdlonge@namedbookfsingleelibrohmultipleelibrie@formdlonge@nameecanonfsinglefcanonehmultiplefcanonie@formdlonge@namegchapterfsinglehcapitolohmultiplehcapitolie@formdlonge@namefcolumnfsinglegcolonnahmultiplegcolonnee@formdlonge@nameielocationfsingleiindirizzohmultipleiindirizzie@formdlonge@namehequationfsingleiequazionehmultipleiequazionie@formdlonge@nameffigurefsingleffigurahmultipleffiguree@formdlonge@nameefoliofsingleffogliohmultipleefoglie@formdlonge@nameeissuefsingleifascicolohmultipleifascicolie@formdlongg@genderimasculinee@namedlinefsingledrigahmultipleerighee@formdlonge@namednotefsinglednotahmultiplednotee@formdlonge@namedopusfsingleeoperahmultipleeoperee@formdlonge@namedpagefsinglefpaginahmultiplefpaginee@formdlonge@nameiparagraphfsingleiparagrafohmultipleiparagrafie@formdlonge@namedpartfsingleepartehmultipleepartie@formdlonge@namedrulefsinglefregolahmultiplefregolee@formdlonge@nameescenefsingleescenahmultipleescenee@formdlonge@namegsectionfsinglegsezionehmultiplegsezionie@formdlonge@nameisub verbofsingleisub verbohmultiplejsub verbise@formdlonge@namejsupplementfsinglejsupplementhmultipleksupplementse@formdlonge@nameetablefsingleftavolahmultipleftavolee@formdlonge@nameitimestampfsingle`hmultiple`e@formdlonge@namemtitle-locatorfsingleftitolohmultipleftitolie@formdlonge@nameeversefsingleeversohmultipleeversie@formdlonge@namefvolumefsinglefvolumehmultiplefvolumie@formdlongg@genderimasculinee@namehappendixfsingledapp.hmultipledapp.e@formeshorte@nameoarticle-locatorfsingledart.hmultipledart.e@formeshorte@namedbooke$textdlib.e@formeshorte@namegchapterfsingledcap.hmultipleecapp.e@formeshorte@namefcolumne$textdcol.e@formeshorte@nameielocationfsingledloc.hmultipleelocs.e@formeshorte@namehequationfsingleceq.hmultipleceq.e@formeshorte@nameffiguree$textdfig.e@formeshorte@nameefolioe$textdfgl.e@formeshorte@nameeissuee$textefasc.e@formeshorte@namedlinee$textbr.e@formeshorte@namednotee$textbn.e@formeshorte@namedopuse$textcop.e@formeshorte@namedpagefsinglebp.hmultiplecpp.e@formeshorte@nameiparagraphe$textdpar.e@formeshorte@namedparte$textcpt.e@formeshorte@namedrulefsinglebr.hmultiplebr.e@formeshorte@nameescenefsinglecsc.hmultiplecsc.e@formeshorte@namegsectione$textdsez.e@formeshorte@nameisub verbofsingleds.v.hmultiplees.vv.e@formeshorte@namejsupplementfsingleesupp.hmultiplefsupps.e@formeshorte@nameetablefsingledtab.hmultipledtab.e@formeshorte@nameitimestampfsingle`hmultiple`e@formeshorte@namemtitle-locatorfsingledtit.hmultipleetits.e@formeshorte@nameeversefsinglebv.hmultiplecvv.e@formeshorte@namefvolumefsingledvol.hmultipleevoll.e@formeshorte@nameiparagraphfsingleb¶hmultipled¶¶e@formfsymbole@namegsectionfsingleb§hmultipled§§e@formfsymbole@namenchapter-numberfsinglegchapterhmultiplehchapterse@formdlonge@nameocitation-numberfsinglehcitationhmultipleicitationse@formdlonge@nameqcollection-numberfsingleifascicolohmultipleifascicolie@formdlongg@genderimasculinee@namegeditionfsinglehedizionehmultiplehedizionie@formdlongg@genderhfemininee@namexfirst-reference-note-numberfsinglednotahmultiplednotee@formdlonge@namefnumberfsinglefnumberhmultiplegnumberse@formdlonge@nameonumber-of-pagesfsinglefpaginahmultiplefpaginee@formdlonge@nameqnumber-of-volumesfsinglefvolumehmultiplegvolumese@formdlonge@namejpage-firstfsingledpagehmultipleepagese@formdlonge@nameoprinting-numberfsinglehprintinghmultipleiprintingse@formdlonge@namegversione$texthversionee@formdlonge@namenchapter-numberfsingleechap.hmultiplefchaps.e@formeshorte@nameocitation-numberfsingledcit.hmultipleecits.e@formeshorte@nameqcollection-numbere$textefasc.e@formeshorte@namegeditione$textced.e@formeshorte@namexfirst-reference-note-numbere$textbn.e@formeshorte@namefnumberfsinglecno.hmultiplednos.e@formeshorte@nameonumber-of-pagesfsinglebp.hmultiplecpp.e@formeshorte@nameqnumber-of-volumesfsingledvol.hmultipleevoll.e@formeshorte@namejpage-firstfsinglebp.hmultiplecpp.e@formeshorte@nameoprinting-numberfsinglefprint.hmultiplegprints.e@formeshorte@namefauthore@formdlonge@nameechairfsinglejpresidentehmultiplejpresidentie@formdlonge@nameqcollection-editorfsingleced.hmultiplededs.e@formdlonge@namehcompilerfsinglekcompilatorehmultiplekcompilatorie@formdlonge@namehcomposere@formdlonge@namepcontainer-authore@formdlonge@namekcontributorfsinglemcollaboratorehmultiplemcollaboratorie@formdlonge@namegcuratorfsinglehcuratorehmultiplehcuratorie@formdlonge@namehdirectorfsinglegregistahmultiplegregistie@formdlonge@namefeditorfsinglehcuratorehmultiplehcuratorie@formdlonge@nameqeditor-translatorfsingleucuratore e traduttorehmultipletcuratori e tradutorie@formdlonge@nameqeditor-translatorfsingleucuratore e traduttorehmultipletcuratori e tradutorie@formdlonge@namereditorial-directorfsingletdirettore editorialehmultipletdirettori editorialie@formdlonge@namerexecutive-producerfsingletproduttore esecutivohmultipletproduttori esecutivie@formdlonge@nameeguestfsinglefospitehmultiplefospitie@formdlonge@namedhostfsinglejconduttorehmultiplejconduttorie@formdlonge@namekillustratorfsinglelillustratorehmultiplelillustratorie@formdlonge@namekinterviewere@formdlonge@namehnarratorfsingleinarratorehmultipleinarratorie@formdlonge@nameiorganizerfsinglemorganizzatorehmultiplemorganizzatorie@formdlonge@nameooriginal-authore@formdlonge@nameiperformerfsingleiesecutorehmultipleiesecutorie@formdlonge@namehproducerfsinglejproduttorehmultiplejproduttorie@formdlonge@nameirecipiente@formdlonge@nameoreviewed-authore@formdlonge@namemscript-writerfsinglemsceneggiatorehmultiplemsceneggiatorie@formdlonge@namenseries-creatorfsinglerautore della seriehmultiplerautori della seriee@formdlonge@namejtranslatorfsinglejtraduttorehmultiplejtraduttorie@formdlonge@namehcompilerfsingleecomp.hmultipleecomp.e@formeshorte@namekcontributorfsinglegcollab.hmultiplegcollab.e@formeshorte@namegcuratorfsingledcur.hmultipledcur.e@formeshorte@namehdirectorfsingledreg.hmultipledreg.e@formeshorte@namefeditorfsinglega c. dihmultiplega c. die@formeshorte@nameqeditor-translatorfsinglelcur. e trad.hmultiplelcur. e trad.e@formeshorte@nameqeditor-translatorfsinglelcur. e trad.hmultiplelcur. e trad.e@formeshorte@namereditorial-directorfsinglehdir. ed.hmultiplehdir. ed.e@formeshorte@namerexecutive-producerfsinglehprod.es.hmultipleiprod. es.e@formeshorte@namekillustratorfsingledill.hmultipledill.e@formeshorte@namehnarratorfsingleenarr.hmultipleenarr.e@formeshorte@nameiorganizerfsingledorg.hmultipledorg.e@formeshorte@nameiperformerfsingleeesec.hmultipleeesec.e@formeshorte@namehproducerfsingleeprod.hmultipleeprod.e@formeshorte@namemscript-writerfsingleescen.hmultipleescen.e@formeshorte@namenseries-creatorfsinglemaut. d. seriehmultiplemaut. d. seriee@formeshorte@namejtranslatorfsingleetrad.hmultipleetrad.e@formeshorte@nameechaire$textmpresieduto dae@formdverbe@nameqcollection-editore$textiedited bye@formdverbe@namehcompilere$textlcompilato dae@formdverbe@namepcontainer-authore$textbdie@formdverbe@namekcontributore$texttcon un contributo die@formdverbe@namegcuratore$textia cura die@formdverbe@namehdirectore$textjdiretto dae@formdverbe@namefeditore$textia cura die@formdverbe@nameqeditor-translatore$textwa cura di e tradotto dae@formdverbe@nameqeditor-translatore$textwa cura di e tradotto dae@formdverbe@namereditorial-directore$textwdirezione editoriale die@formdverbe@namerexecutive-producere$textwproduzione esecutiva die@formdverbe@nameegueste$textjcon ospitee@formdverbe@namedhoste$textkcondotto dae@formdverbe@namekillustratore$textmillustrato dae@formdverbe@namekinterviewere$textmintervista die@formdverbe@namehnarratore$textjnarrato dae@formdverbe@nameiorganizere$textnorganizzato dae@formdverbe@nameiperformere$textmesecuzione die@formdverbe@namehproducere$textkprodotto dae@formdverbe@nameirecipiente$textaae@formdverbe@nameoreviewed-authore$textbdie@formdverbe@namemscript-writere$textjscritto dae@formdverbe@namenseries-creatore$texticreato dae@formdverbe@namejtranslatore$textktradotto dae@formdverbe@nameqcollection-editore$textfed. bye@formjverb-shorte@namehcompilere$texthcomp. dae@formjverb-shorte@namekcontributore$textrcon un contrib. die@formjverb-shorte@namegcuratore$textga c. die@formjverb-shorte@namehdirectore$textgdir. dae@formjverb-shorte@namefeditore$textga c. die@formjverb-shorte@nameqeditor-translatore$textra c. di e trad. dae@formjverb-shorte@nameqeditor-translatore$textra c. di e trad. dae@formjverb-shorte@namereditorial-directore$textkdir. ed. die@formjverb-shorte@namerexecutive-producere$textnprod. esec. die@formjverb-shorte@nameegueste$texthcon osp.e@formjverb-shorte@namedhoste$texthcond. dae@formjverb-shorte@namekillustratore$textgill. dae@formjverb-shorte@namehnarratore$texthnarr. dae@formjverb-shorte@nameiorganizere$textgorg. dae@formjverb-shorte@nameiperformere$texthesec. die@formjverb-shorte@namehproducere$texthprod. dae@formjverb-shorte@namemscript-writere$textgscr. dae@formjverb-shorte@namenseries-creatore$textgcre. dae@formjverb-shorte@namejtranslatore$texthtrad. dae@formjverb-shorte@namehmonth-01e$textggennaioe@formdlongg@genderimasculinee@namehmonth-02e$texthfebbraioe@formdlongg@genderimasculinee@namehmonth-03e$textemarzoe@formdlongg@genderimasculinee@namehmonth-04e$textfaprilee@formdlongg@genderimasculinee@namehmonth-05e$textfmaggioe@formdlongg@genderimasculinee@namehmonth-06e$textfgiugnoe@formdlongg@genderimasculinee@namehmonth-07e$textfluglioe@formdlongg@genderimasculinee@namehmonth-08e$textfagostoe@formdlongg@genderimasculinee@namehmonth-09e$textisettembree@formdlongg@genderimasculinee@namehmonth-10e$textgottobree@formdlongg@genderimasculinee@namehmonth-11e$texthnovembree@formdlongg@genderimasculinee@namehmonth-12e$texthdicembree@formdlongg@genderimasculinee@namehmonth-01e$textdgen.e@formeshorte@namehmonth-02e$textdfeb.e@formeshorte@namehmonth-03e$textdmar.e@formeshorte@namehmonth-04e$textdapr.e@formeshorte@namehmonth-05e$textdmag.e@formeshorte@namehmonth-06e$textdgiu.e@formeshorte@namehmonth-07e$textdlug.e@formeshorte@namehmonth-08e$textdago.e@formeshorte@namehmonth-09e$textdset.e@formeshorte@namehmonth-10e$textdott.e@formeshorte@namehmonth-11e$textdnov.e@formeshorte@namehmonth-12e$textddic.e@formeshorte@nameiseason-01e$textiprimaverae@formdlonge@nameiseason-02e$textfestatee@formdlonge@nameiseason-03e$textgautunnoe@formdlonge@nameiseason-04e$textginvernoe@formdlongddatee@formdtextidate-parte@namecdayg@suffixa n@strip-periodse@nameemonthg@suffixa n@strip-periodse@namedyearn@strip-periodse@formgnumericidate-parte@namecdaye@formunumeric-leading-zerosg@suffixa/n@strip-periodse@nameemonthe@formunumeric-leading-zerosg@suffixa/n@strip-periodse@namedyearn@strip-periodsmstyle-optionsu@punctuation-in-quote \ No newline at end of file From 47263b839ff2b0f3d7991e3ff12c47b6e8adb8ec Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 21 Jul 2026 20:56:07 +0200 Subject: [PATCH 18/31] Remove hayagriva-biblatex --- Cargo.lock | 6 ------ Cargo.toml | 11 +---------- crates/hayagriva-biblatex/Cargo.toml | 10 ---------- crates/hayagriva-biblatex/src/lib.rs | 1 - crates/hayagriva-cli/Cargo.toml | 1 - crates/hayagriva-format/Cargo.toml | 3 +-- 6 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 crates/hayagriva-biblatex/Cargo.toml delete mode 100644 crates/hayagriva-biblatex/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index ac3232ae..020d4f3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,10 +226,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hayagriva-biblatex" -version = "0.10.1" - [[package]] name = "hayagriva-cli" version = "0.10.1" @@ -238,7 +234,6 @@ dependencies = [ "citationberg", "clap", "hayagriva-archive", - "hayagriva-biblatex", "hayagriva-core", "hayagriva-csl", "hayagriva-format", @@ -277,7 +272,6 @@ version = "0.10.1" dependencies = [ "biblatex", "citationberg", - "hayagriva-biblatex", "hayagriva-core", "indexmap", "paste", diff --git a/Cargo.toml b/Cargo.toml index 48003a13..b3285c9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,5 @@ [workspace] -members = [ - "crates/hayagriva-archive", - "crates/hayagriva-biblatex", - "crates/hayagriva-cli", - "crates/hayagriva-core", - "crates/hayagriva-csl", - "crates/hayagriva-format", - "crates/hayagriva-json", - "crates/tests", -] +members = ["crates/*"] resolver = "2" [workspace.package] diff --git a/crates/hayagriva-biblatex/Cargo.toml b/crates/hayagriva-biblatex/Cargo.toml deleted file mode 100644 index e304c46f..00000000 --- a/crates/hayagriva-biblatex/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "hayagriva-biblatex" -description = "Archived CSL styles and locales for Hayagriva/Typst" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -readme.workspace = true -keywords.workspace = true diff --git a/crates/hayagriva-biblatex/src/lib.rs b/crates/hayagriva-biblatex/src/lib.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/hayagriva-biblatex/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index 114e153a..83412bc1 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -13,7 +13,6 @@ keywords.workspace = true citationberg = { workspace = true } clap = { version = "4", features = ["cargo", "derive"] } hayagriva-archive = { path = "../hayagriva-archive" } -hayagriva-biblatex = { path = "../hayagriva-biblatex" } hayagriva-core = { path = "../hayagriva-core" } hayagriva-csl = { path = "../hayagriva-csl" } hayagriva-format = { path = "../hayagriva-format" } diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 33ba53ef..86ad46f4 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -19,7 +19,6 @@ unic-langid = { workspace = true } serde_yaml = "0.9.25" unicode-segmentation = { workspace = true } hayagriva-core = { path = "../hayagriva-core" } -hayagriva-biblatex = { path = "../hayagriva-biblatex", optional = true } thiserror = { workspace = true } unscanny = { workspace = true } url = { workspace = true, optional = true } @@ -28,4 +27,4 @@ url = { workspace = true, optional = true } serde_json = "1" [features] -biblatex = ["dep:biblatex", "dep:hayagriva-biblatex", "dep:url"] +biblatex = ["dep:biblatex", "dep:url"] From 1b9e313d3eb5f1d3af5514c7c0c6de3a92029929 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 21 Jul 2026 21:25:25 +0200 Subject: [PATCH 19/31] Doc, make api somewhat smaller --- crates/hayagriva-archive/src/lib.rs | 4 ++-- crates/hayagriva-archive/tests/archiver.rs | 4 ++-- crates/hayagriva-cli/src/main.rs | 7 +++++++ crates/hayagriva-core/src/lib.rs | 14 ++++++++++++++ crates/hayagriva-core/src/test_util.rs | 2 ++ crates/hayagriva-csl/src/lib.rs | 12 ++++++++---- crates/hayagriva-format/src/lib.rs | 4 ++-- crates/hayagriva-json/src/lib.rs | 1 + 8 files changed, 38 insertions(+), 10 deletions(-) diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index 975ebdd3..782ef313 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -1,4 +1,4 @@ -//! Archive CSL styles. Included in Typst +//! Archive CSL styles. Included in Typst. // This file is generated by tests/archiver.rs // Do not edit by hand! @@ -1161,7 +1161,7 @@ fn from_cbor( } /// CBOR-encoded CSL locales. -pub const LOCALES: &[&[u8]] = &[ +const LOCALES: &[&[u8]] = &[ include_bytes!("../../../archive/locales/af-ZA.cbor"), include_bytes!("../../../archive/locales/ar.cbor"), include_bytes!("../../../archive/locales/bal-PK.cbor"), diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index 6c6d4aa5..a148a95d 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -257,7 +257,7 @@ fn write_styles_section( w: &mut String, items: &[(Vec, IndependentStyle, Vec, String)], ) -> fmt::Result { - writeln!(w, "//! Archive CSL styles. Included in Typst")?; + writeln!(w, "//! Archive CSL styles. Included in Typst.")?; writeln!(w, "// This file is generated by tests/archiver.rs")?; writeln!(w, "// Do not edit by hand!")?; writeln!(w)?; @@ -391,7 +391,7 @@ fn write_locales_section(w: &mut String, items: &[(Vec, Locale)]) -> fmt::Re writeln!(w)?; writeln!(w, "/// CBOR-encoded CSL locales.")?; - writeln!(w, "pub const LOCALES: &[&[u8]] = &[")?; + writeln!(w, "const LOCALES: &[&[u8]] = &[")?; for (_, locale) in items { writeln!( w, diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 55e94898..3ebcc1ee 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -55,11 +55,15 @@ use hayagriva_format::{Selector, io}; #[derive(Debug, Copy, Clone, PartialEq, VariantNames)] #[strum(serialize_all = "kebab_case")] +/// Which input format is expected. pub enum Format { #[cfg(feature = "biblatex")] + /// The bibtex format. Bibtex, #[cfg(feature = "biblatex")] + /// BibLaTeX format. Biblatex, + /// Hayagriva YAML. Yaml, } @@ -86,6 +90,9 @@ impl ValueEnum for Format { } #[derive(ValueEnum, Clone)] +/// CSL locator types. This enum is used to specify the type of locator given +/// via the `--locators` argument of the `cite` command. +/// See the `--locator-type` argument. enum LocatorTypes { Act, Appendix, diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs index af21ad02..11a08e89 100644 --- a/crates/hayagriva-core/src/lib.rs +++ b/crates/hayagriva-core/src/lib.rs @@ -1,3 +1,8 @@ +//! Hayagriva's core. +//! +//! This crate contains data types, traits, and functions used for the +//! different formats and rendering crates of Hayagriva. + pub mod lang; pub mod test_util; pub mod types; @@ -13,6 +18,9 @@ use citationberg::{ }; pub use types::*; +/// Defines an entry for CSL rendering. Implementing this trait enables +/// interaction between an input format like Hayagriva or CSL-JSON and the CSL +/// rendering implementation. pub trait EntryLike { fn resolve_number_variable( &self, @@ -29,7 +37,13 @@ pub trait EntryLike { ) -> Option>; fn resolve_name_variable(&self, variable: NameVariable) -> Vec>; fn resolve_date_variable(&self, variable: DateVariable) -> Option>; + /// `true` if the entry can be interpreted as the given `kind`. As most + /// formats do not have a perfect correspondance, this check is usually + /// "best-effort" and optimistic. fn matches_entry_type(&self, kind: taxonomy::Kind) -> bool; + /// Returns `None` if the entry's language is unknown, `Some(true)` if it + /// is known to be English, and `Some(false)` otherwise. fn is_english(&self) -> Option; + /// The entry's key in its containing library. fn key(&self) -> Cow<'_, str>; } diff --git a/crates/hayagriva-core/src/test_util.rs b/crates/hayagriva-core/src/test_util.rs index 4c76b08a..555c9134 100644 --- a/crates/hayagriva-core/src/test_util.rs +++ b/crates/hayagriva-core/src/test_util.rs @@ -1,3 +1,5 @@ +//! Utilities for tests in Hayagriva. + use std::{fs, io, path::PathBuf, process::Command}; pub const CACHE_PATH: &str = "../../target/haya-cache"; diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index 954ac3d6..1942dad1 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -734,7 +734,7 @@ fn date_replacement( })]) } -pub fn write_year( +pub(crate) fn write_year( year: i32, short: bool, w: &mut W, @@ -1599,7 +1599,7 @@ pub struct RenderedCitation { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Sorting { +enum Sorting { Variable, Macro, } @@ -2703,7 +2703,7 @@ impl IdentifierUsage { } #[derive(Debug, Clone, Default, PartialEq, Eq, Hash)] -pub enum DisambiguateState { +enum DisambiguateState { #[default] None, NameDisambiguation(NameDisambiguationProperties), @@ -2745,7 +2745,7 @@ impl DisambiguateState { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum IbidState { +enum IbidState { /// The previous cite referenced another entry, or this cite has no locator /// when the previous one did. Different, @@ -2822,7 +2822,11 @@ impl PartialEq for TransparentLocator { } } +/// Content of the "transparent" locator. It has to privide a way to check +/// for equality with other transparent locators for the "ibid" usage. pub trait TransparentLocatorPayload: Any { + /// Returns `true` iff a locator with this payload is considered equal to + /// the locator with payload `other`. fn dyn_eq(&self, other: &dyn TransparentLocatorPayload) -> bool; } diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index a4e8fc0b..17930ecb 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -68,9 +68,9 @@ mod selectors; pub mod citation_label; #[cfg(feature = "biblatex")] -pub mod interop; +mod interop; pub mod io; -pub mod taxonomy; +mod taxonomy; use std::collections::BTreeMap; diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-json/src/lib.rs index 3d138fa5..e041072d 100644 --- a/crates/hayagriva-json/src/lib.rs +++ b/crates/hayagriva-json/src/lib.rs @@ -18,6 +18,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(transparent)] +/// A CSL-JSON item. It is a wrapper around a [csl_json::Item]. pub struct Item(pub csl_json::Item); fn resolve_csl_json_standard_variable( From b35eb06230c9ec36fd941ceab571aba3604c89b4 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 21 Jul 2026 21:28:03 +0200 Subject: [PATCH 20/31] Remove "extern crate" --- crates/hayagriva-archive/tests/archiver.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index a148a95d..e0da5fea 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -10,9 +10,6 @@ //! these tests (with `--test archiver`) to update the otherwise outdated //! files. -extern crate citationberg; -extern crate serde; - use citationberg::{IndependentStyle, LocaleCode, Style}; use citationberg::{Locale, LocaleFile, XmlDeError}; use serde::Serialize; From 40a022537b8d035214b31996affd8ccb9b6170ab Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Tue, 21 Jul 2026 21:45:22 +0200 Subject: [PATCH 21/31] Follow import style --- crates/hayagriva-archive/tests/archiver.rs | 13 ++++----- crates/hayagriva-cli/src/main.rs | 4 +-- crates/hayagriva-core/src/lang/mod.rs | 6 ++-- crates/hayagriva-core/src/lib.rs | 20 ++++++------- crates/hayagriva-core/src/test_util.rs | 4 ++- crates/hayagriva-core/src/types/page.rs | 10 +++++-- crates/hayagriva-core/src/types/strings.rs | 4 ++- crates/hayagriva-core/src/types/time.rs | 8 ++--- crates/hayagriva-core/src/util.rs | 3 +- crates/hayagriva-csl/src/lib.rs | 13 +++++---- crates/hayagriva-csl/src/rendering/mod.rs | 5 ++-- crates/hayagriva-csl/src/rendering/names.rs | 3 +- crates/hayagriva-csl/src/sort.rs | 3 +- crates/hayagriva-csl/src/taxonomy.rs | 7 ++--- crates/hayagriva-format/src/interop.rs | 4 +-- crates/hayagriva-format/src/lib.rs | 29 ++++++++++--------- .../hayagriva-format/src/selectors/parser.rs | 3 +- crates/hayagriva-format/src/taxonomy.rs | 11 ++++--- crates/hayagriva-json/src/lib.rs | 11 ++++--- crates/tests/tests/citeproc.rs | 9 +++--- 20 files changed, 90 insertions(+), 80 deletions(-) diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index e0da5fea..a78e5332 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -10,19 +10,18 @@ //! these tests (with `--test archiver`) to update the otherwise outdated //! files. -use citationberg::{IndependentStyle, LocaleCode, Style}; -use citationberg::{Locale, LocaleFile, XmlDeError}; -use serde::Serialize; use std::collections::{HashMap, HashSet}; +use std::fmt; use std::fmt::Write; use std::fs; use std::hash::RandomState; use std::io::{self, BufReader, Read}; +use std::iter::{self, FromIterator}; use std::path::{Path, PathBuf}; -use std::{ - fmt, - iter::{self, FromIterator}, -}; + +use citationberg::{IndependentStyle, LocaleCode, Style}; +use citationberg::{Locale, LocaleFile, XmlDeError}; +use serde::Serialize; use hayagriva_core::test_util::{ CACHE_PATH, ensure_repo, iter_files, iter_files_with_name, diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 3ebcc1ee..bad0cbd3 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -42,8 +42,6 @@ use citationberg::{ }; use clap::builder::PossibleValue; use clap::{Arg, ArgAction, Command, ValueEnum, crate_version}; -#[cfg(feature = "biblatex")] -use hayagriva_format::io::from_biblatex_str; use strum::VariantNames; use hayagriva_archive::{ArchivedStyle, locales}; @@ -51,6 +49,8 @@ use hayagriva_csl::{ BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, LocatorPayload, SpecificLocator, }; +#[cfg(feature = "biblatex")] +use hayagriva_format::io::from_biblatex_str; use hayagriva_format::{Selector, io}; #[derive(Debug, Copy, Clone, PartialEq, VariantNames)] diff --git a/crates/hayagriva-core/src/lang/mod.rs b/crates/hayagriva-core/src/lang/mod.rs index 92a2fd3c..80b09434 100644 --- a/crates/hayagriva-core/src/lang/mod.rs +++ b/crates/hayagriva-core/src/lang/mod.rs @@ -1,14 +1,14 @@ //! Language-dependant string transformations. -pub(crate) mod en; -pub(crate) mod name; - use std::{fmt::Write, mem}; use citationberg::TextCase; use crate::types::{FoldableKind, FoldableStringChunk}; +pub(crate) mod en; +pub(crate) mod name; + /// Rules for the title case transformation. #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[non_exhaustive] diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs index 11a08e89..5d402943 100644 --- a/crates/hayagriva-core/src/lib.rs +++ b/crates/hayagriva-core/src/lib.rs @@ -3,21 +3,21 @@ //! This crate contains data types, traits, and functions used for the //! different formats and rendering crates of Hayagriva. -pub mod lang; -pub mod test_util; -pub mod types; -pub mod util; - use std::borrow::Cow; -use citationberg::{ - LongShortForm, - taxonomy::{ - self, DateVariable, NameVariable, NumberVariable, PageVariable, StandardVariable, - }, +use citationberg::LongShortForm; +use citationberg::taxonomy; +use citationberg::taxonomy::{ + DateVariable, NameVariable, NumberVariable, PageVariable, StandardVariable, }; + pub use types::*; +pub mod lang; +pub mod test_util; +pub mod types; +pub mod util; + /// Defines an entry for CSL rendering. Implementing this trait enables /// interaction between an input format like Hayagriva or CSL-JSON and the CSL /// rendering implementation. diff --git a/crates/hayagriva-core/src/test_util.rs b/crates/hayagriva-core/src/test_util.rs index 555c9134..7c6e1e99 100644 --- a/crates/hayagriva-core/src/test_util.rs +++ b/crates/hayagriva-core/src/test_util.rs @@ -1,6 +1,8 @@ //! Utilities for tests in Hayagriva. -use std::{fs, io, path::PathBuf, process::Command}; +use std::path::PathBuf; +use std::process::Command; +use std::{fs, io}; pub const CACHE_PATH: &str = "../../target/haya-cache"; diff --git a/crates/hayagriva-core/src/types/page.rs b/crates/hayagriva-core/src/types/page.rs index 72328527..af85c893 100644 --- a/crates/hayagriva-core/src/types/page.rs +++ b/crates/hayagriva-core/src/types/page.rs @@ -1,10 +1,14 @@ -use std::{cmp::Ordering, fmt::Display, num::TryFromIntError, str::FromStr}; +use std::cmp::Ordering; +use std::fmt::Display; +use std::num::TryFromIntError; +use std::str::FromStr; + +use serde::{Deserialize, Serialize}; +use thiserror::Error; use crate::types::{MaybeTyped, Numeric, NumericError}; use super::{custom_deserialize, serialize_display}; -use serde::{Deserialize, Serialize}; -use thiserror::Error; impl MaybeTyped { /// Order the values according to CSL rules. diff --git a/crates/hayagriva-core/src/types/strings.rs b/crates/hayagriva-core/src/types/strings.rs index 4829b35c..57260a9f 100644 --- a/crates/hayagriva-core/src/types/strings.rs +++ b/crates/hayagriva-core/src/types/strings.rs @@ -4,7 +4,9 @@ use std::fmt::Display; use std::str::FromStr; use citationberg::LongShortForm; -use serde::{Deserialize, Serialize, de::Visitor, ser::SerializeMap}; +use serde::de::Visitor; +use serde::ser::SerializeMap; +use serde::{Deserialize, Serialize}; use thiserror::Error; use unscanny::Scanner; diff --git a/crates/hayagriva-core/src/types/time.rs b/crates/hayagriva-core/src/types/time.rs index dfd0c7f3..a2ef31ac 100644 --- a/crates/hayagriva-core/src/types/time.rs +++ b/crates/hayagriva-core/src/types/time.rs @@ -1,8 +1,6 @@ -use std::{ - convert::TryInto, - fmt::{Debug, Display, Write}, - str::FromStr, -}; +use std::convert::TryInto; +use std::fmt::{Debug, Display, Write}; +use std::str::FromStr; use citationberg::taxonomy::Season; use serde::{Deserialize, Serialize, de}; diff --git a/crates/hayagriva-core/src/util.rs b/crates/hayagriva-core/src/util.rs index 084c966b..1b3096dc 100644 --- a/crates/hayagriva-core/src/util.rs +++ b/crates/hayagriva-core/src/util.rs @@ -1,6 +1,7 @@ //! Helpers for serializing and deserializing. -use serde::{Deserialize, Deserializer, Serialize, de::Visitor}; +use serde::de::Visitor; +use serde::{Deserialize, Deserializer, Serialize}; /// Generic wrapper that allow one or more occurrences of specified type. /// diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index 1942dad1..f37c9c35 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -73,16 +73,17 @@ use citationberg::taxonomy::{ PageVariable, StandardVariable, Term, Variable, }; use citationberg::{ - Affixes, BaseLanguage, Citation, CitationFormat, Collapse, CslMacro, + Affixes, BaseLanguage, Citation, CitationFormat, Collapse, CslMacro, DateForm, DisambiguationRule, Display, GrammarGender, IndependentStyle, InheritableNameOptions, - Layout, LayoutRenderingElement, Locale, LocaleCode, Names, SecondFieldAlign, - StyleCategory, StyleClass, SubsequentAuthorSubstituteRule, TermForm, ToAffixes, - ToFormatting, taxonomy as csl_taxonomy, + Layout, LayoutRenderingElement, Locale, LocaleCode, LongShortForm, Names, + OrdinalLookup, SecondFieldAlign, StyleCategory, StyleClass, + SubsequentAuthorSubstituteRule, TermForm, TextCase, ToAffixes, ToFormatting, + taxonomy as csl_taxonomy, }; -use citationberg::{DateForm, LongShortForm, OrdinalLookup, TextCase}; +use indexmap::IndexSet; + use hayagriva_core::lang::CaseFolder; use hayagriva_core::{ChunkKind, ChunkedString, Date, EntryLike, MaybeTyped, Person}; -use indexmap::IndexSet; use crate::elem::{NonEmptyStack, simplify_children}; use crate::rendering::RenderCsl; diff --git a/crates/hayagriva-csl/src/rendering/mod.rs b/crates/hayagriva-csl/src/rendering/mod.rs index 4cfac10c..084c82fc 100644 --- a/crates/hayagriva-csl/src/rendering/mod.rs +++ b/crates/hayagriva-csl/src/rendering/mod.rs @@ -9,9 +9,10 @@ use citationberg::taxonomy::{ use citationberg::{ ChooseBranch, CslMacro, DateDayForm, DateMonthForm, DatePartName, DateParts, DateStrongAnyForm, GrammarGender, LabelPluralize, LayoutRenderingElement, - LongShortForm, NumberForm, PageRangeFormat, TestPosition, ToAffixes, ToFormatting, + LongShortForm, NumberForm, PageRangeFormat, TermForm, TestPosition, TextTarget, + ToAffixes, ToFormatting, }; -use citationberg::{TermForm, TextTarget}; + use hayagriva_core::{ ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, PageRangesPart, }; diff --git a/crates/hayagriva-csl/src/rendering/names.rs b/crates/hayagriva-csl/src/rendering/names.rs index ebaf0f64..60c83709 100644 --- a/crates/hayagriva-csl/src/rendering/names.rs +++ b/crates/hayagriva-csl/src/rendering/names.rs @@ -10,9 +10,10 @@ use citationberg::{ ToFormatting, }; -use crate::{Context, DisambiguateState, ElemMeta, SpecialForm, UsageInfo}; use hayagriva_core::{EntryLike, Person}; +use crate::{Context, DisambiguateState, ElemMeta, SpecialForm, UsageInfo}; + use super::{RenderCsl, render_label_with_var}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/crates/hayagriva-csl/src/sort.rs b/crates/hayagriva-csl/src/sort.rs index a6e116b6..c20d71e9 100644 --- a/crates/hayagriva-csl/src/sort.rs +++ b/crates/hayagriva-csl/src/sort.rs @@ -9,11 +9,12 @@ use icu_collator::Collator; use icu_collator::options::CollatorOptions; use icu_locale::Locale as IcuLocale; +use hayagriva_core::EntryLike; + use crate::BufWriteFormat; use crate::rendering::RenderCsl; use super::{CitationItem, InstanceContext, StyleContext}; -use hayagriva_core::EntryLike; trait CollationOrd: Ord { fn collation_cmp(&self, other: &Self, locale: LocaleCode) -> Ordering; diff --git a/crates/hayagriva-csl/src/taxonomy.rs b/crates/hayagriva-csl/src/taxonomy.rs index deeadfcd..555b360b 100644 --- a/crates/hayagriva-csl/src/taxonomy.rs +++ b/crates/hayagriva-csl/src/taxonomy.rs @@ -4,10 +4,9 @@ use std::str::FromStr; use citationberg::LongShortForm; use citationberg::taxonomy::{NumberVariable, PageVariable, StandardVariable}; -use hayagriva_core::{ - EntryLike, PageRanges, - types::{ChunkedString, MaybeTyped, Numeric, StringChunk}, -}; + +use hayagriva_core::types::{ChunkedString, MaybeTyped, Numeric, StringChunk}; +use hayagriva_core::{EntryLike, PageRanges}; use super::{DisambiguateState, InstanceContext, LocatorPayload}; diff --git a/crates/hayagriva-format/src/interop.rs b/crates/hayagriva-format/src/interop.rs index 00dd39d0..4bcc0627 100644 --- a/crates/hayagriva-format/src/interop.rs +++ b/crates/hayagriva-format/src/interop.rs @@ -10,12 +10,12 @@ use tex::{ Chunk, ChunksExt, DateValue, EditorType, PermissiveType, RetrievalError, Spanned, TypeError, }; - use url::Url; -use super::Entry; use hayagriva_core::types::*; +use super::Entry; + macro_rules! tex_kinds { ($self:expr, $mv_attr:expr, [$({$kind:pat, $new_kind:expr, $top_level:expr, $expand_mv:expr}),* $(,)*] $(,)*) => { match $self.entry_type { diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 17930ecb..29a7a78e 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -63,29 +63,30 @@ #![warn(missing_docs)] #![allow(clippy::comparison_chain)] -#[macro_use] -mod selectors; - -pub mod citation_label; -#[cfg(feature = "biblatex")] -mod interop; -pub mod io; -mod taxonomy; - use std::collections::BTreeMap; pub use citationberg; -pub use selectors::{Selector, SelectorError}; +use indexmap::IndexMap; +use paste::paste; +use serde::{Deserialize, Serialize, de::Visitor}; +use unic_langid::LanguageIdentifier; use hayagriva_core::types::*; use hayagriva_core::util::{ OneOrMany, deserialize_one_or_many_opt, serialize_one_or_many, serialize_one_or_many_opt, }; -use indexmap::IndexMap; -use paste::paste; -use serde::{Deserialize, Serialize, de::Visitor}; -use unic_langid::LanguageIdentifier; + +pub use selectors::{Selector, SelectorError}; + +#[macro_use] +mod selectors; + +pub mod citation_label; +#[cfg(feature = "biblatex")] +mod interop; +pub mod io; +mod taxonomy; /// A collection of bibliographic entries. #[derive(Debug, Clone, Default, PartialEq, Serialize)] diff --git a/crates/hayagriva-format/src/selectors/parser.rs b/crates/hayagriva-format/src/selectors/parser.rs index fb5878e2..1ab04a22 100644 --- a/crates/hayagriva-format/src/selectors/parser.rs +++ b/crates/hayagriva-format/src/selectors/parser.rs @@ -1,8 +1,9 @@ use std::str::FromStr; -use super::{Selector, SelectorError, SelectorResult}; use hayagriva_core::types::EntryType; +use super::{Selector, SelectorError, SelectorResult}; + /// Parse a selector. pub fn parse(src: &str) -> SelectorResult { let mut p = Parser::new(src); diff --git a/crates/hayagriva-format/src/taxonomy.rs b/crates/hayagriva-format/src/taxonomy.rs index e57203f6..cbe04f0b 100644 --- a/crates/hayagriva-format/src/taxonomy.rs +++ b/crates/hayagriva-format/src/taxonomy.rs @@ -2,17 +2,16 @@ use std::{borrow::Cow, str::FromStr}; -use citationberg::{ - LongShortForm, - taxonomy::{ - DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, - }, +use citationberg::LongShortForm; +use citationberg::taxonomy::{ + DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, }; +use unic_langid::LanguageIdentifier; + use hayagriva_core::{ ChunkedString, Date, EntryLike, EntryType, MaybeTyped, Numeric, PageRanges, Person, PersonRole, Publisher, StringChunk, }; -use unic_langid::LanguageIdentifier; use crate::citation_label::Alphanumerical; diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-json/src/lib.rs index e041072d..eddfe5ca 100644 --- a/crates/hayagriva-json/src/lib.rs +++ b/crates/hayagriva-json/src/lib.rs @@ -5,16 +5,15 @@ use std::{borrow::Cow, str::FromStr}; -use citationberg::{ - LongShortForm, json as csl_json, - taxonomy::{ - DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, - }, +use citationberg::taxonomy::{ + DateVariable, Kind, NameVariable, NumberVariable, PageVariable, StandardVariable, }; +use citationberg::{LongShortForm, json as csl_json}; +use serde::{Deserialize, Serialize}; + use hayagriva_core::{ ChunkedString, Date, EntryLike, MaybeTyped, Numeric, PageRanges, Person, StringChunk, }; -use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(transparent)] diff --git a/crates/tests/tests/citeproc.rs b/crates/tests/tests/citeproc.rs index 85b32f6a..78842f15 100644 --- a/crates/tests/tests/citeproc.rs +++ b/crates/tests/tests/citeproc.rs @@ -6,18 +6,19 @@ use std::str::FromStr; use std::sync::OnceLock; use std::{fmt, fs}; +use citationberg::json as csl_json; use citationberg::taxonomy::Locator; use citationberg::{Locale, LocaleCode, Style, XmlDeError}; -use hayagriva_core::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; +use unscanny::Scanner; -use citationberg::json as csl_json; use hayagriva_archive::{ArchivedStyle, locales}; +use hayagriva_core::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; use hayagriva_csl::{ BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, CitePurpose, LocatorPayload, SpecificLocator, }; -use hayagriva_format::{Entry, io::from_biblatex_str}; -use unscanny::Scanner; +use hayagriva_format::Entry; +use hayagriva_format::io::from_biblatex_str; const TEST_REPO_NAME: &str = "test-suite"; const TEST_REPO: &str = "https://github.com/citation-style-language/test-suite"; From dbbf0656eeb24d912c42a0bf81efe34be01a98ef Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 20:19:45 +0200 Subject: [PATCH 22/31] Fix Cargo.toml files: no more `path` --- Cargo.toml | 6 ++++++ crates/hayagriva-archive/Cargo.toml | 2 +- crates/hayagriva-cli/Cargo.toml | 8 ++++---- crates/hayagriva-csl/Cargo.toml | 4 ++-- crates/hayagriva-format/Cargo.toml | 2 +- crates/hayagriva-json/Cargo.toml | 2 +- crates/tests/Cargo.toml | 10 +++++----- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b3285c9e..a8353467 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,12 @@ biblatex = { version = "0.12.0", features = ["unic-langid"] } ciborium = { version = "0.2.1" } citationberg = "0.7.0" indexmap = { version = "2.0.2", features = ["serde"] } +hayagriva-archive = { path = "crates/hayagriva-archive" } +hayagriva-cli = { path = "crates/hayagriva-cli" } +hayagriva-core = { path = "crates/hayagriva-core" } +hayagriva-csl = { path = "crates/hayagriva-csl" } +hayagriva-format = { path = "crates/hayagriva-format" } +hayagriva-json = { path = "crates/hayagriva-json" } serde = { version = "1", features = ["derive"] } unic-langid = { version = "0.9.6", features = ["serde"] } unicode-segmentation = "1.6.0" diff --git a/crates/hayagriva-archive/Cargo.toml b/crates/hayagriva-archive/Cargo.toml index 4262a62f..b71ec1ce 100644 --- a/crates/hayagriva-archive/Cargo.toml +++ b/crates/hayagriva-archive/Cargo.toml @@ -12,7 +12,7 @@ keywords.workspace = true [dependencies] citationberg = { workspace = true } serde = { workspace = true } -hayagriva-core = { path = "../hayagriva-core" } +hayagriva-core = { workspace = true } ciborium = { workspace = true } [dev-dependencies] diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index 83412bc1..563a1756 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -12,10 +12,10 @@ keywords.workspace = true [dependencies] citationberg = { workspace = true } clap = { version = "4", features = ["cargo", "derive"] } -hayagriva-archive = { path = "../hayagriva-archive" } -hayagriva-core = { path = "../hayagriva-core" } -hayagriva-csl = { path = "../hayagriva-csl" } -hayagriva-format = { path = "../hayagriva-format" } +hayagriva-archive = { workspace = true } +hayagriva-core = { workspace = true } +hayagriva-csl = { workspace = true } +hayagriva-format = { workspace = true } strum = { version = "0.26", features = ["derive"] } biblatex = { workspace = true, optional = true } diff --git a/crates/hayagriva-csl/Cargo.toml b/crates/hayagriva-csl/Cargo.toml index 49a1eb60..2d0ce9e9 100644 --- a/crates/hayagriva-csl/Cargo.toml +++ b/crates/hayagriva-csl/Cargo.toml @@ -14,8 +14,8 @@ citationberg = { workspace = true } indexmap = { workspace = true } icu_collator = "2.2.0" icu_locale = "2.2.0" -hayagriva-core = { path = "../hayagriva-core" } +hayagriva-core = { workspace = true } unic-langid = { workspace = true } [dev-dependencies] -hayagriva-format = { path = "../hayagriva-format" } +hayagriva-format = { workspace = true } diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 86ad46f4..88281df3 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -18,7 +18,7 @@ serde = { workspace = true } unic-langid = { workspace = true } serde_yaml = "0.9.25" unicode-segmentation = { workspace = true } -hayagriva-core = { path = "../hayagriva-core" } +hayagriva-core = { workspace = true } thiserror = { workspace = true } unscanny = { workspace = true } url = { workspace = true, optional = true } diff --git a/crates/hayagriva-json/Cargo.toml b/crates/hayagriva-json/Cargo.toml index f8bb5f93..54937914 100644 --- a/crates/hayagriva-json/Cargo.toml +++ b/crates/hayagriva-json/Cargo.toml @@ -11,5 +11,5 @@ keywords.workspace = true [dependencies] citationberg = { workspace = true, features = ["json"] } -hayagriva-core = { path = "../hayagriva-core" } +hayagriva-core = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 9e13a131..cc36aaef 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -11,11 +11,11 @@ publish = false [dev-dependencies] citationberg = { workspace = true, features = ["json"] } -hayagriva-archive = { path = "../hayagriva-archive" } -hayagriva-core = { path = "../hayagriva-core" } -hayagriva-csl = { path = "../hayagriva-csl" } -hayagriva-format = { path = "../hayagriva-format", features = ["biblatex"] } -hayagriva-json = { path = "../hayagriva-json" } +hayagriva-archive = { workspace = true } +hayagriva-core = { workspace = true } +hayagriva-csl = { workspace = true } +hayagriva-format = { workspace = true, features = ["biblatex"] } +hayagriva-json = { workspace = true } serde_json = "1" regex = "1" unscanny = { workspace = true } From acb335c7fd5ec73d94a2d2205acc6f612c8275e6 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 20:30:27 +0200 Subject: [PATCH 23/31] Move archive folder --- .../archive}/locales/af-ZA.cbor | 0 .../archive}/locales/ar.cbor | 0 .../archive}/locales/bal-PK.cbor | 0 .../archive}/locales/bg-BG.cbor | 0 .../archive}/locales/brh-PK.cbor | 0 .../archive}/locales/ca-AD.cbor | 0 .../archive}/locales/cs-CZ.cbor | 0 .../archive}/locales/cy-GB.cbor | 0 .../archive}/locales/da-DK.cbor | 0 .../archive}/locales/de-AT.cbor | 0 .../archive}/locales/de-CH.cbor | 0 .../archive}/locales/de-DE.cbor | 0 .../archive}/locales/el-GR.cbor | 0 .../archive}/locales/en-GB.cbor | 0 .../archive}/locales/en-US.cbor | 0 .../archive}/locales/es-CL.cbor | 0 .../archive}/locales/es-ES.cbor | 0 .../archive}/locales/es-MX.cbor | 0 .../archive}/locales/et-EE.cbor | 0 .../archive}/locales/eu.cbor | 0 .../archive}/locales/fa-IR.cbor | 0 .../archive}/locales/fi-FI.cbor | 0 .../archive}/locales/fr-CA.cbor | 0 .../archive}/locales/fr-FR.cbor | 0 .../archive}/locales/gl-ES.cbor | 0 .../archive}/locales/he-IL.cbor | 0 .../archive}/locales/hi-IN.cbor | 0 .../archive}/locales/hr-HR.cbor | 0 .../archive}/locales/hu-HU.cbor | 0 .../archive}/locales/hy-AM.cbor | 0 .../archive}/locales/id-ID.cbor | 0 .../archive}/locales/is-IS.cbor | 0 .../archive}/locales/it-IT.cbor | 0 .../archive}/locales/ja-JP.cbor | 0 .../archive}/locales/km-KH.cbor | 0 .../archive}/locales/ko-KR.cbor | 0 .../archive}/locales/la.cbor | 0 .../archive}/locales/lij-IT.cbor | 0 .../archive}/locales/lt-LT.cbor | 0 .../archive}/locales/lv-LV.cbor | 0 .../archive}/locales/mn-MN.cbor | 0 .../archive}/locales/ms-MY.cbor | 0 .../archive}/locales/nb-NO.cbor | 0 .../archive}/locales/nl-NL.cbor | 0 .../archive}/locales/nn-NO.cbor | 0 .../archive}/locales/pa-PK.cbor | 0 .../archive}/locales/pl-PL.cbor | 0 .../archive}/locales/pt-BR.cbor | 0 .../archive}/locales/pt-PT.cbor | 0 .../archive}/locales/ro-RO.cbor | 0 .../archive}/locales/ru-RU.cbor | 0 .../archive}/locales/sk-SK.cbor | 0 .../archive}/locales/sl-SI.cbor | 0 .../archive}/locales/sr-Cyrl-RS.cbor | 0 .../archive}/locales/sr-Latn-RS.cbor | 0 .../archive}/locales/sr-RS.cbor | 0 .../archive}/locales/sv-SE.cbor | 0 .../archive}/locales/th-TH.cbor | 0 .../archive}/locales/tl-PH.cbor | 0 .../archive}/locales/tr-TR.cbor | 0 .../archive}/locales/uk-UA.cbor | 0 .../archive}/locales/vi-VN.cbor | 0 .../archive}/locales/zh-CN.cbor | 0 .../archive}/locales/zh-TW.cbor | 0 .../archive}/styles/alphanumeric.cbor | 0 .../american-anthropological-association.cbor | Bin .../styles/american-chemical-society.cbor | Bin .../styles/american-geophysical-union.cbor | Bin ...itute-of-aeronautics-and-astronautics.cbor | Bin .../styles/american-institute-of-physics.cbor | Bin .../american-mathematical-society-label.cbor | Bin ...american-mathematical-society-numeric.cbor | Bin .../styles/american-medical-association.cbor | 0 .../american-meteorological-society.cbor | 0 .../styles/american-physics-society.cbor | Bin .../american-physiological-society.cbor | 0 ...merican-political-science-association.cbor | 0 .../american-society-for-microbiology.cbor | 0 .../american-society-of-civil-engineers.cbor | Bin ...rican-society-of-mechanical-engineers.cbor | Bin .../american-sociological-association.cbor | 0 .../archive}/styles/angewandte-chemie.cbor | Bin .../styles/annual-reviews-author-date.cbor | Bin .../archive}/styles/annual-reviews.cbor | Bin .../archive}/styles/apa.cbor | Bin ...ociacao-brasileira-de-normas-tecnicas.cbor | 0 .../association-for-computing-machinery.cbor | Bin .../archive}/styles/biomed-central.cbor | 0 .../archive}/styles/bmj.cbor | 0 .../styles/bristol-university-press.cbor | 0 .../archive}/styles/cell.cbor | 0 .../chicago-author-date-17th-edition.cbor | 0 .../archive}/styles/chicago-author-date.cbor | 0 .../styles/chicago-fullnote-bibliography.cbor | Bin .../styles/chicago-note-bibliography.cbor | Bin ...-subsequent-author-title-17th-edition.cbor | 0 .../styles/chicago-notes-bibliography.cbor | 0 .../chicago-shortened-notes-bibliography.cbor | 0 ...l-standard-gb-t-7714-2015-author-date.cbor | Bin ...national-standard-gb-t-7714-2015-note.cbor | Bin ...ional-standard-gb-t-7714-2015-numeric.cbor | Bin .../styles/chinese-gb7714-2005-numeric.cbor | Bin .../styles/copernicus-publications.cbor | 0 ...ouncil-of-science-editors-author-date.cbor | 0 .../council-of-science-editors-brackets.cbor | 0 ...itation-sequence-brackets-8th-edition.cbor | 0 .../archive}/styles/cse-name-year.cbor | 0 .../archive}/styles/current-opinion.cbor | 0 ...deutsche-gesellschaft-fur-psychologie.cbor | Bin .../archive}/styles/deutsche-sprache.cbor | 0 .../archive}/styles/elsevier-harvard.cbor | Bin .../archive}/styles/elsevier-vancouver.cbor | Bin .../archive}/styles/elsevier-with-titles.cbor | Bin .../archive}/styles/frontiers.cbor | 0 .../archive}/styles/future-medicine.cbor | Bin .../archive}/styles/future-science-group.cbor | 0 .../styles/gost-r-7-0-5-2008-numeric.cbor | Bin .../styles/harvard-cite-them-right.cbor | 0 .../archive}/styles/ieee.cbor | 0 .../styles/institute-of-physics-numeric.cbor | 0 .../styles/iso690-author-date-en.cbor | 0 .../archive}/styles/iso690-numeric-en.cbor | 0 .../archive}/styles/karger-journals.cbor | 0 .../styles/mary-ann-liebert-vancouver.cbor | 0 .../archive}/styles/mhra-notes.cbor | 0 ...humanities-research-association-notes.cbor | 0 ...odern-humanities-research-association.cbor | 0 ...dern-language-association-8th-edition.cbor | Bin .../styles/modern-language-association.cbor | Bin ...iplinary-digital-publishing-institute.cbor | Bin .../archive}/styles/nature.cbor | Bin .../nlm-citation-sequence-superscript.cbor | 0 .../styles/nlm-citation-sequence.cbor | 0 .../archive}/styles/pensoft-journals.cbor | 0 .../archive}/styles/plos.cbor | 0 .../styles/royal-society-of-chemistry.cbor | Bin .../archive}/styles/sage-vancouver.cbor | 0 .../archive}/styles/sist02.cbor | Bin .../archive}/styles/spie-journals.cbor | Bin .../styles/springer-basic-author-date.cbor | 0 .../styles/springer-basic-brackets.cbor | 0 ...fachzeitschriften-medizin-psychologie.cbor | 0 .../springer-humanities-author-date.cbor | Bin ...ger-lecture-notes-in-computer-science.cbor | Bin .../styles/springer-mathphys-brackets.cbor | Bin .../styles/springer-socpsych-author-date.cbor | Bin .../styles/springer-vancouver-brackets.cbor | 0 ...aylor-and-francis-chicago-author-date.cbor | 0 ...-francis-national-library-of-medicine.cbor | 0 ...itution-of-engineering-and-technology.cbor | 0 .../archive}/styles/the-lancet.cbor | 0 .../archive}/styles/thieme-german.cbor | 0 .../archive}/styles/trends-journals.cbor | Bin .../archive}/styles/turabian-author-date.cbor | Bin ...ian-fullnote-bibliography-8th-edition.cbor | 0 .../styles/vancouver-superscript.cbor | 0 .../archive}/styles/vancouver.cbor | 0 crates/hayagriva-archive/src/lib.rs | 290 +++++++++--------- crates/hayagriva-archive/tests/archiver.rs | 8 +- 159 files changed, 149 insertions(+), 149 deletions(-) rename {archive => crates/hayagriva-archive/archive}/locales/af-ZA.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ar.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/bal-PK.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/bg-BG.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/brh-PK.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ca-AD.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/cs-CZ.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/cy-GB.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/da-DK.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/de-AT.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/de-CH.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/de-DE.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/el-GR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/en-GB.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/en-US.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/es-CL.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/es-ES.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/es-MX.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/et-EE.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/eu.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/fa-IR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/fi-FI.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/fr-CA.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/fr-FR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/gl-ES.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/he-IL.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/hi-IN.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/hr-HR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/hu-HU.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/hy-AM.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/id-ID.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/is-IS.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/it-IT.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ja-JP.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/km-KH.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ko-KR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/la.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/lij-IT.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/lt-LT.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/lv-LV.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/mn-MN.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ms-MY.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/nb-NO.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/nl-NL.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/nn-NO.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/pa-PK.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/pl-PL.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/pt-BR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/pt-PT.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ro-RO.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/ru-RU.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sk-SK.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sl-SI.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sr-Cyrl-RS.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sr-Latn-RS.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sr-RS.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/sv-SE.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/th-TH.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/tl-PH.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/tr-TR.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/uk-UA.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/vi-VN.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/zh-CN.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/locales/zh-TW.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/alphanumeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-anthropological-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-chemical-society.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-geophysical-union.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-institute-of-aeronautics-and-astronautics.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-institute-of-physics.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-mathematical-society-label.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-mathematical-society-numeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-medical-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-meteorological-society.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-physics-society.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-physiological-society.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-political-science-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-society-for-microbiology.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-society-of-civil-engineers.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-society-of-mechanical-engineers.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/american-sociological-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/angewandte-chemie.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/annual-reviews-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/annual-reviews.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/apa.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/associacao-brasileira-de-normas-tecnicas.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/association-for-computing-machinery.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/biomed-central.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/bmj.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/bristol-university-press.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/cell.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-author-date-17th-edition.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-fullnote-bibliography.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-note-bibliography.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-notes-bibliography.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chicago-shortened-notes-bibliography.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/china-national-standard-gb-t-7714-2015-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/china-national-standard-gb-t-7714-2015-note.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/china-national-standard-gb-t-7714-2015-numeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/chinese-gb7714-2005-numeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/copernicus-publications.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/council-of-science-editors-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/council-of-science-editors-brackets.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/cse-citation-sequence-brackets-8th-edition.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/cse-name-year.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/current-opinion.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/deutsche-gesellschaft-fur-psychologie.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/deutsche-sprache.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/elsevier-harvard.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/elsevier-vancouver.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/elsevier-with-titles.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/frontiers.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/future-medicine.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/future-science-group.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/gost-r-7-0-5-2008-numeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/harvard-cite-them-right.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/ieee.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/institute-of-physics-numeric.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/iso690-author-date-en.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/iso690-numeric-en.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/karger-journals.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/mary-ann-liebert-vancouver.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/mhra-notes.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/modern-humanities-research-association-notes.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/modern-humanities-research-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/modern-language-association-8th-edition.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/modern-language-association.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/multidisciplinary-digital-publishing-institute.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/nature.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/nlm-citation-sequence-superscript.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/nlm-citation-sequence.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/pensoft-journals.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/plos.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/royal-society-of-chemistry.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/sage-vancouver.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/sist02.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/spie-journals.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-basic-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-basic-brackets.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-fachzeitschriften-medizin-psychologie.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-humanities-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-lecture-notes-in-computer-science.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-mathphys-brackets.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-socpsych-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/springer-vancouver-brackets.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/taylor-and-francis-chicago-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/taylor-and-francis-national-library-of-medicine.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/the-institution-of-engineering-and-technology.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/the-lancet.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/thieme-german.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/trends-journals.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/turabian-author-date.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/turabian-fullnote-bibliography-8th-edition.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/vancouver-superscript.cbor (100%) rename {archive => crates/hayagriva-archive/archive}/styles/vancouver.cbor (100%) diff --git a/archive/locales/af-ZA.cbor b/crates/hayagriva-archive/archive/locales/af-ZA.cbor similarity index 100% rename from archive/locales/af-ZA.cbor rename to crates/hayagriva-archive/archive/locales/af-ZA.cbor diff --git a/archive/locales/ar.cbor b/crates/hayagriva-archive/archive/locales/ar.cbor similarity index 100% rename from archive/locales/ar.cbor rename to crates/hayagriva-archive/archive/locales/ar.cbor diff --git a/archive/locales/bal-PK.cbor b/crates/hayagriva-archive/archive/locales/bal-PK.cbor similarity index 100% rename from archive/locales/bal-PK.cbor rename to crates/hayagriva-archive/archive/locales/bal-PK.cbor diff --git a/archive/locales/bg-BG.cbor b/crates/hayagriva-archive/archive/locales/bg-BG.cbor similarity index 100% rename from archive/locales/bg-BG.cbor rename to crates/hayagriva-archive/archive/locales/bg-BG.cbor diff --git a/archive/locales/brh-PK.cbor b/crates/hayagriva-archive/archive/locales/brh-PK.cbor similarity index 100% rename from archive/locales/brh-PK.cbor rename to crates/hayagriva-archive/archive/locales/brh-PK.cbor diff --git a/archive/locales/ca-AD.cbor b/crates/hayagriva-archive/archive/locales/ca-AD.cbor similarity index 100% rename from archive/locales/ca-AD.cbor rename to crates/hayagriva-archive/archive/locales/ca-AD.cbor diff --git a/archive/locales/cs-CZ.cbor b/crates/hayagriva-archive/archive/locales/cs-CZ.cbor similarity index 100% rename from archive/locales/cs-CZ.cbor rename to crates/hayagriva-archive/archive/locales/cs-CZ.cbor diff --git a/archive/locales/cy-GB.cbor b/crates/hayagriva-archive/archive/locales/cy-GB.cbor similarity index 100% rename from archive/locales/cy-GB.cbor rename to crates/hayagriva-archive/archive/locales/cy-GB.cbor diff --git a/archive/locales/da-DK.cbor b/crates/hayagriva-archive/archive/locales/da-DK.cbor similarity index 100% rename from archive/locales/da-DK.cbor rename to crates/hayagriva-archive/archive/locales/da-DK.cbor diff --git a/archive/locales/de-AT.cbor b/crates/hayagriva-archive/archive/locales/de-AT.cbor similarity index 100% rename from archive/locales/de-AT.cbor rename to crates/hayagriva-archive/archive/locales/de-AT.cbor diff --git a/archive/locales/de-CH.cbor b/crates/hayagriva-archive/archive/locales/de-CH.cbor similarity index 100% rename from archive/locales/de-CH.cbor rename to crates/hayagriva-archive/archive/locales/de-CH.cbor diff --git a/archive/locales/de-DE.cbor b/crates/hayagriva-archive/archive/locales/de-DE.cbor similarity index 100% rename from archive/locales/de-DE.cbor rename to crates/hayagriva-archive/archive/locales/de-DE.cbor diff --git a/archive/locales/el-GR.cbor b/crates/hayagriva-archive/archive/locales/el-GR.cbor similarity index 100% rename from archive/locales/el-GR.cbor rename to crates/hayagriva-archive/archive/locales/el-GR.cbor diff --git a/archive/locales/en-GB.cbor b/crates/hayagriva-archive/archive/locales/en-GB.cbor similarity index 100% rename from archive/locales/en-GB.cbor rename to crates/hayagriva-archive/archive/locales/en-GB.cbor diff --git a/archive/locales/en-US.cbor b/crates/hayagriva-archive/archive/locales/en-US.cbor similarity index 100% rename from archive/locales/en-US.cbor rename to crates/hayagriva-archive/archive/locales/en-US.cbor diff --git a/archive/locales/es-CL.cbor b/crates/hayagriva-archive/archive/locales/es-CL.cbor similarity index 100% rename from archive/locales/es-CL.cbor rename to crates/hayagriva-archive/archive/locales/es-CL.cbor diff --git a/archive/locales/es-ES.cbor b/crates/hayagriva-archive/archive/locales/es-ES.cbor similarity index 100% rename from archive/locales/es-ES.cbor rename to crates/hayagriva-archive/archive/locales/es-ES.cbor diff --git a/archive/locales/es-MX.cbor b/crates/hayagriva-archive/archive/locales/es-MX.cbor similarity index 100% rename from archive/locales/es-MX.cbor rename to crates/hayagriva-archive/archive/locales/es-MX.cbor diff --git a/archive/locales/et-EE.cbor b/crates/hayagriva-archive/archive/locales/et-EE.cbor similarity index 100% rename from archive/locales/et-EE.cbor rename to crates/hayagriva-archive/archive/locales/et-EE.cbor diff --git a/archive/locales/eu.cbor b/crates/hayagriva-archive/archive/locales/eu.cbor similarity index 100% rename from archive/locales/eu.cbor rename to crates/hayagriva-archive/archive/locales/eu.cbor diff --git a/archive/locales/fa-IR.cbor b/crates/hayagriva-archive/archive/locales/fa-IR.cbor similarity index 100% rename from archive/locales/fa-IR.cbor rename to crates/hayagriva-archive/archive/locales/fa-IR.cbor diff --git a/archive/locales/fi-FI.cbor b/crates/hayagriva-archive/archive/locales/fi-FI.cbor similarity index 100% rename from archive/locales/fi-FI.cbor rename to crates/hayagriva-archive/archive/locales/fi-FI.cbor diff --git a/archive/locales/fr-CA.cbor b/crates/hayagriva-archive/archive/locales/fr-CA.cbor similarity index 100% rename from archive/locales/fr-CA.cbor rename to crates/hayagriva-archive/archive/locales/fr-CA.cbor diff --git a/archive/locales/fr-FR.cbor b/crates/hayagriva-archive/archive/locales/fr-FR.cbor similarity index 100% rename from archive/locales/fr-FR.cbor rename to crates/hayagriva-archive/archive/locales/fr-FR.cbor diff --git a/archive/locales/gl-ES.cbor b/crates/hayagriva-archive/archive/locales/gl-ES.cbor similarity index 100% rename from archive/locales/gl-ES.cbor rename to crates/hayagriva-archive/archive/locales/gl-ES.cbor diff --git a/archive/locales/he-IL.cbor b/crates/hayagriva-archive/archive/locales/he-IL.cbor similarity index 100% rename from archive/locales/he-IL.cbor rename to crates/hayagriva-archive/archive/locales/he-IL.cbor diff --git a/archive/locales/hi-IN.cbor b/crates/hayagriva-archive/archive/locales/hi-IN.cbor similarity index 100% rename from archive/locales/hi-IN.cbor rename to crates/hayagriva-archive/archive/locales/hi-IN.cbor diff --git a/archive/locales/hr-HR.cbor b/crates/hayagriva-archive/archive/locales/hr-HR.cbor similarity index 100% rename from archive/locales/hr-HR.cbor rename to crates/hayagriva-archive/archive/locales/hr-HR.cbor diff --git a/archive/locales/hu-HU.cbor b/crates/hayagriva-archive/archive/locales/hu-HU.cbor similarity index 100% rename from archive/locales/hu-HU.cbor rename to crates/hayagriva-archive/archive/locales/hu-HU.cbor diff --git a/archive/locales/hy-AM.cbor b/crates/hayagriva-archive/archive/locales/hy-AM.cbor similarity index 100% rename from archive/locales/hy-AM.cbor rename to crates/hayagriva-archive/archive/locales/hy-AM.cbor diff --git a/archive/locales/id-ID.cbor b/crates/hayagriva-archive/archive/locales/id-ID.cbor similarity index 100% rename from archive/locales/id-ID.cbor rename to crates/hayagriva-archive/archive/locales/id-ID.cbor diff --git a/archive/locales/is-IS.cbor b/crates/hayagriva-archive/archive/locales/is-IS.cbor similarity index 100% rename from archive/locales/is-IS.cbor rename to crates/hayagriva-archive/archive/locales/is-IS.cbor diff --git a/archive/locales/it-IT.cbor b/crates/hayagriva-archive/archive/locales/it-IT.cbor similarity index 100% rename from archive/locales/it-IT.cbor rename to crates/hayagriva-archive/archive/locales/it-IT.cbor diff --git a/archive/locales/ja-JP.cbor b/crates/hayagriva-archive/archive/locales/ja-JP.cbor similarity index 100% rename from archive/locales/ja-JP.cbor rename to crates/hayagriva-archive/archive/locales/ja-JP.cbor diff --git a/archive/locales/km-KH.cbor b/crates/hayagriva-archive/archive/locales/km-KH.cbor similarity index 100% rename from archive/locales/km-KH.cbor rename to crates/hayagriva-archive/archive/locales/km-KH.cbor diff --git a/archive/locales/ko-KR.cbor b/crates/hayagriva-archive/archive/locales/ko-KR.cbor similarity index 100% rename from archive/locales/ko-KR.cbor rename to crates/hayagriva-archive/archive/locales/ko-KR.cbor diff --git a/archive/locales/la.cbor b/crates/hayagriva-archive/archive/locales/la.cbor similarity index 100% rename from archive/locales/la.cbor rename to crates/hayagriva-archive/archive/locales/la.cbor diff --git a/archive/locales/lij-IT.cbor b/crates/hayagriva-archive/archive/locales/lij-IT.cbor similarity index 100% rename from archive/locales/lij-IT.cbor rename to crates/hayagriva-archive/archive/locales/lij-IT.cbor diff --git a/archive/locales/lt-LT.cbor b/crates/hayagriva-archive/archive/locales/lt-LT.cbor similarity index 100% rename from archive/locales/lt-LT.cbor rename to crates/hayagriva-archive/archive/locales/lt-LT.cbor diff --git a/archive/locales/lv-LV.cbor b/crates/hayagriva-archive/archive/locales/lv-LV.cbor similarity index 100% rename from archive/locales/lv-LV.cbor rename to crates/hayagriva-archive/archive/locales/lv-LV.cbor diff --git a/archive/locales/mn-MN.cbor b/crates/hayagriva-archive/archive/locales/mn-MN.cbor similarity index 100% rename from archive/locales/mn-MN.cbor rename to crates/hayagriva-archive/archive/locales/mn-MN.cbor diff --git a/archive/locales/ms-MY.cbor b/crates/hayagriva-archive/archive/locales/ms-MY.cbor similarity index 100% rename from archive/locales/ms-MY.cbor rename to crates/hayagriva-archive/archive/locales/ms-MY.cbor diff --git a/archive/locales/nb-NO.cbor b/crates/hayagriva-archive/archive/locales/nb-NO.cbor similarity index 100% rename from archive/locales/nb-NO.cbor rename to crates/hayagriva-archive/archive/locales/nb-NO.cbor diff --git a/archive/locales/nl-NL.cbor b/crates/hayagriva-archive/archive/locales/nl-NL.cbor similarity index 100% rename from archive/locales/nl-NL.cbor rename to crates/hayagriva-archive/archive/locales/nl-NL.cbor diff --git a/archive/locales/nn-NO.cbor b/crates/hayagriva-archive/archive/locales/nn-NO.cbor similarity index 100% rename from archive/locales/nn-NO.cbor rename to crates/hayagriva-archive/archive/locales/nn-NO.cbor diff --git a/archive/locales/pa-PK.cbor b/crates/hayagriva-archive/archive/locales/pa-PK.cbor similarity index 100% rename from archive/locales/pa-PK.cbor rename to crates/hayagriva-archive/archive/locales/pa-PK.cbor diff --git a/archive/locales/pl-PL.cbor b/crates/hayagriva-archive/archive/locales/pl-PL.cbor similarity index 100% rename from archive/locales/pl-PL.cbor rename to crates/hayagriva-archive/archive/locales/pl-PL.cbor diff --git a/archive/locales/pt-BR.cbor b/crates/hayagriva-archive/archive/locales/pt-BR.cbor similarity index 100% rename from archive/locales/pt-BR.cbor rename to crates/hayagriva-archive/archive/locales/pt-BR.cbor diff --git a/archive/locales/pt-PT.cbor b/crates/hayagriva-archive/archive/locales/pt-PT.cbor similarity index 100% rename from archive/locales/pt-PT.cbor rename to crates/hayagriva-archive/archive/locales/pt-PT.cbor diff --git a/archive/locales/ro-RO.cbor b/crates/hayagriva-archive/archive/locales/ro-RO.cbor similarity index 100% rename from archive/locales/ro-RO.cbor rename to crates/hayagriva-archive/archive/locales/ro-RO.cbor diff --git a/archive/locales/ru-RU.cbor b/crates/hayagriva-archive/archive/locales/ru-RU.cbor similarity index 100% rename from archive/locales/ru-RU.cbor rename to crates/hayagriva-archive/archive/locales/ru-RU.cbor diff --git a/archive/locales/sk-SK.cbor b/crates/hayagriva-archive/archive/locales/sk-SK.cbor similarity index 100% rename from archive/locales/sk-SK.cbor rename to crates/hayagriva-archive/archive/locales/sk-SK.cbor diff --git a/archive/locales/sl-SI.cbor b/crates/hayagriva-archive/archive/locales/sl-SI.cbor similarity index 100% rename from archive/locales/sl-SI.cbor rename to crates/hayagriva-archive/archive/locales/sl-SI.cbor diff --git a/archive/locales/sr-Cyrl-RS.cbor b/crates/hayagriva-archive/archive/locales/sr-Cyrl-RS.cbor similarity index 100% rename from archive/locales/sr-Cyrl-RS.cbor rename to crates/hayagriva-archive/archive/locales/sr-Cyrl-RS.cbor diff --git a/archive/locales/sr-Latn-RS.cbor b/crates/hayagriva-archive/archive/locales/sr-Latn-RS.cbor similarity index 100% rename from archive/locales/sr-Latn-RS.cbor rename to crates/hayagriva-archive/archive/locales/sr-Latn-RS.cbor diff --git a/archive/locales/sr-RS.cbor b/crates/hayagriva-archive/archive/locales/sr-RS.cbor similarity index 100% rename from archive/locales/sr-RS.cbor rename to crates/hayagriva-archive/archive/locales/sr-RS.cbor diff --git a/archive/locales/sv-SE.cbor b/crates/hayagriva-archive/archive/locales/sv-SE.cbor similarity index 100% rename from archive/locales/sv-SE.cbor rename to crates/hayagriva-archive/archive/locales/sv-SE.cbor diff --git a/archive/locales/th-TH.cbor b/crates/hayagriva-archive/archive/locales/th-TH.cbor similarity index 100% rename from archive/locales/th-TH.cbor rename to crates/hayagriva-archive/archive/locales/th-TH.cbor diff --git a/archive/locales/tl-PH.cbor b/crates/hayagriva-archive/archive/locales/tl-PH.cbor similarity index 100% rename from archive/locales/tl-PH.cbor rename to crates/hayagriva-archive/archive/locales/tl-PH.cbor diff --git a/archive/locales/tr-TR.cbor b/crates/hayagriva-archive/archive/locales/tr-TR.cbor similarity index 100% rename from archive/locales/tr-TR.cbor rename to crates/hayagriva-archive/archive/locales/tr-TR.cbor diff --git a/archive/locales/uk-UA.cbor b/crates/hayagriva-archive/archive/locales/uk-UA.cbor similarity index 100% rename from archive/locales/uk-UA.cbor rename to crates/hayagriva-archive/archive/locales/uk-UA.cbor diff --git a/archive/locales/vi-VN.cbor b/crates/hayagriva-archive/archive/locales/vi-VN.cbor similarity index 100% rename from archive/locales/vi-VN.cbor rename to crates/hayagriva-archive/archive/locales/vi-VN.cbor diff --git a/archive/locales/zh-CN.cbor b/crates/hayagriva-archive/archive/locales/zh-CN.cbor similarity index 100% rename from archive/locales/zh-CN.cbor rename to crates/hayagriva-archive/archive/locales/zh-CN.cbor diff --git a/archive/locales/zh-TW.cbor b/crates/hayagriva-archive/archive/locales/zh-TW.cbor similarity index 100% rename from archive/locales/zh-TW.cbor rename to crates/hayagriva-archive/archive/locales/zh-TW.cbor diff --git a/archive/styles/alphanumeric.cbor b/crates/hayagriva-archive/archive/styles/alphanumeric.cbor similarity index 100% rename from archive/styles/alphanumeric.cbor rename to crates/hayagriva-archive/archive/styles/alphanumeric.cbor diff --git a/archive/styles/american-anthropological-association.cbor b/crates/hayagriva-archive/archive/styles/american-anthropological-association.cbor similarity index 100% rename from archive/styles/american-anthropological-association.cbor rename to crates/hayagriva-archive/archive/styles/american-anthropological-association.cbor diff --git a/archive/styles/american-chemical-society.cbor b/crates/hayagriva-archive/archive/styles/american-chemical-society.cbor similarity index 100% rename from archive/styles/american-chemical-society.cbor rename to crates/hayagriva-archive/archive/styles/american-chemical-society.cbor diff --git a/archive/styles/american-geophysical-union.cbor b/crates/hayagriva-archive/archive/styles/american-geophysical-union.cbor similarity index 100% rename from archive/styles/american-geophysical-union.cbor rename to crates/hayagriva-archive/archive/styles/american-geophysical-union.cbor diff --git a/archive/styles/american-institute-of-aeronautics-and-astronautics.cbor b/crates/hayagriva-archive/archive/styles/american-institute-of-aeronautics-and-astronautics.cbor similarity index 100% rename from archive/styles/american-institute-of-aeronautics-and-astronautics.cbor rename to crates/hayagriva-archive/archive/styles/american-institute-of-aeronautics-and-astronautics.cbor diff --git a/archive/styles/american-institute-of-physics.cbor b/crates/hayagriva-archive/archive/styles/american-institute-of-physics.cbor similarity index 100% rename from archive/styles/american-institute-of-physics.cbor rename to crates/hayagriva-archive/archive/styles/american-institute-of-physics.cbor diff --git a/archive/styles/american-mathematical-society-label.cbor b/crates/hayagriva-archive/archive/styles/american-mathematical-society-label.cbor similarity index 100% rename from archive/styles/american-mathematical-society-label.cbor rename to crates/hayagriva-archive/archive/styles/american-mathematical-society-label.cbor diff --git a/archive/styles/american-mathematical-society-numeric.cbor b/crates/hayagriva-archive/archive/styles/american-mathematical-society-numeric.cbor similarity index 100% rename from archive/styles/american-mathematical-society-numeric.cbor rename to crates/hayagriva-archive/archive/styles/american-mathematical-society-numeric.cbor diff --git a/archive/styles/american-medical-association.cbor b/crates/hayagriva-archive/archive/styles/american-medical-association.cbor similarity index 100% rename from archive/styles/american-medical-association.cbor rename to crates/hayagriva-archive/archive/styles/american-medical-association.cbor diff --git a/archive/styles/american-meteorological-society.cbor b/crates/hayagriva-archive/archive/styles/american-meteorological-society.cbor similarity index 100% rename from archive/styles/american-meteorological-society.cbor rename to crates/hayagriva-archive/archive/styles/american-meteorological-society.cbor diff --git a/archive/styles/american-physics-society.cbor b/crates/hayagriva-archive/archive/styles/american-physics-society.cbor similarity index 100% rename from archive/styles/american-physics-society.cbor rename to crates/hayagriva-archive/archive/styles/american-physics-society.cbor diff --git a/archive/styles/american-physiological-society.cbor b/crates/hayagriva-archive/archive/styles/american-physiological-society.cbor similarity index 100% rename from archive/styles/american-physiological-society.cbor rename to crates/hayagriva-archive/archive/styles/american-physiological-society.cbor diff --git a/archive/styles/american-political-science-association.cbor b/crates/hayagriva-archive/archive/styles/american-political-science-association.cbor similarity index 100% rename from archive/styles/american-political-science-association.cbor rename to crates/hayagriva-archive/archive/styles/american-political-science-association.cbor diff --git a/archive/styles/american-society-for-microbiology.cbor b/crates/hayagriva-archive/archive/styles/american-society-for-microbiology.cbor similarity index 100% rename from archive/styles/american-society-for-microbiology.cbor rename to crates/hayagriva-archive/archive/styles/american-society-for-microbiology.cbor diff --git a/archive/styles/american-society-of-civil-engineers.cbor b/crates/hayagriva-archive/archive/styles/american-society-of-civil-engineers.cbor similarity index 100% rename from archive/styles/american-society-of-civil-engineers.cbor rename to crates/hayagriva-archive/archive/styles/american-society-of-civil-engineers.cbor diff --git a/archive/styles/american-society-of-mechanical-engineers.cbor b/crates/hayagriva-archive/archive/styles/american-society-of-mechanical-engineers.cbor similarity index 100% rename from archive/styles/american-society-of-mechanical-engineers.cbor rename to crates/hayagriva-archive/archive/styles/american-society-of-mechanical-engineers.cbor diff --git a/archive/styles/american-sociological-association.cbor b/crates/hayagriva-archive/archive/styles/american-sociological-association.cbor similarity index 100% rename from archive/styles/american-sociological-association.cbor rename to crates/hayagriva-archive/archive/styles/american-sociological-association.cbor diff --git a/archive/styles/angewandte-chemie.cbor b/crates/hayagriva-archive/archive/styles/angewandte-chemie.cbor similarity index 100% rename from archive/styles/angewandte-chemie.cbor rename to crates/hayagriva-archive/archive/styles/angewandte-chemie.cbor diff --git a/archive/styles/annual-reviews-author-date.cbor b/crates/hayagriva-archive/archive/styles/annual-reviews-author-date.cbor similarity index 100% rename from archive/styles/annual-reviews-author-date.cbor rename to crates/hayagriva-archive/archive/styles/annual-reviews-author-date.cbor diff --git a/archive/styles/annual-reviews.cbor b/crates/hayagriva-archive/archive/styles/annual-reviews.cbor similarity index 100% rename from archive/styles/annual-reviews.cbor rename to crates/hayagriva-archive/archive/styles/annual-reviews.cbor diff --git a/archive/styles/apa.cbor b/crates/hayagriva-archive/archive/styles/apa.cbor similarity index 100% rename from archive/styles/apa.cbor rename to crates/hayagriva-archive/archive/styles/apa.cbor diff --git a/archive/styles/associacao-brasileira-de-normas-tecnicas.cbor b/crates/hayagriva-archive/archive/styles/associacao-brasileira-de-normas-tecnicas.cbor similarity index 100% rename from archive/styles/associacao-brasileira-de-normas-tecnicas.cbor rename to crates/hayagriva-archive/archive/styles/associacao-brasileira-de-normas-tecnicas.cbor diff --git a/archive/styles/association-for-computing-machinery.cbor b/crates/hayagriva-archive/archive/styles/association-for-computing-machinery.cbor similarity index 100% rename from archive/styles/association-for-computing-machinery.cbor rename to crates/hayagriva-archive/archive/styles/association-for-computing-machinery.cbor diff --git a/archive/styles/biomed-central.cbor b/crates/hayagriva-archive/archive/styles/biomed-central.cbor similarity index 100% rename from archive/styles/biomed-central.cbor rename to crates/hayagriva-archive/archive/styles/biomed-central.cbor diff --git a/archive/styles/bmj.cbor b/crates/hayagriva-archive/archive/styles/bmj.cbor similarity index 100% rename from archive/styles/bmj.cbor rename to crates/hayagriva-archive/archive/styles/bmj.cbor diff --git a/archive/styles/bristol-university-press.cbor b/crates/hayagriva-archive/archive/styles/bristol-university-press.cbor similarity index 100% rename from archive/styles/bristol-university-press.cbor rename to crates/hayagriva-archive/archive/styles/bristol-university-press.cbor diff --git a/archive/styles/cell.cbor b/crates/hayagriva-archive/archive/styles/cell.cbor similarity index 100% rename from archive/styles/cell.cbor rename to crates/hayagriva-archive/archive/styles/cell.cbor diff --git a/archive/styles/chicago-author-date-17th-edition.cbor b/crates/hayagriva-archive/archive/styles/chicago-author-date-17th-edition.cbor similarity index 100% rename from archive/styles/chicago-author-date-17th-edition.cbor rename to crates/hayagriva-archive/archive/styles/chicago-author-date-17th-edition.cbor diff --git a/archive/styles/chicago-author-date.cbor b/crates/hayagriva-archive/archive/styles/chicago-author-date.cbor similarity index 100% rename from archive/styles/chicago-author-date.cbor rename to crates/hayagriva-archive/archive/styles/chicago-author-date.cbor diff --git a/archive/styles/chicago-fullnote-bibliography.cbor b/crates/hayagriva-archive/archive/styles/chicago-fullnote-bibliography.cbor similarity index 100% rename from archive/styles/chicago-fullnote-bibliography.cbor rename to crates/hayagriva-archive/archive/styles/chicago-fullnote-bibliography.cbor diff --git a/archive/styles/chicago-note-bibliography.cbor b/crates/hayagriva-archive/archive/styles/chicago-note-bibliography.cbor similarity index 100% rename from archive/styles/chicago-note-bibliography.cbor rename to crates/hayagriva-archive/archive/styles/chicago-note-bibliography.cbor diff --git a/archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor b/crates/hayagriva-archive/archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor similarity index 100% rename from archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor rename to crates/hayagriva-archive/archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor diff --git a/archive/styles/chicago-notes-bibliography.cbor b/crates/hayagriva-archive/archive/styles/chicago-notes-bibliography.cbor similarity index 100% rename from archive/styles/chicago-notes-bibliography.cbor rename to crates/hayagriva-archive/archive/styles/chicago-notes-bibliography.cbor diff --git a/archive/styles/chicago-shortened-notes-bibliography.cbor b/crates/hayagriva-archive/archive/styles/chicago-shortened-notes-bibliography.cbor similarity index 100% rename from archive/styles/chicago-shortened-notes-bibliography.cbor rename to crates/hayagriva-archive/archive/styles/chicago-shortened-notes-bibliography.cbor diff --git a/archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor b/crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor similarity index 100% rename from archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor rename to crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor diff --git a/archive/styles/china-national-standard-gb-t-7714-2015-note.cbor b/crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-note.cbor similarity index 100% rename from archive/styles/china-national-standard-gb-t-7714-2015-note.cbor rename to crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-note.cbor diff --git a/archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor b/crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor similarity index 100% rename from archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor rename to crates/hayagriva-archive/archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor diff --git a/archive/styles/chinese-gb7714-2005-numeric.cbor b/crates/hayagriva-archive/archive/styles/chinese-gb7714-2005-numeric.cbor similarity index 100% rename from archive/styles/chinese-gb7714-2005-numeric.cbor rename to crates/hayagriva-archive/archive/styles/chinese-gb7714-2005-numeric.cbor diff --git a/archive/styles/copernicus-publications.cbor b/crates/hayagriva-archive/archive/styles/copernicus-publications.cbor similarity index 100% rename from archive/styles/copernicus-publications.cbor rename to crates/hayagriva-archive/archive/styles/copernicus-publications.cbor diff --git a/archive/styles/council-of-science-editors-author-date.cbor b/crates/hayagriva-archive/archive/styles/council-of-science-editors-author-date.cbor similarity index 100% rename from archive/styles/council-of-science-editors-author-date.cbor rename to crates/hayagriva-archive/archive/styles/council-of-science-editors-author-date.cbor diff --git a/archive/styles/council-of-science-editors-brackets.cbor b/crates/hayagriva-archive/archive/styles/council-of-science-editors-brackets.cbor similarity index 100% rename from archive/styles/council-of-science-editors-brackets.cbor rename to crates/hayagriva-archive/archive/styles/council-of-science-editors-brackets.cbor diff --git a/archive/styles/cse-citation-sequence-brackets-8th-edition.cbor b/crates/hayagriva-archive/archive/styles/cse-citation-sequence-brackets-8th-edition.cbor similarity index 100% rename from archive/styles/cse-citation-sequence-brackets-8th-edition.cbor rename to crates/hayagriva-archive/archive/styles/cse-citation-sequence-brackets-8th-edition.cbor diff --git a/archive/styles/cse-name-year.cbor b/crates/hayagriva-archive/archive/styles/cse-name-year.cbor similarity index 100% rename from archive/styles/cse-name-year.cbor rename to crates/hayagriva-archive/archive/styles/cse-name-year.cbor diff --git a/archive/styles/current-opinion.cbor b/crates/hayagriva-archive/archive/styles/current-opinion.cbor similarity index 100% rename from archive/styles/current-opinion.cbor rename to crates/hayagriva-archive/archive/styles/current-opinion.cbor diff --git a/archive/styles/deutsche-gesellschaft-fur-psychologie.cbor b/crates/hayagriva-archive/archive/styles/deutsche-gesellschaft-fur-psychologie.cbor similarity index 100% rename from archive/styles/deutsche-gesellschaft-fur-psychologie.cbor rename to crates/hayagriva-archive/archive/styles/deutsche-gesellschaft-fur-psychologie.cbor diff --git a/archive/styles/deutsche-sprache.cbor b/crates/hayagriva-archive/archive/styles/deutsche-sprache.cbor similarity index 100% rename from archive/styles/deutsche-sprache.cbor rename to crates/hayagriva-archive/archive/styles/deutsche-sprache.cbor diff --git a/archive/styles/elsevier-harvard.cbor b/crates/hayagriva-archive/archive/styles/elsevier-harvard.cbor similarity index 100% rename from archive/styles/elsevier-harvard.cbor rename to crates/hayagriva-archive/archive/styles/elsevier-harvard.cbor diff --git a/archive/styles/elsevier-vancouver.cbor b/crates/hayagriva-archive/archive/styles/elsevier-vancouver.cbor similarity index 100% rename from archive/styles/elsevier-vancouver.cbor rename to crates/hayagriva-archive/archive/styles/elsevier-vancouver.cbor diff --git a/archive/styles/elsevier-with-titles.cbor b/crates/hayagriva-archive/archive/styles/elsevier-with-titles.cbor similarity index 100% rename from archive/styles/elsevier-with-titles.cbor rename to crates/hayagriva-archive/archive/styles/elsevier-with-titles.cbor diff --git a/archive/styles/frontiers.cbor b/crates/hayagriva-archive/archive/styles/frontiers.cbor similarity index 100% rename from archive/styles/frontiers.cbor rename to crates/hayagriva-archive/archive/styles/frontiers.cbor diff --git a/archive/styles/future-medicine.cbor b/crates/hayagriva-archive/archive/styles/future-medicine.cbor similarity index 100% rename from archive/styles/future-medicine.cbor rename to crates/hayagriva-archive/archive/styles/future-medicine.cbor diff --git a/archive/styles/future-science-group.cbor b/crates/hayagriva-archive/archive/styles/future-science-group.cbor similarity index 100% rename from archive/styles/future-science-group.cbor rename to crates/hayagriva-archive/archive/styles/future-science-group.cbor diff --git a/archive/styles/gost-r-7-0-5-2008-numeric.cbor b/crates/hayagriva-archive/archive/styles/gost-r-7-0-5-2008-numeric.cbor similarity index 100% rename from archive/styles/gost-r-7-0-5-2008-numeric.cbor rename to crates/hayagriva-archive/archive/styles/gost-r-7-0-5-2008-numeric.cbor diff --git a/archive/styles/harvard-cite-them-right.cbor b/crates/hayagriva-archive/archive/styles/harvard-cite-them-right.cbor similarity index 100% rename from archive/styles/harvard-cite-them-right.cbor rename to crates/hayagriva-archive/archive/styles/harvard-cite-them-right.cbor diff --git a/archive/styles/ieee.cbor b/crates/hayagriva-archive/archive/styles/ieee.cbor similarity index 100% rename from archive/styles/ieee.cbor rename to crates/hayagriva-archive/archive/styles/ieee.cbor diff --git a/archive/styles/institute-of-physics-numeric.cbor b/crates/hayagriva-archive/archive/styles/institute-of-physics-numeric.cbor similarity index 100% rename from archive/styles/institute-of-physics-numeric.cbor rename to crates/hayagriva-archive/archive/styles/institute-of-physics-numeric.cbor diff --git a/archive/styles/iso690-author-date-en.cbor b/crates/hayagriva-archive/archive/styles/iso690-author-date-en.cbor similarity index 100% rename from archive/styles/iso690-author-date-en.cbor rename to crates/hayagriva-archive/archive/styles/iso690-author-date-en.cbor diff --git a/archive/styles/iso690-numeric-en.cbor b/crates/hayagriva-archive/archive/styles/iso690-numeric-en.cbor similarity index 100% rename from archive/styles/iso690-numeric-en.cbor rename to crates/hayagriva-archive/archive/styles/iso690-numeric-en.cbor diff --git a/archive/styles/karger-journals.cbor b/crates/hayagriva-archive/archive/styles/karger-journals.cbor similarity index 100% rename from archive/styles/karger-journals.cbor rename to crates/hayagriva-archive/archive/styles/karger-journals.cbor diff --git a/archive/styles/mary-ann-liebert-vancouver.cbor b/crates/hayagriva-archive/archive/styles/mary-ann-liebert-vancouver.cbor similarity index 100% rename from archive/styles/mary-ann-liebert-vancouver.cbor rename to crates/hayagriva-archive/archive/styles/mary-ann-liebert-vancouver.cbor diff --git a/archive/styles/mhra-notes.cbor b/crates/hayagriva-archive/archive/styles/mhra-notes.cbor similarity index 100% rename from archive/styles/mhra-notes.cbor rename to crates/hayagriva-archive/archive/styles/mhra-notes.cbor diff --git a/archive/styles/modern-humanities-research-association-notes.cbor b/crates/hayagriva-archive/archive/styles/modern-humanities-research-association-notes.cbor similarity index 100% rename from archive/styles/modern-humanities-research-association-notes.cbor rename to crates/hayagriva-archive/archive/styles/modern-humanities-research-association-notes.cbor diff --git a/archive/styles/modern-humanities-research-association.cbor b/crates/hayagriva-archive/archive/styles/modern-humanities-research-association.cbor similarity index 100% rename from archive/styles/modern-humanities-research-association.cbor rename to crates/hayagriva-archive/archive/styles/modern-humanities-research-association.cbor diff --git a/archive/styles/modern-language-association-8th-edition.cbor b/crates/hayagriva-archive/archive/styles/modern-language-association-8th-edition.cbor similarity index 100% rename from archive/styles/modern-language-association-8th-edition.cbor rename to crates/hayagriva-archive/archive/styles/modern-language-association-8th-edition.cbor diff --git a/archive/styles/modern-language-association.cbor b/crates/hayagriva-archive/archive/styles/modern-language-association.cbor similarity index 100% rename from archive/styles/modern-language-association.cbor rename to crates/hayagriva-archive/archive/styles/modern-language-association.cbor diff --git a/archive/styles/multidisciplinary-digital-publishing-institute.cbor b/crates/hayagriva-archive/archive/styles/multidisciplinary-digital-publishing-institute.cbor similarity index 100% rename from archive/styles/multidisciplinary-digital-publishing-institute.cbor rename to crates/hayagriva-archive/archive/styles/multidisciplinary-digital-publishing-institute.cbor diff --git a/archive/styles/nature.cbor b/crates/hayagriva-archive/archive/styles/nature.cbor similarity index 100% rename from archive/styles/nature.cbor rename to crates/hayagriva-archive/archive/styles/nature.cbor diff --git a/archive/styles/nlm-citation-sequence-superscript.cbor b/crates/hayagriva-archive/archive/styles/nlm-citation-sequence-superscript.cbor similarity index 100% rename from archive/styles/nlm-citation-sequence-superscript.cbor rename to crates/hayagriva-archive/archive/styles/nlm-citation-sequence-superscript.cbor diff --git a/archive/styles/nlm-citation-sequence.cbor b/crates/hayagriva-archive/archive/styles/nlm-citation-sequence.cbor similarity index 100% rename from archive/styles/nlm-citation-sequence.cbor rename to crates/hayagriva-archive/archive/styles/nlm-citation-sequence.cbor diff --git a/archive/styles/pensoft-journals.cbor b/crates/hayagriva-archive/archive/styles/pensoft-journals.cbor similarity index 100% rename from archive/styles/pensoft-journals.cbor rename to crates/hayagriva-archive/archive/styles/pensoft-journals.cbor diff --git a/archive/styles/plos.cbor b/crates/hayagriva-archive/archive/styles/plos.cbor similarity index 100% rename from archive/styles/plos.cbor rename to crates/hayagriva-archive/archive/styles/plos.cbor diff --git a/archive/styles/royal-society-of-chemistry.cbor b/crates/hayagriva-archive/archive/styles/royal-society-of-chemistry.cbor similarity index 100% rename from archive/styles/royal-society-of-chemistry.cbor rename to crates/hayagriva-archive/archive/styles/royal-society-of-chemistry.cbor diff --git a/archive/styles/sage-vancouver.cbor b/crates/hayagriva-archive/archive/styles/sage-vancouver.cbor similarity index 100% rename from archive/styles/sage-vancouver.cbor rename to crates/hayagriva-archive/archive/styles/sage-vancouver.cbor diff --git a/archive/styles/sist02.cbor b/crates/hayagriva-archive/archive/styles/sist02.cbor similarity index 100% rename from archive/styles/sist02.cbor rename to crates/hayagriva-archive/archive/styles/sist02.cbor diff --git a/archive/styles/spie-journals.cbor b/crates/hayagriva-archive/archive/styles/spie-journals.cbor similarity index 100% rename from archive/styles/spie-journals.cbor rename to crates/hayagriva-archive/archive/styles/spie-journals.cbor diff --git a/archive/styles/springer-basic-author-date.cbor b/crates/hayagriva-archive/archive/styles/springer-basic-author-date.cbor similarity index 100% rename from archive/styles/springer-basic-author-date.cbor rename to crates/hayagriva-archive/archive/styles/springer-basic-author-date.cbor diff --git a/archive/styles/springer-basic-brackets.cbor b/crates/hayagriva-archive/archive/styles/springer-basic-brackets.cbor similarity index 100% rename from archive/styles/springer-basic-brackets.cbor rename to crates/hayagriva-archive/archive/styles/springer-basic-brackets.cbor diff --git a/archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor b/crates/hayagriva-archive/archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor similarity index 100% rename from archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor rename to crates/hayagriva-archive/archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor diff --git a/archive/styles/springer-humanities-author-date.cbor b/crates/hayagriva-archive/archive/styles/springer-humanities-author-date.cbor similarity index 100% rename from archive/styles/springer-humanities-author-date.cbor rename to crates/hayagriva-archive/archive/styles/springer-humanities-author-date.cbor diff --git a/archive/styles/springer-lecture-notes-in-computer-science.cbor b/crates/hayagriva-archive/archive/styles/springer-lecture-notes-in-computer-science.cbor similarity index 100% rename from archive/styles/springer-lecture-notes-in-computer-science.cbor rename to crates/hayagriva-archive/archive/styles/springer-lecture-notes-in-computer-science.cbor diff --git a/archive/styles/springer-mathphys-brackets.cbor b/crates/hayagriva-archive/archive/styles/springer-mathphys-brackets.cbor similarity index 100% rename from archive/styles/springer-mathphys-brackets.cbor rename to crates/hayagriva-archive/archive/styles/springer-mathphys-brackets.cbor diff --git a/archive/styles/springer-socpsych-author-date.cbor b/crates/hayagriva-archive/archive/styles/springer-socpsych-author-date.cbor similarity index 100% rename from archive/styles/springer-socpsych-author-date.cbor rename to crates/hayagriva-archive/archive/styles/springer-socpsych-author-date.cbor diff --git a/archive/styles/springer-vancouver-brackets.cbor b/crates/hayagriva-archive/archive/styles/springer-vancouver-brackets.cbor similarity index 100% rename from archive/styles/springer-vancouver-brackets.cbor rename to crates/hayagriva-archive/archive/styles/springer-vancouver-brackets.cbor diff --git a/archive/styles/taylor-and-francis-chicago-author-date.cbor b/crates/hayagriva-archive/archive/styles/taylor-and-francis-chicago-author-date.cbor similarity index 100% rename from archive/styles/taylor-and-francis-chicago-author-date.cbor rename to crates/hayagriva-archive/archive/styles/taylor-and-francis-chicago-author-date.cbor diff --git a/archive/styles/taylor-and-francis-national-library-of-medicine.cbor b/crates/hayagriva-archive/archive/styles/taylor-and-francis-national-library-of-medicine.cbor similarity index 100% rename from archive/styles/taylor-and-francis-national-library-of-medicine.cbor rename to crates/hayagriva-archive/archive/styles/taylor-and-francis-national-library-of-medicine.cbor diff --git a/archive/styles/the-institution-of-engineering-and-technology.cbor b/crates/hayagriva-archive/archive/styles/the-institution-of-engineering-and-technology.cbor similarity index 100% rename from archive/styles/the-institution-of-engineering-and-technology.cbor rename to crates/hayagriva-archive/archive/styles/the-institution-of-engineering-and-technology.cbor diff --git a/archive/styles/the-lancet.cbor b/crates/hayagriva-archive/archive/styles/the-lancet.cbor similarity index 100% rename from archive/styles/the-lancet.cbor rename to crates/hayagriva-archive/archive/styles/the-lancet.cbor diff --git a/archive/styles/thieme-german.cbor b/crates/hayagriva-archive/archive/styles/thieme-german.cbor similarity index 100% rename from archive/styles/thieme-german.cbor rename to crates/hayagriva-archive/archive/styles/thieme-german.cbor diff --git a/archive/styles/trends-journals.cbor b/crates/hayagriva-archive/archive/styles/trends-journals.cbor similarity index 100% rename from archive/styles/trends-journals.cbor rename to crates/hayagriva-archive/archive/styles/trends-journals.cbor diff --git a/archive/styles/turabian-author-date.cbor b/crates/hayagriva-archive/archive/styles/turabian-author-date.cbor similarity index 100% rename from archive/styles/turabian-author-date.cbor rename to crates/hayagriva-archive/archive/styles/turabian-author-date.cbor diff --git a/archive/styles/turabian-fullnote-bibliography-8th-edition.cbor b/crates/hayagriva-archive/archive/styles/turabian-fullnote-bibliography-8th-edition.cbor similarity index 100% rename from archive/styles/turabian-fullnote-bibliography-8th-edition.cbor rename to crates/hayagriva-archive/archive/styles/turabian-fullnote-bibliography-8th-edition.cbor diff --git a/archive/styles/vancouver-superscript.cbor b/crates/hayagriva-archive/archive/styles/vancouver-superscript.cbor similarity index 100% rename from archive/styles/vancouver-superscript.cbor rename to crates/hayagriva-archive/archive/styles/vancouver-superscript.cbor diff --git a/archive/styles/vancouver.cbor b/crates/hayagriva-archive/archive/styles/vancouver.cbor similarity index 100% rename from archive/styles/vancouver.cbor rename to crates/hayagriva-archive/archive/styles/vancouver.cbor diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index 782ef313..845cb65a 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -623,88 +623,88 @@ impl ArchivedStyle { /// Get the CBOR representation of this style. fn bytes(self) -> &'static [u8] { match self { - Self::Alphanumeric => include_bytes!("../../../archive/styles/alphanumeric.cbor"), - Self::AmericanAnthropologicalAssociation => include_bytes!("../../../archive/styles/american-anthropological-association.cbor"), - Self::AmericanChemicalSociety => include_bytes!("../../../archive/styles/american-chemical-society.cbor"), - Self::AmericanGeophysicalUnion => include_bytes!("../../../archive/styles/american-geophysical-union.cbor"), - Self::AmericanInstituteOfAeronauticsAndAstronautics => include_bytes!("../../../archive/styles/american-institute-of-aeronautics-and-astronautics.cbor"), - Self::AmericanInstituteOfPhysics => include_bytes!("../../../archive/styles/american-institute-of-physics.cbor"), - Self::AmericanMathematicalSocietyLabel => include_bytes!("../../../archive/styles/american-mathematical-society-label.cbor"), - Self::AmericanMathematicalSocietyNumeric => include_bytes!("../../../archive/styles/american-mathematical-society-numeric.cbor"), - Self::AmericanMedicalAssociation => include_bytes!("../../../archive/styles/american-medical-association.cbor"), - Self::AmericanMeteorologicalSociety => include_bytes!("../../../archive/styles/american-meteorological-society.cbor"), - Self::AmericanPhysicsSociety => include_bytes!("../../../archive/styles/american-physics-society.cbor"), - Self::AmericanPhysiologicalSociety => include_bytes!("../../../archive/styles/american-physiological-society.cbor"), - Self::AmericanPoliticalScienceAssociation => include_bytes!("../../../archive/styles/american-political-science-association.cbor"), - Self::AmericanPsychologicalAssociation => include_bytes!("../../../archive/styles/apa.cbor"), - Self::AmericanSocietyForMicrobiology => include_bytes!("../../../archive/styles/american-society-for-microbiology.cbor"), - Self::AmericanSocietyOfCivilEngineers => include_bytes!("../../../archive/styles/american-society-of-civil-engineers.cbor"), - Self::AmericanSocietyOfMechanicalEngineers => include_bytes!("../../../archive/styles/american-society-of-mechanical-engineers.cbor"), - Self::AmericanSociologicalAssociation => include_bytes!("../../../archive/styles/american-sociological-association.cbor"), - Self::AngewandteChemie => include_bytes!("../../../archive/styles/angewandte-chemie.cbor"), - Self::AnnualReviews => include_bytes!("../../../archive/styles/annual-reviews.cbor"), - Self::AnnualReviewsAuthorDate => include_bytes!("../../../archive/styles/annual-reviews-author-date.cbor"), - Self::AssociacaoBrasileiraDeNormasTecnicas => include_bytes!("../../../archive/styles/associacao-brasileira-de-normas-tecnicas.cbor"), - Self::AssociationForComputingMachinery => include_bytes!("../../../archive/styles/association-for-computing-machinery.cbor"), - Self::BiomedCentral => include_bytes!("../../../archive/styles/biomed-central.cbor"), - Self::BristolUniversityPress => include_bytes!("../../../archive/styles/bristol-university-press.cbor"), - Self::BritishMedicalJournal => include_bytes!("../../../archive/styles/bmj.cbor"), - Self::Cell => include_bytes!("../../../archive/styles/cell.cbor"), - Self::ChicagoAuthorDate => include_bytes!("../../../archive/styles/chicago-author-date.cbor"), - Self::ChicagoNotes => include_bytes!("../../../archive/styles/chicago-notes-bibliography.cbor"), - Self::ChicagoShortenedNotes => include_bytes!("../../../archive/styles/chicago-shortened-notes-bibliography.cbor"), - Self::Copernicus => include_bytes!("../../../archive/styles/copernicus-publications.cbor"), - Self::CseCitationSequenceBrackets8thEdition => include_bytes!("../../../archive/styles/cse-citation-sequence-brackets-8th-edition.cbor"), - Self::CseNameYear => include_bytes!("../../../archive/styles/cse-name-year.cbor"), - Self::CurrentOpinion => include_bytes!("../../../archive/styles/current-opinion.cbor"), - Self::DeutscheGesellschaftFürPsychologie => include_bytes!("../../../archive/styles/deutsche-gesellschaft-fur-psychologie.cbor"), - Self::DeutscheSprache => include_bytes!("../../../archive/styles/deutsche-sprache.cbor"), - Self::ElsevierHarvard => include_bytes!("../../../archive/styles/elsevier-harvard.cbor"), - Self::ElsevierVancouver => include_bytes!("../../../archive/styles/elsevier-vancouver.cbor"), - Self::ElsevierWithTitles => include_bytes!("../../../archive/styles/elsevier-with-titles.cbor"), - Self::Frontiers => include_bytes!("../../../archive/styles/frontiers.cbor"), - Self::FutureMedicine => include_bytes!("../../../archive/styles/future-medicine.cbor"), - Self::FutureScience => include_bytes!("../../../archive/styles/future-science-group.cbor"), - Self::Gb77142005Numeric => include_bytes!("../../../archive/styles/chinese-gb7714-2005-numeric.cbor"), - Self::Gb77142015AuthorDate => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor"), - Self::Gb77142015Note => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-note.cbor"), - Self::Gb77142015Numeric => include_bytes!("../../../archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor"), - Self::GostR7052008Numeric => include_bytes!("../../../archive/styles/gost-r-7-0-5-2008-numeric.cbor"), - Self::HarvardCiteThemRight => include_bytes!("../../../archive/styles/harvard-cite-them-right.cbor"), - Self::InstituteOfElectricalAndElectronicsEngineers => include_bytes!("../../../archive/styles/ieee.cbor"), - Self::InstituteOfPhysicsNumeric => include_bytes!("../../../archive/styles/institute-of-physics-numeric.cbor"), - Self::Iso690AuthorDate => include_bytes!("../../../archive/styles/iso690-author-date-en.cbor"), - Self::Iso690Numeric => include_bytes!("../../../archive/styles/iso690-numeric-en.cbor"), - Self::Karger => include_bytes!("../../../archive/styles/karger-journals.cbor"), - Self::MaryAnnLiebertVancouver => include_bytes!("../../../archive/styles/mary-ann-liebert-vancouver.cbor"), - Self::ModernHumanitiesResearchAssociationNotes => include_bytes!("../../../archive/styles/mhra-notes.cbor"), - Self::ModernLanguageAssociation => include_bytes!("../../../archive/styles/modern-language-association.cbor"), - Self::MultidisciplinaryDigitalPublishingInstitute => include_bytes!("../../../archive/styles/multidisciplinary-digital-publishing-institute.cbor"), - Self::Nature => include_bytes!("../../../archive/styles/nature.cbor"), - Self::NlmCitationSequence => include_bytes!("../../../archive/styles/nlm-citation-sequence.cbor"), - Self::NlmCitationSequenceSuperscript => include_bytes!("../../../archive/styles/nlm-citation-sequence-superscript.cbor"), - Self::Pensoft => include_bytes!("../../../archive/styles/pensoft-journals.cbor"), - Self::PublicLibraryOfScience => include_bytes!("../../../archive/styles/plos.cbor"), - Self::RoyalSocietyOfChemistry => include_bytes!("../../../archive/styles/royal-society-of-chemistry.cbor"), - Self::SageVancouver => include_bytes!("../../../archive/styles/sage-vancouver.cbor"), - Self::Sist02 => include_bytes!("../../../archive/styles/sist02.cbor"), - Self::Spie => include_bytes!("../../../archive/styles/spie-journals.cbor"), - Self::SpringerBasic => include_bytes!("../../../archive/styles/springer-basic-brackets.cbor"), - Self::SpringerBasicAuthorDate => include_bytes!("../../../archive/styles/springer-basic-author-date.cbor"), - Self::SpringerFachzeitschriftenMedizinPsychologie => include_bytes!("../../../archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor"), - Self::SpringerHumanitiesAuthorDate => include_bytes!("../../../archive/styles/springer-humanities-author-date.cbor"), - Self::SpringerLectureNotesInComputerScience => include_bytes!("../../../archive/styles/springer-lecture-notes-in-computer-science.cbor"), - Self::SpringerMathphys => include_bytes!("../../../archive/styles/springer-mathphys-brackets.cbor"), - Self::SpringerSocpsychAuthorDate => include_bytes!("../../../archive/styles/springer-socpsych-author-date.cbor"), - Self::SpringerVancouver => include_bytes!("../../../archive/styles/springer-vancouver-brackets.cbor"), - Self::TaylorAndFrancisChicagoAuthorDate => include_bytes!("../../../archive/styles/taylor-and-francis-chicago-author-date.cbor"), - Self::TaylorAndFrancisNationalLibraryOfMedicine => include_bytes!("../../../archive/styles/taylor-and-francis-national-library-of-medicine.cbor"), - Self::TheInstitutionOfEngineeringAndTechnology => include_bytes!("../../../archive/styles/the-institution-of-engineering-and-technology.cbor"), - Self::TheLancet => include_bytes!("../../../archive/styles/the-lancet.cbor"), - Self::Thieme => include_bytes!("../../../archive/styles/thieme-german.cbor"), - Self::Trends => include_bytes!("../../../archive/styles/trends-journals.cbor"), - Self::TurabianAuthorDate => include_bytes!("../../../archive/styles/chicago-author-date-17th-edition.cbor"), - Self::TurabianFullnote8 => include_bytes!("../../../archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor"), + Self::Alphanumeric => include_bytes!("../archive/styles/alphanumeric.cbor"), + Self::AmericanAnthropologicalAssociation => include_bytes!("../archive/styles/american-anthropological-association.cbor"), + Self::AmericanChemicalSociety => include_bytes!("../archive/styles/american-chemical-society.cbor"), + Self::AmericanGeophysicalUnion => include_bytes!("../archive/styles/american-geophysical-union.cbor"), + Self::AmericanInstituteOfAeronauticsAndAstronautics => include_bytes!("../archive/styles/american-institute-of-aeronautics-and-astronautics.cbor"), + Self::AmericanInstituteOfPhysics => include_bytes!("../archive/styles/american-institute-of-physics.cbor"), + Self::AmericanMathematicalSocietyLabel => include_bytes!("../archive/styles/american-mathematical-society-label.cbor"), + Self::AmericanMathematicalSocietyNumeric => include_bytes!("../archive/styles/american-mathematical-society-numeric.cbor"), + Self::AmericanMedicalAssociation => include_bytes!("../archive/styles/american-medical-association.cbor"), + Self::AmericanMeteorologicalSociety => include_bytes!("../archive/styles/american-meteorological-society.cbor"), + Self::AmericanPhysicsSociety => include_bytes!("../archive/styles/american-physics-society.cbor"), + Self::AmericanPhysiologicalSociety => include_bytes!("../archive/styles/american-physiological-society.cbor"), + Self::AmericanPoliticalScienceAssociation => include_bytes!("../archive/styles/american-political-science-association.cbor"), + Self::AmericanPsychologicalAssociation => include_bytes!("../archive/styles/apa.cbor"), + Self::AmericanSocietyForMicrobiology => include_bytes!("../archive/styles/american-society-for-microbiology.cbor"), + Self::AmericanSocietyOfCivilEngineers => include_bytes!("../archive/styles/american-society-of-civil-engineers.cbor"), + Self::AmericanSocietyOfMechanicalEngineers => include_bytes!("../archive/styles/american-society-of-mechanical-engineers.cbor"), + Self::AmericanSociologicalAssociation => include_bytes!("../archive/styles/american-sociological-association.cbor"), + Self::AngewandteChemie => include_bytes!("../archive/styles/angewandte-chemie.cbor"), + Self::AnnualReviews => include_bytes!("../archive/styles/annual-reviews.cbor"), + Self::AnnualReviewsAuthorDate => include_bytes!("../archive/styles/annual-reviews-author-date.cbor"), + Self::AssociacaoBrasileiraDeNormasTecnicas => include_bytes!("../archive/styles/associacao-brasileira-de-normas-tecnicas.cbor"), + Self::AssociationForComputingMachinery => include_bytes!("../archive/styles/association-for-computing-machinery.cbor"), + Self::BiomedCentral => include_bytes!("../archive/styles/biomed-central.cbor"), + Self::BristolUniversityPress => include_bytes!("../archive/styles/bristol-university-press.cbor"), + Self::BritishMedicalJournal => include_bytes!("../archive/styles/bmj.cbor"), + Self::Cell => include_bytes!("../archive/styles/cell.cbor"), + Self::ChicagoAuthorDate => include_bytes!("../archive/styles/chicago-author-date.cbor"), + Self::ChicagoNotes => include_bytes!("../archive/styles/chicago-notes-bibliography.cbor"), + Self::ChicagoShortenedNotes => include_bytes!("../archive/styles/chicago-shortened-notes-bibliography.cbor"), + Self::Copernicus => include_bytes!("../archive/styles/copernicus-publications.cbor"), + Self::CseCitationSequenceBrackets8thEdition => include_bytes!("../archive/styles/cse-citation-sequence-brackets-8th-edition.cbor"), + Self::CseNameYear => include_bytes!("../archive/styles/cse-name-year.cbor"), + Self::CurrentOpinion => include_bytes!("../archive/styles/current-opinion.cbor"), + Self::DeutscheGesellschaftFürPsychologie => include_bytes!("../archive/styles/deutsche-gesellschaft-fur-psychologie.cbor"), + Self::DeutscheSprache => include_bytes!("../archive/styles/deutsche-sprache.cbor"), + Self::ElsevierHarvard => include_bytes!("../archive/styles/elsevier-harvard.cbor"), + Self::ElsevierVancouver => include_bytes!("../archive/styles/elsevier-vancouver.cbor"), + Self::ElsevierWithTitles => include_bytes!("../archive/styles/elsevier-with-titles.cbor"), + Self::Frontiers => include_bytes!("../archive/styles/frontiers.cbor"), + Self::FutureMedicine => include_bytes!("../archive/styles/future-medicine.cbor"), + Self::FutureScience => include_bytes!("../archive/styles/future-science-group.cbor"), + Self::Gb77142005Numeric => include_bytes!("../archive/styles/chinese-gb7714-2005-numeric.cbor"), + Self::Gb77142015AuthorDate => include_bytes!("../archive/styles/china-national-standard-gb-t-7714-2015-author-date.cbor"), + Self::Gb77142015Note => include_bytes!("../archive/styles/china-national-standard-gb-t-7714-2015-note.cbor"), + Self::Gb77142015Numeric => include_bytes!("../archive/styles/china-national-standard-gb-t-7714-2015-numeric.cbor"), + Self::GostR7052008Numeric => include_bytes!("../archive/styles/gost-r-7-0-5-2008-numeric.cbor"), + Self::HarvardCiteThemRight => include_bytes!("../archive/styles/harvard-cite-them-right.cbor"), + Self::InstituteOfElectricalAndElectronicsEngineers => include_bytes!("../archive/styles/ieee.cbor"), + Self::InstituteOfPhysicsNumeric => include_bytes!("../archive/styles/institute-of-physics-numeric.cbor"), + Self::Iso690AuthorDate => include_bytes!("../archive/styles/iso690-author-date-en.cbor"), + Self::Iso690Numeric => include_bytes!("../archive/styles/iso690-numeric-en.cbor"), + Self::Karger => include_bytes!("../archive/styles/karger-journals.cbor"), + Self::MaryAnnLiebertVancouver => include_bytes!("../archive/styles/mary-ann-liebert-vancouver.cbor"), + Self::ModernHumanitiesResearchAssociationNotes => include_bytes!("../archive/styles/mhra-notes.cbor"), + Self::ModernLanguageAssociation => include_bytes!("../archive/styles/modern-language-association.cbor"), + Self::MultidisciplinaryDigitalPublishingInstitute => include_bytes!("../archive/styles/multidisciplinary-digital-publishing-institute.cbor"), + Self::Nature => include_bytes!("../archive/styles/nature.cbor"), + Self::NlmCitationSequence => include_bytes!("../archive/styles/nlm-citation-sequence.cbor"), + Self::NlmCitationSequenceSuperscript => include_bytes!("../archive/styles/nlm-citation-sequence-superscript.cbor"), + Self::Pensoft => include_bytes!("../archive/styles/pensoft-journals.cbor"), + Self::PublicLibraryOfScience => include_bytes!("../archive/styles/plos.cbor"), + Self::RoyalSocietyOfChemistry => include_bytes!("../archive/styles/royal-society-of-chemistry.cbor"), + Self::SageVancouver => include_bytes!("../archive/styles/sage-vancouver.cbor"), + Self::Sist02 => include_bytes!("../archive/styles/sist02.cbor"), + Self::Spie => include_bytes!("../archive/styles/spie-journals.cbor"), + Self::SpringerBasic => include_bytes!("../archive/styles/springer-basic-brackets.cbor"), + Self::SpringerBasicAuthorDate => include_bytes!("../archive/styles/springer-basic-author-date.cbor"), + Self::SpringerFachzeitschriftenMedizinPsychologie => include_bytes!("../archive/styles/springer-fachzeitschriften-medizin-psychologie.cbor"), + Self::SpringerHumanitiesAuthorDate => include_bytes!("../archive/styles/springer-humanities-author-date.cbor"), + Self::SpringerLectureNotesInComputerScience => include_bytes!("../archive/styles/springer-lecture-notes-in-computer-science.cbor"), + Self::SpringerMathphys => include_bytes!("../archive/styles/springer-mathphys-brackets.cbor"), + Self::SpringerSocpsychAuthorDate => include_bytes!("../archive/styles/springer-socpsych-author-date.cbor"), + Self::SpringerVancouver => include_bytes!("../archive/styles/springer-vancouver-brackets.cbor"), + Self::TaylorAndFrancisChicagoAuthorDate => include_bytes!("../archive/styles/taylor-and-francis-chicago-author-date.cbor"), + Self::TaylorAndFrancisNationalLibraryOfMedicine => include_bytes!("../archive/styles/taylor-and-francis-national-library-of-medicine.cbor"), + Self::TheInstitutionOfEngineeringAndTechnology => include_bytes!("../archive/styles/the-institution-of-engineering-and-technology.cbor"), + Self::TheLancet => include_bytes!("../archive/styles/the-lancet.cbor"), + Self::Thieme => include_bytes!("../archive/styles/thieme-german.cbor"), + Self::Trends => include_bytes!("../archive/styles/trends-journals.cbor"), + Self::TurabianAuthorDate => include_bytes!("../archive/styles/chicago-author-date-17th-edition.cbor"), + Self::TurabianFullnote8 => include_bytes!("../archive/styles/chicago-notes-bibliography-subsequent-author-title-17th-edition.cbor"), } } @@ -1162,69 +1162,69 @@ fn from_cbor( /// CBOR-encoded CSL locales. const LOCALES: &[&[u8]] = &[ - include_bytes!("../../../archive/locales/af-ZA.cbor"), - include_bytes!("../../../archive/locales/ar.cbor"), - include_bytes!("../../../archive/locales/bal-PK.cbor"), - include_bytes!("../../../archive/locales/bg-BG.cbor"), - include_bytes!("../../../archive/locales/brh-PK.cbor"), - include_bytes!("../../../archive/locales/ca-AD.cbor"), - include_bytes!("../../../archive/locales/cs-CZ.cbor"), - include_bytes!("../../../archive/locales/cy-GB.cbor"), - include_bytes!("../../../archive/locales/da-DK.cbor"), - include_bytes!("../../../archive/locales/de-AT.cbor"), - include_bytes!("../../../archive/locales/de-CH.cbor"), - include_bytes!("../../../archive/locales/de-DE.cbor"), - include_bytes!("../../../archive/locales/el-GR.cbor"), - include_bytes!("../../../archive/locales/en-GB.cbor"), - include_bytes!("../../../archive/locales/en-US.cbor"), - include_bytes!("../../../archive/locales/es-CL.cbor"), - include_bytes!("../../../archive/locales/es-ES.cbor"), - include_bytes!("../../../archive/locales/es-MX.cbor"), - include_bytes!("../../../archive/locales/et-EE.cbor"), - include_bytes!("../../../archive/locales/eu.cbor"), - include_bytes!("../../../archive/locales/fa-IR.cbor"), - include_bytes!("../../../archive/locales/fi-FI.cbor"), - include_bytes!("../../../archive/locales/fr-CA.cbor"), - include_bytes!("../../../archive/locales/fr-FR.cbor"), - include_bytes!("../../../archive/locales/gl-ES.cbor"), - include_bytes!("../../../archive/locales/he-IL.cbor"), - include_bytes!("../../../archive/locales/hi-IN.cbor"), - include_bytes!("../../../archive/locales/hr-HR.cbor"), - include_bytes!("../../../archive/locales/hu-HU.cbor"), - include_bytes!("../../../archive/locales/hy-AM.cbor"), - include_bytes!("../../../archive/locales/id-ID.cbor"), - include_bytes!("../../../archive/locales/is-IS.cbor"), - include_bytes!("../../../archive/locales/it-IT.cbor"), - include_bytes!("../../../archive/locales/ja-JP.cbor"), - include_bytes!("../../../archive/locales/km-KH.cbor"), - include_bytes!("../../../archive/locales/ko-KR.cbor"), - include_bytes!("../../../archive/locales/la.cbor"), - include_bytes!("../../../archive/locales/lij-IT.cbor"), - include_bytes!("../../../archive/locales/lt-LT.cbor"), - include_bytes!("../../../archive/locales/lv-LV.cbor"), - include_bytes!("../../../archive/locales/mn-MN.cbor"), - include_bytes!("../../../archive/locales/ms-MY.cbor"), - include_bytes!("../../../archive/locales/nb-NO.cbor"), - include_bytes!("../../../archive/locales/nl-NL.cbor"), - include_bytes!("../../../archive/locales/nn-NO.cbor"), - include_bytes!("../../../archive/locales/pa-PK.cbor"), - include_bytes!("../../../archive/locales/pl-PL.cbor"), - include_bytes!("../../../archive/locales/pt-BR.cbor"), - include_bytes!("../../../archive/locales/pt-PT.cbor"), - include_bytes!("../../../archive/locales/ro-RO.cbor"), - include_bytes!("../../../archive/locales/ru-RU.cbor"), - include_bytes!("../../../archive/locales/sk-SK.cbor"), - include_bytes!("../../../archive/locales/sl-SI.cbor"), - include_bytes!("../../../archive/locales/sr-Cyrl-RS.cbor"), - include_bytes!("../../../archive/locales/sr-Latn-RS.cbor"), - include_bytes!("../../../archive/locales/sv-SE.cbor"), - include_bytes!("../../../archive/locales/th-TH.cbor"), - include_bytes!("../../../archive/locales/tl-PH.cbor"), - include_bytes!("../../../archive/locales/tr-TR.cbor"), - include_bytes!("../../../archive/locales/uk-UA.cbor"), - include_bytes!("../../../archive/locales/vi-VN.cbor"), - include_bytes!("../../../archive/locales/zh-CN.cbor"), - include_bytes!("../../../archive/locales/zh-TW.cbor"), + include_bytes!("../archive/locales/af-ZA.cbor"), + include_bytes!("../archive/locales/ar.cbor"), + include_bytes!("../archive/locales/bal-PK.cbor"), + include_bytes!("../archive/locales/bg-BG.cbor"), + include_bytes!("../archive/locales/brh-PK.cbor"), + include_bytes!("../archive/locales/ca-AD.cbor"), + include_bytes!("../archive/locales/cs-CZ.cbor"), + include_bytes!("../archive/locales/cy-GB.cbor"), + include_bytes!("../archive/locales/da-DK.cbor"), + include_bytes!("../archive/locales/de-AT.cbor"), + include_bytes!("../archive/locales/de-CH.cbor"), + include_bytes!("../archive/locales/de-DE.cbor"), + include_bytes!("../archive/locales/el-GR.cbor"), + include_bytes!("../archive/locales/en-GB.cbor"), + include_bytes!("../archive/locales/en-US.cbor"), + include_bytes!("../archive/locales/es-CL.cbor"), + include_bytes!("../archive/locales/es-ES.cbor"), + include_bytes!("../archive/locales/es-MX.cbor"), + include_bytes!("../archive/locales/et-EE.cbor"), + include_bytes!("../archive/locales/eu.cbor"), + include_bytes!("../archive/locales/fa-IR.cbor"), + include_bytes!("../archive/locales/fi-FI.cbor"), + include_bytes!("../archive/locales/fr-CA.cbor"), + include_bytes!("../archive/locales/fr-FR.cbor"), + include_bytes!("../archive/locales/gl-ES.cbor"), + include_bytes!("../archive/locales/he-IL.cbor"), + include_bytes!("../archive/locales/hi-IN.cbor"), + include_bytes!("../archive/locales/hr-HR.cbor"), + include_bytes!("../archive/locales/hu-HU.cbor"), + include_bytes!("../archive/locales/hy-AM.cbor"), + include_bytes!("../archive/locales/id-ID.cbor"), + include_bytes!("../archive/locales/is-IS.cbor"), + include_bytes!("../archive/locales/it-IT.cbor"), + include_bytes!("../archive/locales/ja-JP.cbor"), + include_bytes!("../archive/locales/km-KH.cbor"), + include_bytes!("../archive/locales/ko-KR.cbor"), + include_bytes!("../archive/locales/la.cbor"), + include_bytes!("../archive/locales/lij-IT.cbor"), + include_bytes!("../archive/locales/lt-LT.cbor"), + include_bytes!("../archive/locales/lv-LV.cbor"), + include_bytes!("../archive/locales/mn-MN.cbor"), + include_bytes!("../archive/locales/ms-MY.cbor"), + include_bytes!("../archive/locales/nb-NO.cbor"), + include_bytes!("../archive/locales/nl-NL.cbor"), + include_bytes!("../archive/locales/nn-NO.cbor"), + include_bytes!("../archive/locales/pa-PK.cbor"), + include_bytes!("../archive/locales/pl-PL.cbor"), + include_bytes!("../archive/locales/pt-BR.cbor"), + include_bytes!("../archive/locales/pt-PT.cbor"), + include_bytes!("../archive/locales/ro-RO.cbor"), + include_bytes!("../archive/locales/ru-RU.cbor"), + include_bytes!("../archive/locales/sk-SK.cbor"), + include_bytes!("../archive/locales/sl-SI.cbor"), + include_bytes!("../archive/locales/sr-Cyrl-RS.cbor"), + include_bytes!("../archive/locales/sr-Latn-RS.cbor"), + include_bytes!("../archive/locales/sv-SE.cbor"), + include_bytes!("../archive/locales/th-TH.cbor"), + include_bytes!("../archive/locales/tl-PH.cbor"), + include_bytes!("../archive/locales/tr-TR.cbor"), + include_bytes!("../archive/locales/uk-UA.cbor"), + include_bytes!("../archive/locales/vi-VN.cbor"), + include_bytes!("../archive/locales/zh-CN.cbor"), + include_bytes!("../archive/locales/zh-TW.cbor"), ]; /// Get all CSL locales. diff --git a/crates/hayagriva-archive/tests/archiver.rs b/crates/hayagriva-archive/tests/archiver.rs index a78e5332..9e1c932b 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/crates/hayagriva-archive/tests/archiver.rs @@ -32,8 +32,8 @@ const CSL_REPO: &str = "https://github.com/citation-style-language/styles"; const LOCALES_REPO: &str = "https://github.com/citation-style-language/locales"; const LOCALES_REPO_NAME: &str = "locales"; const OWN_STYLES: &str = "../../styles"; -const ARCHIVE_STYLES_PATH: &str = "../../archive/styles/"; -const ARCHIVE_LOCALES_PATH: &str = "../../archive/locales/"; +const ARCHIVE_STYLES_PATH: &str = "archive/styles/"; +const ARCHIVE_LOCALES_PATH: &str = "archive/locales/"; const ARCHIVE_SRC_PATH: &str = "src/lib.rs"; const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; @@ -327,7 +327,7 @@ fn write_styles_section( writeln!( w, - " Self::{variant} => include_bytes!(\"../../../archive/styles/{stripped_id}.cbor\")," + " Self::{variant} => include_bytes!(\"../archive/styles/{stripped_id}.cbor\")," )?; } writeln!(w, " }}")?; @@ -391,7 +391,7 @@ fn write_locales_section(w: &mut String, items: &[(Vec, Locale)]) -> fmt::Re for (_, locale) in items { writeln!( w, - " include_bytes!(\"../../../archive/locales/{}.cbor\"),", + " include_bytes!(\"../archive/locales/{}.cbor\"),", locale.lang.as_ref().unwrap() )?; } From 300b491eb6abcd36111f02c93bc2f0bdfef62ab0 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 20:38:27 +0200 Subject: [PATCH 24/31] Crate keywords and descriptions --- Cargo.toml | 2 +- crates/hayagriva-archive/Cargo.toml | 13 +++++++++++-- crates/hayagriva-cli/Cargo.toml | 11 +++++++++-- crates/hayagriva-core/Cargo.toml | 3 ++- crates/hayagriva-csl/Cargo.toml | 11 +++++++++-- crates/hayagriva-format/Cargo.toml | 4 ++-- crates/hayagriva-json/Cargo.toml | 11 +++++++++-- 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a8353467..c8059ee8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2024" license = "MIT OR Apache-2.0" repository = "https://github.com/typst/hayagriva" readme = "README.md" -keywords = ["bibliography", "citation", "reference", "literature"] +keywords = ["hayagriva", "bibliography", "citation", "reference", "literature"] [workspace.dependencies] biblatex = { version = "0.12.0", features = ["unic-langid"] } diff --git a/crates/hayagriva-archive/Cargo.toml b/crates/hayagriva-archive/Cargo.toml index b71ec1ce..084b4c77 100644 --- a/crates/hayagriva-archive/Cargo.toml +++ b/crates/hayagriva-archive/Cargo.toml @@ -1,13 +1,22 @@ [package] name = "hayagriva-archive" -description = "Archived CSL styles and locales for Hayagriva/Typst" +description = "Archived CSL styles and locales for Hayagriva/Typst." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = [ + "hayagriva", + "bibliography", + "citation", + "reference", + "literature", + "archive", + "citation style language", + "locales", +] [dependencies] citationberg = { workspace = true } diff --git a/crates/hayagriva-cli/Cargo.toml b/crates/hayagriva-cli/Cargo.toml index 563a1756..f077f27e 100644 --- a/crates/hayagriva-cli/Cargo.toml +++ b/crates/hayagriva-cli/Cargo.toml @@ -1,13 +1,20 @@ [package] name = "hayagriva-cli" -description = "Archived CSL styles and locales for Hayagriva/Typst" +description = "The command line interface for Hayagriva." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = [ + "hayagriva", + "bibliography", + "citation", + "reference", + "literature", + "cli", +] [dependencies] citationberg = { workspace = true } diff --git a/crates/hayagriva-core/Cargo.toml b/crates/hayagriva-core/Cargo.toml index 1dcb7bcc..8bace8fc 100644 --- a/crates/hayagriva-core/Cargo.toml +++ b/crates/hayagriva-core/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "hayagriva-core" +description = "Core data types and utilities for Hayagriva." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = ["hayagriva", "bibliography", "citation", "reference", "literature"] [dependencies] serde = { workspace = true } diff --git a/crates/hayagriva-csl/Cargo.toml b/crates/hayagriva-csl/Cargo.toml index 2d0ce9e9..ae88439d 100644 --- a/crates/hayagriva-csl/Cargo.toml +++ b/crates/hayagriva-csl/Cargo.toml @@ -1,13 +1,20 @@ [package] name = "hayagriva-csl" -description = "Work with references: Literature database management, storage, and citation formatting" +description = "Citation Style Language procesor and renderer for Hayagriva." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = [ + "hayagriva", + "bibliography", + "citation", + "reference", + "literature", + "rendering", +] [dependencies] citationberg = { workspace = true } diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 88281df3..25f9f97f 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "hayagriva-format" -description = "Archived CSL styles and locales for Hayagriva/Typst" +description = "The bibliography format Hayagriva, used in Typst." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = ["hayagriva", "bibliography", "citation", "reference", "literature"] [dependencies] biblatex = { workspace = true, optional = true } diff --git a/crates/hayagriva-json/Cargo.toml b/crates/hayagriva-json/Cargo.toml index 54937914..ed801a87 100644 --- a/crates/hayagriva-json/Cargo.toml +++ b/crates/hayagriva-json/Cargo.toml @@ -1,13 +1,20 @@ [package] name = "hayagriva-json" -description = "Archived CSL styles and locales for Hayagriva/Typst" +description = "CSL-JSON handling for Hayagriva." version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true readme.workspace = true -keywords.workspace = true +keywords = [ + "hayagriva", + "bibliography", + "citation", + "reference", + "literature", + "json", +] [dependencies] citationberg = { workspace = true, features = ["json"] } From 6e4bb8bb961e479b7e4e59041538b3fda7cdc777 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 20:52:48 +0200 Subject: [PATCH 25/31] Restructure tests --- Cargo.toml | 2 +- crates/hayagriva-cli/src/main.rs | 13 ++++--------- crates/hayagriva-format/src/io.rs | 2 +- crates/hayagriva-format/src/lib.rs | 4 ++-- crates/tests/src/lib.rs | 1 - {crates/tests => tests}/Cargo.toml | 2 +- {crates/tests/tests => tests}/citeproc-pass.txt | 0 {crates/tests/tests => tests}/data/art-history.csl | 0 {crates/tests/tests => tests}/data/basic.yml | 0 .../tests/tests => tests}/data/locales-en-US.xml | 0 {crates/tests/tests => tests}/data/lotr.bib | 0 .../tests => tests}/local/affix_DoiUrlPrefix.txt | 0 .../local/choose_UseAncestorsDelimiter.txt | 0 .../collapse_CitationNumberRangesSeparated.txt | 0 .../local/collapse_CitationNumberRangesSort.txt | 0 .../tests => tests}/local/date_DateBCAdjusted.txt | 0 .../local/date_LocalizedDateDelimiters.txt | 0 .../tests => tests}/local/date_NegativeDateSort.txt | 0 .../local/date_NegativeDateSortViaMacro.txt | 0 ...date_NegativeDateSortViaMacroOnYearMonthOnly.txt | 0 .../local/name_PartInheritsFormatting.txt | 0 .../local/name_SubsequentAuthorSubstitute.txt | 0 .../tests/tests => tests}/local/page_NumberPage.txt | 0 .../local/page_NumberPageMacroSort.txt | 0 .../tests => tests}/local/page_NumberPageSort.txt | 0 .../local/position_IbidIsNotIbidWithLocator.txt | 0 .../local/position_IbidWithLocatorIsIbid.txt | 0 .../tests/tests => tests}/local/sort_Unicode.txt | 0 {crates/tests/tests => tests/src}/citeproc.rs | 12 ++++-------- 29 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 crates/tests/src/lib.rs rename {crates/tests => tests}/Cargo.toml (95%) rename {crates/tests/tests => tests}/citeproc-pass.txt (100%) rename {crates/tests/tests => tests}/data/art-history.csl (100%) rename {crates/tests/tests => tests}/data/basic.yml (100%) rename {crates/tests/tests => tests}/data/locales-en-US.xml (100%) rename {crates/tests/tests => tests}/data/lotr.bib (100%) rename {crates/tests/tests => tests}/local/affix_DoiUrlPrefix.txt (100%) rename {crates/tests/tests => tests}/local/choose_UseAncestorsDelimiter.txt (100%) rename {crates/tests/tests => tests}/local/collapse_CitationNumberRangesSeparated.txt (100%) rename {crates/tests/tests => tests}/local/collapse_CitationNumberRangesSort.txt (100%) rename {crates/tests/tests => tests}/local/date_DateBCAdjusted.txt (100%) rename {crates/tests/tests => tests}/local/date_LocalizedDateDelimiters.txt (100%) rename {crates/tests/tests => tests}/local/date_NegativeDateSort.txt (100%) rename {crates/tests/tests => tests}/local/date_NegativeDateSortViaMacro.txt (100%) rename {crates/tests/tests => tests}/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt (100%) rename {crates/tests/tests => tests}/local/name_PartInheritsFormatting.txt (100%) rename {crates/tests/tests => tests}/local/name_SubsequentAuthorSubstitute.txt (100%) rename {crates/tests/tests => tests}/local/page_NumberPage.txt (100%) rename {crates/tests/tests => tests}/local/page_NumberPageMacroSort.txt (100%) rename {crates/tests/tests => tests}/local/page_NumberPageSort.txt (100%) rename {crates/tests/tests => tests}/local/position_IbidIsNotIbidWithLocator.txt (100%) rename {crates/tests/tests => tests}/local/position_IbidWithLocatorIsIbid.txt (100%) rename {crates/tests/tests => tests}/local/sort_Unicode.txt (100%) rename {crates/tests/tests => tests/src}/citeproc.rs (99%) diff --git a/Cargo.toml b/Cargo.toml index c8059ee8..03be137a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/*"] +members = ["crates/*", "tests"] resolver = "2" [workspace.package] diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index bad0cbd3..851851e5 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -643,15 +643,11 @@ mod tests { #[test] fn test_csl() { let workspace = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../"); - let en_locale = fs::read_to_string( - workspace.join("crates/tests/tests/data/locales-en-US.xml"), - ) - .unwrap(); + let en_locale = + fs::read_to_string(workspace.join("tests/data/locales-en-US.xml")).unwrap(); let en_locale = LocaleFile::from_xml(&en_locale).unwrap(); - let yaml = - fs::read_to_string(workspace.join("crates/tests/tests/data/basic.yml")) - .unwrap(); + let yaml = fs::read_to_string(workspace.join("tests/data/basic.yml")).unwrap(); let bib = from_yaml_str(&yaml).unwrap(); let en_locale = [en_locale.into()]; @@ -818,8 +814,7 @@ mod tests { fn test_chapter_field() { let workspace = Path::new(env!("CARGO_MANIFEST_DIR")); let yaml = - fs::read_to_string(workspace.join("../../crates/tests/tests/data/basic.yml")) - .unwrap(); + fs::read_to_string(workspace.join("../../tests/data/basic.yml")).unwrap(); let bib = from_yaml_str(&yaml).unwrap(); let book = bib.get("lamb").unwrap(); assert_eq!(book.chapter().unwrap(), &MaybeTyped::Typed(Numeric::new(20))); diff --git a/crates/hayagriva-format/src/io.rs b/crates/hayagriva-format/src/io.rs index 3962ca28..cb99832c 100644 --- a/crates/hayagriva-format/src/io.rs +++ b/crates/hayagriva-format/src/io.rs @@ -90,7 +90,7 @@ mod tests { #[test] fn roundtrip() { - let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); let yaml = to_yaml_str(&entries).unwrap(); println!("{}", &yaml); diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 29a7a78e..70007896 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -859,7 +859,7 @@ mod tests { #[test] fn selectors() { - let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select_all!("article > proceedings", entries, ["zygos"]); @@ -927,7 +927,7 @@ mod tests { #[test] fn selector_bindings() { - let contents = fs::read_to_string("../tests/tests/data/basic.yml").unwrap(); + let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); select!( diff --git a/crates/tests/src/lib.rs b/crates/tests/src/lib.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/tests/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/tests/Cargo.toml b/tests/Cargo.toml similarity index 95% rename from crates/tests/Cargo.toml rename to tests/Cargo.toml index cc36aaef..7c01c725 100644 --- a/crates/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -22,4 +22,4 @@ unscanny = { workspace = true } [[test]] name = "citeproc" -path = "tests/citeproc.rs" +path = "src/citeproc.rs" diff --git a/crates/tests/tests/citeproc-pass.txt b/tests/citeproc-pass.txt similarity index 100% rename from crates/tests/tests/citeproc-pass.txt rename to tests/citeproc-pass.txt diff --git a/crates/tests/tests/data/art-history.csl b/tests/data/art-history.csl similarity index 100% rename from crates/tests/tests/data/art-history.csl rename to tests/data/art-history.csl diff --git a/crates/tests/tests/data/basic.yml b/tests/data/basic.yml similarity index 100% rename from crates/tests/tests/data/basic.yml rename to tests/data/basic.yml diff --git a/crates/tests/tests/data/locales-en-US.xml b/tests/data/locales-en-US.xml similarity index 100% rename from crates/tests/tests/data/locales-en-US.xml rename to tests/data/locales-en-US.xml diff --git a/crates/tests/tests/data/lotr.bib b/tests/data/lotr.bib similarity index 100% rename from crates/tests/tests/data/lotr.bib rename to tests/data/lotr.bib diff --git a/crates/tests/tests/local/affix_DoiUrlPrefix.txt b/tests/local/affix_DoiUrlPrefix.txt similarity index 100% rename from crates/tests/tests/local/affix_DoiUrlPrefix.txt rename to tests/local/affix_DoiUrlPrefix.txt diff --git a/crates/tests/tests/local/choose_UseAncestorsDelimiter.txt b/tests/local/choose_UseAncestorsDelimiter.txt similarity index 100% rename from crates/tests/tests/local/choose_UseAncestorsDelimiter.txt rename to tests/local/choose_UseAncestorsDelimiter.txt diff --git a/crates/tests/tests/local/collapse_CitationNumberRangesSeparated.txt b/tests/local/collapse_CitationNumberRangesSeparated.txt similarity index 100% rename from crates/tests/tests/local/collapse_CitationNumberRangesSeparated.txt rename to tests/local/collapse_CitationNumberRangesSeparated.txt diff --git a/crates/tests/tests/local/collapse_CitationNumberRangesSort.txt b/tests/local/collapse_CitationNumberRangesSort.txt similarity index 100% rename from crates/tests/tests/local/collapse_CitationNumberRangesSort.txt rename to tests/local/collapse_CitationNumberRangesSort.txt diff --git a/crates/tests/tests/local/date_DateBCAdjusted.txt b/tests/local/date_DateBCAdjusted.txt similarity index 100% rename from crates/tests/tests/local/date_DateBCAdjusted.txt rename to tests/local/date_DateBCAdjusted.txt diff --git a/crates/tests/tests/local/date_LocalizedDateDelimiters.txt b/tests/local/date_LocalizedDateDelimiters.txt similarity index 100% rename from crates/tests/tests/local/date_LocalizedDateDelimiters.txt rename to tests/local/date_LocalizedDateDelimiters.txt diff --git a/crates/tests/tests/local/date_NegativeDateSort.txt b/tests/local/date_NegativeDateSort.txt similarity index 100% rename from crates/tests/tests/local/date_NegativeDateSort.txt rename to tests/local/date_NegativeDateSort.txt diff --git a/crates/tests/tests/local/date_NegativeDateSortViaMacro.txt b/tests/local/date_NegativeDateSortViaMacro.txt similarity index 100% rename from crates/tests/tests/local/date_NegativeDateSortViaMacro.txt rename to tests/local/date_NegativeDateSortViaMacro.txt diff --git a/crates/tests/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt b/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt similarity index 100% rename from crates/tests/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt rename to tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt diff --git a/crates/tests/tests/local/name_PartInheritsFormatting.txt b/tests/local/name_PartInheritsFormatting.txt similarity index 100% rename from crates/tests/tests/local/name_PartInheritsFormatting.txt rename to tests/local/name_PartInheritsFormatting.txt diff --git a/crates/tests/tests/local/name_SubsequentAuthorSubstitute.txt b/tests/local/name_SubsequentAuthorSubstitute.txt similarity index 100% rename from crates/tests/tests/local/name_SubsequentAuthorSubstitute.txt rename to tests/local/name_SubsequentAuthorSubstitute.txt diff --git a/crates/tests/tests/local/page_NumberPage.txt b/tests/local/page_NumberPage.txt similarity index 100% rename from crates/tests/tests/local/page_NumberPage.txt rename to tests/local/page_NumberPage.txt diff --git a/crates/tests/tests/local/page_NumberPageMacroSort.txt b/tests/local/page_NumberPageMacroSort.txt similarity index 100% rename from crates/tests/tests/local/page_NumberPageMacroSort.txt rename to tests/local/page_NumberPageMacroSort.txt diff --git a/crates/tests/tests/local/page_NumberPageSort.txt b/tests/local/page_NumberPageSort.txt similarity index 100% rename from crates/tests/tests/local/page_NumberPageSort.txt rename to tests/local/page_NumberPageSort.txt diff --git a/crates/tests/tests/local/position_IbidIsNotIbidWithLocator.txt b/tests/local/position_IbidIsNotIbidWithLocator.txt similarity index 100% rename from crates/tests/tests/local/position_IbidIsNotIbidWithLocator.txt rename to tests/local/position_IbidIsNotIbidWithLocator.txt diff --git a/crates/tests/tests/local/position_IbidWithLocatorIsIbid.txt b/tests/local/position_IbidWithLocatorIsIbid.txt similarity index 100% rename from crates/tests/tests/local/position_IbidWithLocatorIsIbid.txt rename to tests/local/position_IbidWithLocatorIsIbid.txt diff --git a/crates/tests/tests/local/sort_Unicode.txt b/tests/local/sort_Unicode.txt similarity index 100% rename from crates/tests/tests/local/sort_Unicode.txt rename to tests/local/sort_Unicode.txt diff --git a/crates/tests/tests/citeproc.rs b/tests/src/citeproc.rs similarity index 99% rename from crates/tests/tests/citeproc.rs rename to tests/src/citeproc.rs index 78842f15..2fab5992 100644 --- a/crates/tests/tests/citeproc.rs +++ b/tests/src/citeproc.rs @@ -452,7 +452,7 @@ fn test_single_file() { #[test] fn test_local_files() { let locales = locales(); - let test_path = PathBuf::from("tests/local"); + let test_path = PathBuf::from("local"); for path in iter_files_with_name(&test_path, "txt", |_| true) { let case = match build_case(&std::fs::read_to_string(&path).unwrap()) { @@ -886,9 +886,7 @@ fn purposes() { /// The file should be located at `tests/citeproc-pass.txt`. /// It contains one test case name per line. fn load_passing_tests() -> Vec { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests") - .join("citeproc-pass.txt"); + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("citeproc-pass.txt"); std::fs::read_to_string(path) .unwrap() .lines() @@ -898,11 +896,9 @@ fn load_passing_tests() -> Vec { } /// Write the names of the test cases that should pass to the file -/// `tests/citeproc-pass.txt`. +/// `citeproc-pass.txt`. fn write_passing_test(tests: &[String]) { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests") - .join("citeproc-pass.txt"); + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("citeproc-pass.txt"); let comment = "# This file contains all test cases that should pass.\n\ # The test fails if a test case in this file fails or if a test case\n\ # that is not in this file passes.\n#\n\ From 5edbaf959664a8e3a4a034fbc236fda6aec7529c Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 20:55:44 +0200 Subject: [PATCH 26/31] Clippy --- crates/hayagriva-cli/src/main.rs | 6 +++--- crates/hayagriva-format/src/io.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/hayagriva-cli/src/main.rs b/crates/hayagriva-cli/src/main.rs index 851851e5..80d84f6b 100644 --- a/crates/hayagriva-cli/src/main.rs +++ b/crates/hayagriva-cli/src/main.rs @@ -562,8 +562,8 @@ verse volume"#) Some(("styles", _)) => { for key in ArchivedStyle::all() { let style = key.get(); - println!("- {}", &key.names()[0]); - println!(" Full name: {}", &style.info().title.value); + println!("- {}", key.names()[0]); + println!(" Full name: {}", style.info().title.value); println!(" Authors:"); for author in style.info().authors.iter() { print!(" - {}", author.name); @@ -574,7 +574,7 @@ verse volume"#) } } if let Some(desc) = &style.info().summary { - println!(" Summary: {}", &desc.value); + println!(" Summary: {}", desc.value); } } } diff --git a/crates/hayagriva-format/src/io.rs b/crates/hayagriva-format/src/io.rs index cb99832c..517e6ce6 100644 --- a/crates/hayagriva-format/src/io.rs +++ b/crates/hayagriva-format/src/io.rs @@ -93,7 +93,7 @@ mod tests { let contents = fs::read_to_string("../../tests/data/basic.yml").unwrap(); let entries = from_yaml_str(&contents).unwrap(); let yaml = to_yaml_str(&entries).unwrap(); - println!("{}", &yaml); + println!("{}", yaml); let reconstructed = from_yaml_str(&yaml).unwrap(); assert_eq!(entries.len(), reconstructed.len()); From f45f5c50756f5c402fec48509bfe4c938dccd0a1 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 21:22:30 +0200 Subject: [PATCH 27/31] Simplify workspace structure and tests --- Cargo.lock | 5 +++-- crates/hayagriva-archive/Cargo.toml | 6 +----- crates/hayagriva-archive/src/lib.rs | 2 +- crates/hayagriva-core/src/lib.rs | 1 - tests/Cargo.toml | 7 +++++-- .../tests => tests/src}/archiver.rs | 16 +++++++--------- tests/src/citeproc.rs | 7 ++++--- .../src/test_util.rs => tests/src/tests.rs | 5 +++-- 8 files changed, 24 insertions(+), 25 deletions(-) rename {crates/hayagriva-archive/tests => tests/src}/archiver.rs (98%) rename crates/hayagriva-core/src/test_util.rs => tests/src/tests.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index 020d4f3f..7ef9b444 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,8 +221,6 @@ version = "0.10.1" dependencies = [ "ciborium", "citationberg", - "hayagriva-core", - "heck", "serde", ] @@ -755,13 +753,16 @@ dependencies = [ name = "tests" version = "0.10.1" dependencies = [ + "ciborium", "citationberg", "hayagriva-archive", "hayagriva-core", "hayagriva-csl", "hayagriva-format", "hayagriva-json", + "heck", "regex", + "serde", "serde_json", "unscanny", ] diff --git a/crates/hayagriva-archive/Cargo.toml b/crates/hayagriva-archive/Cargo.toml index 084b4c77..39ac6c87 100644 --- a/crates/hayagriva-archive/Cargo.toml +++ b/crates/hayagriva-archive/Cargo.toml @@ -19,10 +19,6 @@ keywords = [ ] [dependencies] +ciborium = { workspace = true } citationberg = { workspace = true } serde = { workspace = true } -hayagriva-core = { workspace = true } -ciborium = { workspace = true } - -[dev-dependencies] -heck = "0.5" diff --git a/crates/hayagriva-archive/src/lib.rs b/crates/hayagriva-archive/src/lib.rs index 845cb65a..6d5ab445 100644 --- a/crates/hayagriva-archive/src/lib.rs +++ b/crates/hayagriva-archive/src/lib.rs @@ -1,5 +1,5 @@ //! Archive CSL styles. Included in Typst. -// This file is generated by tests/archiver.rs +// This file is generated by tests/src/archiver.rs // Do not edit by hand! use citationberg::{Locale, Style}; diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs index 5d402943..19209076 100644 --- a/crates/hayagriva-core/src/lib.rs +++ b/crates/hayagriva-core/src/lib.rs @@ -14,7 +14,6 @@ use citationberg::taxonomy::{ pub use types::*; pub mod lang; -pub mod test_util; pub mod types; pub mod util; diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 7c01c725..8ec8b2c7 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -10,16 +10,19 @@ keywords.workspace = true publish = false [dev-dependencies] +ciborium = { workspace = true } citationberg = { workspace = true, features = ["json"] } hayagriva-archive = { workspace = true } hayagriva-core = { workspace = true } hayagriva-csl = { workspace = true } hayagriva-format = { workspace = true, features = ["biblatex"] } hayagriva-json = { workspace = true } +heck = "0.5" +serde = { workspace = true } serde_json = "1" regex = "1" unscanny = { workspace = true } [[test]] -name = "citeproc" -path = "src/citeproc.rs" +name = "test" +path = "src/tests.rs" diff --git a/crates/hayagriva-archive/tests/archiver.rs b/tests/src/archiver.rs similarity index 98% rename from crates/hayagriva-archive/tests/archiver.rs rename to tests/src/archiver.rs index 9e1c932b..16ca86c3 100644 --- a/crates/hayagriva-archive/tests/archiver.rs +++ b/tests/src/archiver.rs @@ -23,18 +23,16 @@ use citationberg::{IndependentStyle, LocaleCode, Style}; use citationberg::{Locale, LocaleFile, XmlDeError}; use serde::Serialize; -use hayagriva_core::test_util::{ - CACHE_PATH, ensure_repo, iter_files, iter_files_with_name, -}; +use super::{CACHE_PATH, ensure_repo, iter_files, iter_files_with_name}; const STYLES_REPO_NAME: &str = "styles"; const CSL_REPO: &str = "https://github.com/citation-style-language/styles"; const LOCALES_REPO: &str = "https://github.com/citation-style-language/locales"; const LOCALES_REPO_NAME: &str = "locales"; -const OWN_STYLES: &str = "../../styles"; -const ARCHIVE_STYLES_PATH: &str = "archive/styles/"; -const ARCHIVE_LOCALES_PATH: &str = "archive/locales/"; -const ARCHIVE_SRC_PATH: &str = "src/lib.rs"; +const OWN_STYLES: &str = "../styles"; +const ARCHIVE_STYLES_PATH: &str = "../crates/hayagriva-archive/archive/styles/"; +const ARCHIVE_LOCALES_PATH: &str = "../crates/hayagriva-archive/archive/locales/"; +const ARCHIVE_SRC_PATH: &str = "../crates/hayagriva-archive/src/lib.rs"; const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; @@ -45,7 +43,7 @@ const UPDATE_ARCHIVES_ENV_VAR: &str = "HAYAGRIVA_ARCHIVER_UPDATE"; /// below: /// /// ```sh -/// cargo test -p hayagriva-archive --test archiver -- --ignored +/// cargo test --test test -- archiver --ignored /// ``` #[test] #[ignore] @@ -254,7 +252,7 @@ fn write_styles_section( items: &[(Vec, IndependentStyle, Vec, String)], ) -> fmt::Result { writeln!(w, "//! Archive CSL styles. Included in Typst.")?; - writeln!(w, "// This file is generated by tests/archiver.rs")?; + writeln!(w, "// This file is generated by tests/src/archiver.rs")?; writeln!(w, "// Do not edit by hand!")?; writeln!(w)?; writeln!(w, "use citationberg::{{Locale, Style}};")?; diff --git a/tests/src/citeproc.rs b/tests/src/citeproc.rs index 2fab5992..57fd5c3c 100644 --- a/tests/src/citeproc.rs +++ b/tests/src/citeproc.rs @@ -12,7 +12,6 @@ use citationberg::{Locale, LocaleCode, Style, XmlDeError}; use unscanny::Scanner; use hayagriva_archive::{ArchivedStyle, locales}; -use hayagriva_core::test_util::{CACHE_PATH, ensure_repo, iter_files_with_name}; use hayagriva_csl::{ BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, CitePurpose, LocatorPayload, SpecificLocator, @@ -20,6 +19,8 @@ use hayagriva_csl::{ use hayagriva_format::Entry; use hayagriva_format::io::from_biblatex_str; +use super::{CACHE_PATH, ensure_repo, iter_files_with_name}; + const TEST_REPO_NAME: &str = "test-suite"; const TEST_REPO: &str = "https://github.com/citation-style-language/test-suite"; @@ -362,7 +363,7 @@ fn test_parse_tests() { if fail { panic!( - "⚠️ Some test passed but were not found in the `passing` file.\nRebuild the file by running `cargo test --test citeproc --features csl-json -- write_passing --ignored`" + "⚠️ Some test passed but were not found in the `passing` file.\nRebuild the file by running `cargo test --test test -- citeproc::write_passing --ignored`" ) } @@ -902,7 +903,7 @@ fn write_passing_test(tests: &[String]) { let comment = "# This file contains all test cases that should pass.\n\ # The test fails if a test case in this file fails or if a test case\n\ # that is not in this file passes.\n#\n\ - # This file is automatically generated by running `cargo test --test citeproc --features csl-json -- write_passing --ignored`.\n\n"; + # This file is automatically generated by running `cargo test --test test -- citeproc::write_passing --ignored`.\n\n"; let mut w = BufWriter::new(fs::File::create(path).unwrap()); w.write_all(comment.as_bytes()).unwrap(); diff --git a/crates/hayagriva-core/src/test_util.rs b/tests/src/tests.rs similarity index 96% rename from crates/hayagriva-core/src/test_util.rs rename to tests/src/tests.rs index 7c6e1e99..ee92c189 100644 --- a/crates/hayagriva-core/src/test_util.rs +++ b/tests/src/tests.rs @@ -1,10 +1,11 @@ -//! Utilities for tests in Hayagriva. +mod archiver; +mod citeproc; use std::path::PathBuf; use std::process::Command; use std::{fs, io}; -pub const CACHE_PATH: &str = "../../target/haya-cache"; +pub const CACHE_PATH: &str = "../target/haya-cache"; #[allow(unused)] pub fn iter_files<'a>( From 83fbc4e8643bc0df6ed35d3874b0802e36798150 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 21:37:17 +0200 Subject: [PATCH 28/31] Rename `hayagriva-json` to `hayagriva-csl-json` --- Cargo.lock | 20 +++++++++---------- Cargo.toml | 2 +- .../Cargo.toml | 2 +- .../src/lib.rs | 0 tests/Cargo.toml | 2 +- tests/src/citeproc.rs | 12 +++++------ 6 files changed, 19 insertions(+), 19 deletions(-) rename crates/{hayagriva-json => hayagriva-csl-json}/Cargo.toml (94%) rename crates/{hayagriva-json => hayagriva-csl-json}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 7ef9b444..ad10ccf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -264,6 +264,15 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "hayagriva-csl-json" +version = "0.10.1" +dependencies = [ + "citationberg", + "hayagriva-core", + "serde", +] + [[package]] name = "hayagriva-format" version = "0.10.1" @@ -283,15 +292,6 @@ dependencies = [ "url", ] -[[package]] -name = "hayagriva-json" -version = "0.10.1" -dependencies = [ - "citationberg", - "hayagriva-core", - "serde", -] - [[package]] name = "heck" version = "0.5.0" @@ -758,8 +758,8 @@ dependencies = [ "hayagriva-archive", "hayagriva-core", "hayagriva-csl", + "hayagriva-csl-json", "hayagriva-format", - "hayagriva-json", "heck", "regex", "serde", diff --git a/Cargo.toml b/Cargo.toml index 03be137a..fb90e2eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ hayagriva-archive = { path = "crates/hayagriva-archive" } hayagriva-cli = { path = "crates/hayagriva-cli" } hayagriva-core = { path = "crates/hayagriva-core" } hayagriva-csl = { path = "crates/hayagriva-csl" } +hayagriva-csl-json = { path = "crates/hayagriva-csl-json" } hayagriva-format = { path = "crates/hayagriva-format" } -hayagriva-json = { path = "crates/hayagriva-json" } serde = { version = "1", features = ["derive"] } unic-langid = { version = "0.9.6", features = ["serde"] } unicode-segmentation = "1.6.0" diff --git a/crates/hayagriva-json/Cargo.toml b/crates/hayagriva-csl-json/Cargo.toml similarity index 94% rename from crates/hayagriva-json/Cargo.toml rename to crates/hayagriva-csl-json/Cargo.toml index ed801a87..a072ecdf 100644 --- a/crates/hayagriva-json/Cargo.toml +++ b/crates/hayagriva-csl-json/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "hayagriva-json" +name = "hayagriva-csl-json" description = "CSL-JSON handling for Hayagriva." version.workspace = true authors.workspace = true diff --git a/crates/hayagriva-json/src/lib.rs b/crates/hayagriva-csl-json/src/lib.rs similarity index 100% rename from crates/hayagriva-json/src/lib.rs rename to crates/hayagriva-csl-json/src/lib.rs diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 8ec8b2c7..1abdabf8 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -15,8 +15,8 @@ citationberg = { workspace = true, features = ["json"] } hayagriva-archive = { workspace = true } hayagriva-core = { workspace = true } hayagriva-csl = { workspace = true } +hayagriva-csl-json = { workspace = true } hayagriva-format = { workspace = true, features = ["biblatex"] } -hayagriva-json = { workspace = true } heck = "0.5" serde = { workspace = true } serde_json = "1" diff --git a/tests/src/citeproc.rs b/tests/src/citeproc.rs index 57fd5c3c..f42e8c05 100644 --- a/tests/src/citeproc.rs +++ b/tests/src/citeproc.rs @@ -224,7 +224,7 @@ struct TestCase { mode: TestMode, result: String, csl: Style, - input: Vec, + input: Vec, bib_entries: Option>>, bib_section: Option, citation_items: Option>>, @@ -539,7 +539,7 @@ where panic!("test {} has dependent style", display()); }; - let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = + let mut driver: BibliographyDriver<'_, hayagriva_csl_json::Item> = BibliographyDriver::new(); let mut output = String::new(); if let Some(cites) = &case.citation_items { @@ -833,7 +833,7 @@ fn purposes() { panic!("test has dependent style"); }; - let item = hayagriva_json::Item( + let item = hayagriva_csl_json::Item( serde_json::from_str( r#"{ "id": "ITEM-1", @@ -863,7 +863,7 @@ fn purposes() { (CitePurpose::Year, "2000"), (CitePurpose::Full, "Doe, J. (2000). Book A."), ] { - let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = + let mut driver: BibliographyDriver<'_, hayagriva_csl_json::Item> = BibliographyDriver::new(); driver.citation(CitationRequest::new( vec![CitationItem::new(&item, None, None, false, Some(purpose))], @@ -921,7 +921,7 @@ fn case_folding() { panic!("test has dependent style"); }; - let item: hayagriva_json::Item = hayagriva_json::Item( + let item: hayagriva_csl_json::Item = hayagriva_csl_json::Item( serde_json::from_str( r#"{ "id": "ITEM-1", @@ -932,7 +932,7 @@ fn case_folding() { .unwrap(), ); - let mut driver: BibliographyDriver<'_, hayagriva_json::Item> = + let mut driver: BibliographyDriver<'_, hayagriva_csl_json::Item> = BibliographyDriver::new(); driver.citation(CitationRequest::new( vec![CitationItem::new(&item, None, None, false, None)], From e6af4763d125e4bb032e73bdf6ba8af4d079a412 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 21:39:38 +0200 Subject: [PATCH 29/31] Mark core util as `doc(hidden)` --- crates/hayagriva-core/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/hayagriva-core/src/lib.rs b/crates/hayagriva-core/src/lib.rs index 19209076..1190f3ca 100644 --- a/crates/hayagriva-core/src/lib.rs +++ b/crates/hayagriva-core/src/lib.rs @@ -15,6 +15,7 @@ pub use types::*; pub mod lang; pub mod types; +#[doc(hidden)] pub mod util; /// Defines an entry for CSL rendering. Implementing this trait enables From 6403cd4157e2d74afdd54a7f7d9aae7120880ac3 Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 22:21:16 +0200 Subject: [PATCH 30/31] Move as many types from core to format as possible --- crates/hayagriva-core/src/types/mod.rs | 179 +--------- crates/hayagriva-core/src/types/page.rs | 1 - crates/hayagriva-core/src/types/persons.rs | 73 +--- crates/hayagriva-core/src/types/time.rs | 334 +---------------- crates/hayagriva-format/Cargo.toml | 5 +- crates/hayagriva-format/src/citation_label.rs | 3 +- crates/hayagriva-format/src/interop.rs | 6 +- crates/hayagriva-format/src/lib.rs | 3 + crates/hayagriva-format/src/taxonomy.rs | 3 +- crates/hayagriva-format/src/types/mod.rs | 172 +++++++++ crates/hayagriva-format/src/types/person.rs | 74 ++++ crates/hayagriva-format/src/types/time.rs | 338 ++++++++++++++++++ 12 files changed, 612 insertions(+), 579 deletions(-) create mode 100644 crates/hayagriva-format/src/types/mod.rs create mode 100644 crates/hayagriva-format/src/types/person.rs create mode 100644 crates/hayagriva-format/src/types/time.rs diff --git a/crates/hayagriva-core/src/types/mod.rs b/crates/hayagriva-core/src/types/mod.rs index f64a9448..a37e9437 100644 --- a/crates/hayagriva-core/src/types/mod.rs +++ b/crates/hayagriva-core/src/types/mod.rs @@ -1,16 +1,13 @@ //! Base types for the bibliography items and their content. use std::borrow::Cow; -use std::collections::BTreeMap; use std::convert::Infallible; use std::fmt::{self, Display}; use std::str::FromStr; use serde::de::value::StrDeserializer; -use serde::ser::SerializeMap; use serde::{Deserialize, Serialize}; use thiserror::Error; -use url::Url; pub use numeric::*; pub use page::*; @@ -25,9 +22,10 @@ mod strings; mod time; /// Use the [`Display`] implementation of a type for serialization. +#[macro_export] macro_rules! serialize_display { ($t:ty) => { - impl Serialize for $t { + impl serde::Serialize for $t { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -39,23 +37,25 @@ macro_rules! serialize_display { } /// Use the [`FromStr`] implementation of a type for deserialization. +#[macro_export] macro_rules! deserialize_from_str { ($t:ty) => { - impl<'de> Deserialize<'de> for $t { + impl<'de> serde::Deserialize<'de> for $t { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; - FromStr::from_str(s).map_err(serde::de::Error::custom) + std::str::FromStr::from_str(s).map_err(serde::de::Error::custom) } } }; } +#[macro_export] macro_rules! custom_deserialize { ($type_name:ident where $expect:literal $($additional_visitors:item)+) => { - impl<'de> Deserialize<'de> for $type_name { + impl<'de> serde::Deserialize<'de> for $type_name { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, @@ -89,6 +89,7 @@ macro_rules! custom_deserialize { /// Use the [`FromStr`] implementation of a type for deserialization if it is a /// string. +#[macro_export] macro_rules! derive_or_from_str { ( $(#[$global:meta])* @@ -110,7 +111,7 @@ macro_rules! derive_or_from_str { } - crate::types::custom_deserialize!( + $crate::types::custom_deserialize!( $s where $expect fn visit_map(self, map: A) -> Result where A: serde::de::MapAccess<'de>, { @@ -132,10 +133,10 @@ macro_rules! derive_or_from_str { }; } -use custom_deserialize; -use derive_or_from_str; -use deserialize_from_str; -use serialize_display; +pub use custom_deserialize; +pub use derive_or_from_str; +pub use deserialize_from_str; +pub use serialize_display; /// Describes which kind of work a database entry refers to. #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] @@ -287,8 +288,6 @@ impl FromStr for EntryType { pub enum DeserializationError { #[error("malformed date")] Date(#[from] time::DateError), - #[error("malformed duration")] - Duration(#[from] time::DurationError), #[error("malformed person")] Person(#[from] persons::PersonError), #[error("malformed numeric value")] @@ -383,158 +382,6 @@ impl From for MaybeTyped { } } -derive_or_from_str! { - /// An URL, possibly with a last visited date. - #[derive(Clone, Debug, PartialEq, Eq, Hash)] - pub struct QualifiedUrl where "URL string or dictionary with keys \"url\" and \"date\"" { - /// The [Url]. - pub value: Url, - /// The last visited date. - #[serde(rename = "date")] - pub visit_date: Option, - } -} - -impl Serialize for QualifiedUrl { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - if let Some(date) = &self.visit_date { - let mut map = serializer.serialize_map(Some(2))?; - map.serialize_entry("value", &self.value)?; - map.serialize_entry("date", date)?; - map.end() - } else { - self.value.serialize(serializer) - } - } -} - -impl QualifiedUrl { - /// Create a new qualified URL. - pub fn new(value: Url, visit_date: Option) -> Self { - Self { value, visit_date } - } -} - -impl FromStr for QualifiedUrl { - type Err = url::ParseError; - - fn from_str(s: &str) -> Result { - Ok(Self { value: Url::parse(s)?, visit_date: None }) - } -} - -impl Display for QualifiedUrl { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.value.fmt(f) - } -} - -derive_or_from_str! { - /// A publisher, possibly with a location. - #[derive(Clone, Debug, PartialEq, Eq, Hash)] - pub struct Publisher where "FormatString string or dictionary with \"name\" and \"location\"" { - /// Publisher of the item. - name: Option, - /// Physical location at which the item was published or created. - location: Option, - } -} - -impl Serialize for Publisher { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - if let Some(location) = &self.location { - let mut map = serializer.serialize_map(Some(2))?; - map.serialize_entry("name", &self.name)?; - map.serialize_entry("location", location)?; - map.end() - } else { - self.name.serialize(serializer) - } - } -} - -impl Publisher { - /// Create a new publisher. - pub fn new(name: Option, location: Option) -> Self { - Self { name, location } - } - - /// Publisher of the item. - pub fn name(&self) -> Option<&FormatString> { - self.name.as_ref() - } - - /// Physical location at which the item was published or created. - pub fn location(&self) -> Option<&FormatString> { - self.location.as_ref() - } -} - -impl FromStr for Publisher { - type Err = ChunkedStrParseError; - - /// Creates a new publisher with `s` as its name and no location. - fn from_str(s: &str) -> Result { - Ok(Publisher::new(Some(FormatString::from_str(s)?), None)) - } -} - -/// A set of serial numbers like DOIs, ISBNs, or ISSNs. -/// Keys should be lowercase. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Hash)] -#[serde(transparent)] -pub struct SerialNumber(pub BTreeMap); - -impl<'de> Deserialize<'de> for SerialNumber { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - #[derive(Deserialize)] - #[serde(untagged)] - enum Choice { - Map(BTreeMap), - Other(StringOrNumber), - } - - #[derive(Deserialize)] - #[serde(untagged)] - enum StringOrNumber { - String(String), - Number(i64), - UnsignedNumber(u64), - Float(f64), - } - - impl Display for StringOrNumber { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::String(s) => s.fmt(formatter), - Self::Number(n) => n.fmt(formatter), - Self::UnsignedNumber(n) => n.fmt(formatter), - Self::Float(f) => f.fmt(formatter), - } - } - } - - Choice::deserialize(deserializer).map(|choice| match choice { - Choice::Other(text) => SerialNumber(BTreeMap::from_iter(vec![( - "serial".to_owned(), - text.to_string(), - )])), - Choice::Map(map) => { - SerialNumber(map.into_iter().map(|(k, v)| (k, v.to_string())).collect()) - } - }) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/hayagriva-core/src/types/page.rs b/crates/hayagriva-core/src/types/page.rs index af85c893..bf550fd4 100644 --- a/crates/hayagriva-core/src/types/page.rs +++ b/crates/hayagriva-core/src/types/page.rs @@ -3,7 +3,6 @@ use std::fmt::Display; use std::num::TryFromIntError; use std::str::FromStr; -use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::types::{MaybeTyped, Numeric, NumericError}; diff --git a/crates/hayagriva-core/src/types/persons.rs b/crates/hayagriva-core/src/types/persons.rs index c4b00d56..3e9f53a6 100644 --- a/crates/hayagriva-core/src/types/persons.rs +++ b/crates/hayagriva-core/src/types/persons.rs @@ -3,88 +3,17 @@ use std::cmp::Ordering; use std::str::FromStr; use citationberg::LongShortForm; +use serde::Serialize; use serde::ser::SerializeMap; -use serde::{Deserialize, Serialize}; use thiserror::Error; use unicode_segmentation::UnicodeSegmentation; use crate::lang::en::ARTICLES; use crate::lang::is_cjk; use crate::lang::name::NAME_PARTICLES; -use crate::util::{deserialize_one_or_many, serialize_one_or_many}; use super::derive_or_from_str; -/// A list of persons with a common role. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] -pub struct PersonsWithRoles { - /// The persons. - #[serde(serialize_with = "serialize_one_or_many")] - #[serde(deserialize_with = "deserialize_one_or_many")] - pub names: Vec, - /// The role the persons had in the creation of the cited item. - pub role: PersonRole, -} - -impl PersonsWithRoles { - /// Create a new list of persons with a common role. - pub fn new(names: Vec, role: PersonRole) -> Self { - Self { names, role } - } -} - -/// Specifies the role a group of persons had in the creation to the -/// cited item. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] -#[non_exhaustive] -#[serde(rename_all = "kebab-case")] -pub enum PersonRole { - /// Translated the work from a foreign language to the cited edition. - Translator, - /// Authored an afterword. - Afterword, - /// Authored an foreword. - Foreword, - /// Authored an introduction. - Introduction, - /// Provided value-adding annotations. - Annotator, - /// Commented the work. - Commentator, - /// Holds a patent or similar. - Holder, - /// Compiled the works in an [Anthology](super::EntryType::Anthology). - Compiler, - /// Founded the publication. - Founder, - /// Collaborated on the cited item. - Collaborator, - /// Organized the creation of the cited item. - Organizer, - /// Performed in the cited item. - CastMember, - /// Composed all or parts of the cited item's musical / audible components. - Composer, - /// Produced the cited item. - Producer, - /// Lead Producer for the cited item. - ExecutiveProducer, - /// Did the writing for the cited item. - Writer, - /// Shot film/video for the cited item. - Cinematography, - /// Directed the cited item. - Director, - /// Illustrated the cited item. - Illustrator, - /// Provided narration or voice-over for the cited item. - Narrator, - - /// Various other roles described by the contained string. - #[serde(skip)] - Unknown(String), -} - derive_or_from_str! { /// Holds the name of a person. #[derive(Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/hayagriva-core/src/types/time.rs b/crates/hayagriva-core/src/types/time.rs index a2ef31ac..380d9081 100644 --- a/crates/hayagriva-core/src/types/time.rs +++ b/crates/hayagriva-core/src/types/time.rs @@ -7,8 +7,6 @@ use serde::{Deserialize, Serialize, de}; use thiserror::Error; use unscanny::Scanner; -use super::{derive_or_from_str, deserialize_from_str, serialize_display}; - /// A date that can be as coarse as a year and as fine-grained as a day. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct Date { @@ -331,249 +329,6 @@ impl Serialize for Date { } } -/// A duration. -#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)] -pub struct Duration { - /// Days (24 hours). - pub days: u32, - /// Hours (60 minutes). - pub hours: u32, - /// Minutes (60 seconds). - pub minutes: u32, - /// Seconds (1000 milliseconds). - pub seconds: u8, - /// Milliseconds. - pub milliseconds: u16, -} - -serialize_display!(Duration); -deserialize_from_str!(Duration); - -impl Duration { - fn scan(s: &mut Scanner, require_end: bool) -> Result { - let mut days = 0; - let mut hours = 0; - let mut minutes = 0; - let mut seconds = 0; - let mut milliseconds = 0; - - let idx = s.cursor(); - let colons = - s.eat_while(|c: char| c != '-').chars().filter(|c| c == &':').count(); - s.jump(idx); - - if !(1..=3).contains(&colons) { - return Err(DurationError::Malformed); - } - - let start = 3 - colons; - - for i in start..5 { - match i { - 0 => days = parse_unsigned_int(s, 1..).ok_or(DurationError::Malformed)?, - 1 => { - hours = if start == i { - parse_unsigned_int(s, 2..) - } else { - parse_unsigned_int(s, 2..=2) - } - .ok_or(DurationError::Malformed)? - } - 2 => { - minutes = if start == i { - parse_unsigned_int(s, 2..) - } else { - parse_unsigned_int(s, 2..=2) - } - .ok_or(DurationError::Malformed)? - } - 3 => { - seconds = - parse_unsigned_int(s, 2..=2).ok_or(DurationError::Malformed)? - } - 4 => { - s.eat_whitespace(); - let num = s.eat_while(char::is_numeric); - if num.is_empty() { - return Err(DurationError::Malformed); - } - let str = format!("0.{num}"); - let ms: f64 = str.parse().map_err(|_| DurationError::Malformed)?; - milliseconds = (ms * 1000.0).round() as u16; - } - _ => unreachable!(), - } - - if s.done() { - if i < 3 { - return Err(DurationError::Malformed); - } else { - break; - } - } - - s.eat_whitespace(); - - if i < 3 && !s.eat_if(':') { - return Err(DurationError::Malformed); - } else if i == 3 { - if s.peek() == Some('-') { - break; - } - if !s.eat_if(",") { - return Err(DurationError::Malformed); - } - } - } - - s.eat_whitespace(); - if require_end && !s.done() { - return Err(DurationError::Malformed); - } - - for i in (0..=start).rev() { - match i { - 0 => {} - 1 => { - days = hours / 24; - hours %= 24; - } - 2 => { - hours += minutes / 60; - minutes %= 60; - } - _ => unreachable!(), - } - } - - if hours >= 24 || minutes >= 60 || seconds >= 60 || milliseconds >= 1000 { - return Err(DurationError::TooLarge); - } - - Ok(Duration { days, hours, minutes, seconds, milliseconds }) - } - - /// Get the duration in milliseconds. - fn milliseconds(self) -> u64 { - self.milliseconds as u64 - + self.seconds as u64 * 1000 - + self.minutes as u64 * 60 * 1000 - + self.hours as u64 * 60 * 60 * 1000 - + self.days as u64 * 24 * 60 * 60 * 1000 - } -} - -impl PartialOrd for Duration { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for Duration { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.milliseconds().cmp(&other.milliseconds()) - } -} - -/// Errors that can occur when parsing a string to a duration -#[derive(Clone, Copy, Error, Debug, PartialEq, Eq, Hash)] -pub enum DurationError { - /// The string is malformed. - #[error("duration string malformed")] - Malformed, - /// The value is out of bounds when another, subsequent value is present (i.e. `01:61:48`). - #[error("out of bounds value when greater order value is specified")] - TooLarge, -} - -impl FromStr for Duration { - type Err = DurationError; - - fn from_str(s: &str) -> Result { - let mut s = Scanner::new(s); - Self::scan(&mut s, true) - } -} - -impl Display for Duration { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if self.days > 0 { - write!(f, "{}:", self.days)?; - } - - if self.hours > 0 { - write!(f, "{:02}:", self.hours)?; - } - - write!(f, "{:02}:{:02}", self.minutes, self.seconds)?; - - if self.milliseconds > 0 { - write!(f, ",{:03}", self.milliseconds)?; - } - - Ok(()) - } -} - -derive_or_from_str! { - /// An half-open interval of durations. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - pub struct DurationRange where "two durations separated by a hyphen or a map with a `from` and `to` field" { - /// The start of the interval. - pub start: Duration, - /// The end of the interval. - pub end: Duration, - } -} - -impl DurationRange { - /// Create a new duration range. - pub fn new(start: Duration, end: Option) -> Self { - Self { start, end: end.unwrap_or(start) } - } - - fn scan(s: &mut Scanner) -> Result { - let start = Duration::scan(s, false)?; - let hyphens = s.eat_while('-'); - - if hyphens.is_empty() { - s.eat_whitespace(); - - if s.done() { - return Ok(Self::new(start, None)); - } else { - return Err(DurationError::Malformed); - } - } - - let end = Duration::scan(s, true)?; - - Ok(Self { start, end }) - } -} - -impl Display for DurationRange { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.start)?; - if self.start != self.end { - write!(f, "-{}", self.end)?; - } - - Ok(()) - } -} - -impl FromStr for DurationRange { - type Err = DurationError; - - fn from_str(s: &str) -> Result { - let mut s = Scanner::new(s); - Self::scan(&mut s) - } -} - -serialize_display!(DurationRange); - fn parse_int(s: &mut Scanner, digits: R) -> Option where R: std::ops::RangeBounds, @@ -593,7 +348,7 @@ where Some(num) } -fn parse_unsigned_int(s: &mut Scanner, digits: R) -> Option +pub fn parse_unsigned_int(s: &mut Scanner, digits: R) -> Option where T: FromStr + Ord + Debug, ::Err: Debug, @@ -698,90 +453,3 @@ fn days_in_month(month: u8, year: i32) -> u8 { 30 + month % 2 } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_duration_parse() { - assert_eq!( - Duration::from_str("01:00").unwrap(), - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - } - ); - assert_eq!( - Duration::from_str("00:01:00").unwrap(), - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - } - ); - assert_eq!( - Duration::from_str("00 : 00 : 01 : 00").unwrap(), - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - } - ); - assert_eq!( - Duration::from_str("01:00,000").unwrap(), - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - } - ); - assert!(Duration::from_str("01:00,").is_err()); - assert!(Duration::from_str("010:00,").is_err()); - } - - #[test] - fn test_duration_range_parse() { - assert_eq!( - DurationRange::from_str("01:00").unwrap(), - DurationRange::new( - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - }, - None - ) - ); - assert_eq!( - DurationRange::from_str("01:00-02:00").unwrap(), - DurationRange::new( - Duration { - days: 0, - hours: 0, - minutes: 1, - seconds: 0, - milliseconds: 0, - }, - Some(Duration { - days: 0, - hours: 0, - minutes: 2, - seconds: 0, - milliseconds: 0, - }) - ) - ); - } -} diff --git a/crates/hayagriva-format/Cargo.toml b/crates/hayagriva-format/Cargo.toml index 25f9f97f..9796e771 100644 --- a/crates/hayagriva-format/Cargo.toml +++ b/crates/hayagriva-format/Cargo.toml @@ -21,10 +21,7 @@ unicode-segmentation = { workspace = true } hayagriva-core = { workspace = true } thiserror = { workspace = true } unscanny = { workspace = true } -url = { workspace = true, optional = true } +url = { workspace = true } [dev-dependencies] serde_json = "1" - -[features] -biblatex = ["dep:biblatex", "dep:url"] diff --git a/crates/hayagriva-format/src/citation_label.rs b/crates/hayagriva-format/src/citation_label.rs index 5625e00b..0227f9b3 100644 --- a/crates/hayagriva-format/src/citation_label.rs +++ b/crates/hayagriva-format/src/citation_label.rs @@ -3,9 +3,10 @@ use std::fmt::Write; use unicode_segmentation::UnicodeSegmentation; -use hayagriva_core::types::{EntryType, Person, PersonRole}; +use hayagriva_core::types::{EntryType, Person}; use crate::Entry; +use crate::types::PersonRole; /// Citation labels in the form of numbers. /// diff --git a/crates/hayagriva-format/src/interop.rs b/crates/hayagriva-format/src/interop.rs index 4bcc0627..c36aeac5 100644 --- a/crates/hayagriva-format/src/interop.rs +++ b/crates/hayagriva-format/src/interop.rs @@ -14,6 +14,8 @@ use url::Url; use hayagriva_core::types::*; +use crate::types::*; + use super::Entry; macro_rules! tex_kinds { @@ -664,7 +666,9 @@ fn comma_list(items: &[Vec>]) -> FormatString { mod tests { use unic_langid::LanguageIdentifier; - use hayagriva_core::types::{EntryType, MaybeTyped, PersonRole}; + use hayagriva_core::types::{EntryType, MaybeTyped}; + + use crate::types::PersonRole; #[test] fn test_pmid_from_biblatex() { diff --git a/crates/hayagriva-format/src/lib.rs b/crates/hayagriva-format/src/lib.rs index 70007896..e81d5a5d 100644 --- a/crates/hayagriva-format/src/lib.rs +++ b/crates/hayagriva-format/src/lib.rs @@ -77,6 +77,8 @@ use hayagriva_core::util::{ serialize_one_or_many_opt, }; +pub use crate::types::*; + pub use selectors::{Selector, SelectorError}; #[macro_use] @@ -87,6 +89,7 @@ pub mod citation_label; mod interop; pub mod io; mod taxonomy; +pub mod types; /// A collection of bibliographic entries. #[derive(Debug, Clone, Default, PartialEq, Serialize)] diff --git a/crates/hayagriva-format/src/taxonomy.rs b/crates/hayagriva-format/src/taxonomy.rs index cbe04f0b..cd9abf17 100644 --- a/crates/hayagriva-format/src/taxonomy.rs +++ b/crates/hayagriva-format/src/taxonomy.rs @@ -10,10 +10,11 @@ use unic_langid::LanguageIdentifier; use hayagriva_core::{ ChunkedString, Date, EntryLike, EntryType, MaybeTyped, Numeric, PageRanges, Person, - PersonRole, Publisher, StringChunk, + StringChunk, }; use crate::citation_label::Alphanumerical; +use crate::types::*; use super::Entry; diff --git a/crates/hayagriva-format/src/types/mod.rs b/crates/hayagriva-format/src/types/mod.rs new file mode 100644 index 00000000..eebf8286 --- /dev/null +++ b/crates/hayagriva-format/src/types/mod.rs @@ -0,0 +1,172 @@ +//! Types for the Hayagriva format. + +use std::{ + collections::BTreeMap, + fmt::{self, Display}, + str::FromStr, +}; + +use serde::{Deserialize, Serialize, ser::SerializeMap}; +use url::Url; + +use hayagriva_core::{ + ChunkedStrParseError, Date, FormatString, types::derive_or_from_str, +}; + +pub use person::*; +pub use time::*; + +mod person; +mod time; + +derive_or_from_str! { + /// An URL, possibly with a last visited date. + #[derive(Clone, Debug, PartialEq, Eq, Hash)] + pub struct QualifiedUrl where "URL string or dictionary with keys \"url\" and \"date\"" { + /// The [Url]. + pub value: Url, + /// The last visited date. + #[serde(rename = "date")] + pub visit_date: Option, + } +} + +impl Serialize for QualifiedUrl { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + if let Some(date) = &self.visit_date { + let mut map = serializer.serialize_map(Some(2))?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("date", date)?; + map.end() + } else { + self.value.serialize(serializer) + } + } +} + +impl QualifiedUrl { + /// Create a new qualified URL. + pub fn new(value: Url, visit_date: Option) -> Self { + Self { value, visit_date } + } +} + +impl FromStr for QualifiedUrl { + type Err = url::ParseError; + + fn from_str(s: &str) -> Result { + Ok(Self { value: Url::parse(s)?, visit_date: None }) + } +} + +impl Display for QualifiedUrl { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.value.fmt(f) + } +} + +derive_or_from_str! { + /// A publisher, possibly with a location. + #[derive(Clone, Debug, PartialEq, Eq, Hash)] + pub struct Publisher where "FormatString string or dictionary with \"name\" and \"location\"" { + /// Publisher of the item. + name: Option, + /// Physical location at which the item was published or created. + location: Option, + } +} + +impl Serialize for Publisher { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + if let Some(location) = &self.location { + let mut map = serializer.serialize_map(Some(2))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("location", location)?; + map.end() + } else { + self.name.serialize(serializer) + } + } +} + +impl Publisher { + /// Create a new publisher. + pub fn new(name: Option, location: Option) -> Self { + Self { name, location } + } + + /// Publisher of the item. + pub fn name(&self) -> Option<&FormatString> { + self.name.as_ref() + } + + /// Physical location at which the item was published or created. + pub fn location(&self) -> Option<&FormatString> { + self.location.as_ref() + } +} + +impl FromStr for Publisher { + type Err = ChunkedStrParseError; + + /// Creates a new publisher with `s` as its name and no location. + fn from_str(s: &str) -> Result { + Ok(Publisher::new(Some(FormatString::from_str(s)?), None)) + } +} + +/// A set of serial numbers like DOIs, ISBNs, or ISSNs. +/// Keys should be lowercase. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Hash)] +#[serde(transparent)] +pub struct SerialNumber(pub BTreeMap); + +impl<'de> Deserialize<'de> for SerialNumber { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + #[derive(Deserialize)] + #[serde(untagged)] + enum Choice { + Map(BTreeMap), + Other(StringOrNumber), + } + + #[derive(Deserialize)] + #[serde(untagged)] + enum StringOrNumber { + String(String), + Number(i64), + UnsignedNumber(u64), + Float(f64), + } + + impl Display for StringOrNumber { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::String(s) => s.fmt(formatter), + Self::Number(n) => n.fmt(formatter), + Self::UnsignedNumber(n) => n.fmt(formatter), + Self::Float(f) => f.fmt(formatter), + } + } + } + + Choice::deserialize(deserializer).map(|choice| match choice { + Choice::Other(text) => SerialNumber(BTreeMap::from_iter(vec![( + "serial".to_owned(), + text.to_string(), + )])), + Choice::Map(map) => { + SerialNumber(map.into_iter().map(|(k, v)| (k, v.to_string())).collect()) + } + }) + } +} diff --git a/crates/hayagriva-format/src/types/person.rs b/crates/hayagriva-format/src/types/person.rs new file mode 100644 index 00000000..1af409a8 --- /dev/null +++ b/crates/hayagriva-format/src/types/person.rs @@ -0,0 +1,74 @@ +use serde::{Deserialize, Serialize}; + +use hayagriva_core::Person; +use hayagriva_core::util::{deserialize_one_or_many, serialize_one_or_many}; + +/// A list of persons with a common role. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] +pub struct PersonsWithRoles { + /// The persons. + #[serde(serialize_with = "serialize_one_or_many")] + #[serde(deserialize_with = "deserialize_one_or_many")] + pub names: Vec, + /// The role the persons had in the creation of the cited item. + pub role: PersonRole, +} + +impl PersonsWithRoles { + /// Create a new list of persons with a common role. + pub fn new(names: Vec, role: PersonRole) -> Self { + Self { names, role } + } +} + +/// Specifies the role a group of persons had in the creation to the +/// cited item. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[non_exhaustive] +#[serde(rename_all = "kebab-case")] +pub enum PersonRole { + /// Translated the work from a foreign language to the cited edition. + Translator, + /// Authored an afterword. + Afterword, + /// Authored an foreword. + Foreword, + /// Authored an introduction. + Introduction, + /// Provided value-adding annotations. + Annotator, + /// Commented the work. + Commentator, + /// Holds a patent or similar. + Holder, + /// Compiled the works in an [Anthology](super::EntryType::Anthology). + Compiler, + /// Founded the publication. + Founder, + /// Collaborated on the cited item. + Collaborator, + /// Organized the creation of the cited item. + Organizer, + /// Performed in the cited item. + CastMember, + /// Composed all or parts of the cited item's musical / audible components. + Composer, + /// Produced the cited item. + Producer, + /// Lead Producer for the cited item. + ExecutiveProducer, + /// Did the writing for the cited item. + Writer, + /// Shot film/video for the cited item. + Cinematography, + /// Directed the cited item. + Director, + /// Illustrated the cited item. + Illustrator, + /// Provided narration or voice-over for the cited item. + Narrator, + + /// Various other roles described by the contained string. + #[serde(skip)] + Unknown(String), +} diff --git a/crates/hayagriva-format/src/types/time.rs b/crates/hayagriva-format/src/types/time.rs new file mode 100644 index 00000000..776d9e09 --- /dev/null +++ b/crates/hayagriva-format/src/types/time.rs @@ -0,0 +1,338 @@ +use std::{fmt::Display, str::FromStr}; + +use thiserror::Error; +use unscanny::Scanner; + +use hayagriva_core::{ + derive_or_from_str, deserialize_from_str, parse_unsigned_int, serialize_display, +}; + +/// A duration. +#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)] +pub struct Duration { + /// Days (24 hours). + pub days: u32, + /// Hours (60 minutes). + pub hours: u32, + /// Minutes (60 seconds). + pub minutes: u32, + /// Seconds (1000 milliseconds). + pub seconds: u8, + /// Milliseconds. + pub milliseconds: u16, +} + +serialize_display!(Duration); +deserialize_from_str!(Duration); + +impl Duration { + fn scan(s: &mut Scanner, require_end: bool) -> Result { + let mut days = 0; + let mut hours = 0; + let mut minutes = 0; + let mut seconds = 0; + let mut milliseconds = 0; + + let idx = s.cursor(); + let colons = + s.eat_while(|c: char| c != '-').chars().filter(|c| c == &':').count(); + s.jump(idx); + + if !(1..=3).contains(&colons) { + return Err(DurationError::Malformed); + } + + let start = 3 - colons; + + for i in start..5 { + match i { + 0 => days = parse_unsigned_int(s, 1..).ok_or(DurationError::Malformed)?, + 1 => { + hours = if start == i { + parse_unsigned_int(s, 2..) + } else { + parse_unsigned_int(s, 2..=2) + } + .ok_or(DurationError::Malformed)? + } + 2 => { + minutes = if start == i { + parse_unsigned_int(s, 2..) + } else { + parse_unsigned_int(s, 2..=2) + } + .ok_or(DurationError::Malformed)? + } + 3 => { + seconds = + parse_unsigned_int(s, 2..=2).ok_or(DurationError::Malformed)? + } + 4 => { + s.eat_whitespace(); + let num = s.eat_while(char::is_numeric); + if num.is_empty() { + return Err(DurationError::Malformed); + } + let str = format!("0.{num}"); + let ms: f64 = str.parse().map_err(|_| DurationError::Malformed)?; + milliseconds = (ms * 1000.0).round() as u16; + } + _ => unreachable!(), + } + + if s.done() { + if i < 3 { + return Err(DurationError::Malformed); + } else { + break; + } + } + + s.eat_whitespace(); + + if i < 3 && !s.eat_if(':') { + return Err(DurationError::Malformed); + } else if i == 3 { + if s.peek() == Some('-') { + break; + } + if !s.eat_if(",") { + return Err(DurationError::Malformed); + } + } + } + + s.eat_whitespace(); + if require_end && !s.done() { + return Err(DurationError::Malformed); + } + + for i in (0..=start).rev() { + match i { + 0 => {} + 1 => { + days = hours / 24; + hours %= 24; + } + 2 => { + hours += minutes / 60; + minutes %= 60; + } + _ => unreachable!(), + } + } + + if hours >= 24 || minutes >= 60 || seconds >= 60 || milliseconds >= 1000 { + return Err(DurationError::TooLarge); + } + + Ok(Duration { days, hours, minutes, seconds, milliseconds }) + } + + /// Get the duration in milliseconds. + fn milliseconds(self) -> u64 { + self.milliseconds as u64 + + self.seconds as u64 * 1000 + + self.minutes as u64 * 60 * 1000 + + self.hours as u64 * 60 * 60 * 1000 + + self.days as u64 * 24 * 60 * 60 * 1000 + } +} + +impl PartialOrd for Duration { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Duration { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.milliseconds().cmp(&other.milliseconds()) + } +} + +/// Errors that can occur when parsing a string to a duration +#[derive(Clone, Copy, Error, Debug, PartialEq, Eq, Hash)] +pub enum DurationError { + /// The string is malformed. + #[error("duration string malformed")] + Malformed, + /// The value is out of bounds when another, subsequent value is present (i.e. `01:61:48`). + #[error("out of bounds value when greater order value is specified")] + TooLarge, +} + +impl FromStr for Duration { + type Err = DurationError; + + fn from_str(s: &str) -> Result { + let mut s = Scanner::new(s); + Self::scan(&mut s, true) + } +} + +impl Display for Duration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.days > 0 { + write!(f, "{}:", self.days)?; + } + + if self.hours > 0 { + write!(f, "{:02}:", self.hours)?; + } + + write!(f, "{:02}:{:02}", self.minutes, self.seconds)?; + + if self.milliseconds > 0 { + write!(f, ",{:03}", self.milliseconds)?; + } + + Ok(()) + } +} + +derive_or_from_str! { + /// An half-open interval of durations. + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + pub struct DurationRange where "two durations separated by a hyphen or a map with a `from` and `to` field" { + /// The start of the interval. + pub start: Duration, + /// The end of the interval. + pub end: Duration, + } +} + +impl DurationRange { + /// Create a new duration range. + pub fn new(start: Duration, end: Option) -> Self { + Self { start, end: end.unwrap_or(start) } + } + + fn scan(s: &mut Scanner) -> Result { + let start = Duration::scan(s, false)?; + let hyphens = s.eat_while('-'); + + if hyphens.is_empty() { + s.eat_whitespace(); + + if s.done() { + return Ok(Self::new(start, None)); + } else { + return Err(DurationError::Malformed); + } + } + + let end = Duration::scan(s, true)?; + + Ok(Self { start, end }) + } +} + +impl Display for DurationRange { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.start)?; + if self.start != self.end { + write!(f, "-{}", self.end)?; + } + + Ok(()) + } +} + +impl FromStr for DurationRange { + type Err = DurationError; + + fn from_str(s: &str) -> Result { + let mut s = Scanner::new(s); + Self::scan(&mut s) + } +} + +serialize_display!(DurationRange); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_duration_parse() { + assert_eq!( + Duration::from_str("01:00").unwrap(), + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + } + ); + assert_eq!( + Duration::from_str("00:01:00").unwrap(), + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + } + ); + assert_eq!( + Duration::from_str("00 : 00 : 01 : 00").unwrap(), + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + } + ); + assert_eq!( + Duration::from_str("01:00,000").unwrap(), + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + } + ); + assert!(Duration::from_str("01:00,").is_err()); + assert!(Duration::from_str("010:00,").is_err()); + } + + #[test] + fn test_duration_range_parse() { + assert_eq!( + DurationRange::from_str("01:00").unwrap(), + DurationRange::new( + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + }, + None + ) + ); + assert_eq!( + DurationRange::from_str("01:00-02:00").unwrap(), + DurationRange::new( + Duration { + days: 0, + hours: 0, + minutes: 1, + seconds: 0, + milliseconds: 0, + }, + Some(Duration { + days: 0, + hours: 0, + minutes: 2, + seconds: 0, + milliseconds: 0, + }) + ) + ); + } +} From 439e28e09f343950f40764eb54b1c25240db3a6b Mon Sep 17 00:00:00 2001 From: DerDrodt Date: Fri, 31 Jul 2026 22:28:27 +0200 Subject: [PATCH 31/31] Fix CI and docs --- .github/workflows/archive.yml | 2 +- crates/hayagriva-csl/src/lib.rs | 4 ++-- crates/hayagriva-format/src/types/person.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/archive.yml b/.github/workflows/archive.yml index b6d03acd..4ca26517 100644 --- a/.github/workflows/archive.yml +++ b/.github/workflows/archive.yml @@ -25,4 +25,4 @@ jobs: cd .. git clone --depth 1 https://github.com/citation-style-language/styles - name: Check if archives are up-to-date - run: cargo test -p hayagriva-archive --test archiver -- --ignored + run: cargo test --test test -- archiver --ignored diff --git a/crates/hayagriva-csl/src/lib.rs b/crates/hayagriva-csl/src/lib.rs index f37c9c35..952566c7 100644 --- a/crates/hayagriva-csl/src/lib.rs +++ b/crates/hayagriva-csl/src/lib.rs @@ -29,10 +29,10 @@ //! }; //! use citationberg::{LocaleFile, IndependentStyle}; //! -//! let en_locale = fs::read_to_string("../tests/tests/data/locales-en-US.xml").unwrap(); +//! let en_locale = fs::read_to_string("../../tests/data/locales-en-US.xml").unwrap(); //! let locales = [LocaleFile::from_xml(&en_locale).unwrap().into()]; //! -//! let style = fs::read_to_string("../tests/tests/data/art-history.csl").unwrap(); +//! let style = fs::read_to_string("../../tests/data/art-history.csl").unwrap(); //! let style = IndependentStyle::from_xml(&style).unwrap(); //! //! let mut driver = BibliographyDriver::new(); diff --git a/crates/hayagriva-format/src/types/person.rs b/crates/hayagriva-format/src/types/person.rs index 1af409a8..653dc11d 100644 --- a/crates/hayagriva-format/src/types/person.rs +++ b/crates/hayagriva-format/src/types/person.rs @@ -41,7 +41,7 @@ pub enum PersonRole { Commentator, /// Holds a patent or similar. Holder, - /// Compiled the works in an [Anthology](super::EntryType::Anthology). + /// Compiled the works in an [Anthology](hayagriva_core::EntryType::Anthology). Compiler, /// Founded the publication. Founder,