### Utilize Hayagriva Command Line Interface Source: https://context7.com/typst/hayagriva/llms.txt Provides examples for using the Hayagriva CLI to perform common tasks such as converting BibTeX to YAML, generating formatted bibliographies, and filtering entries using selectors. ```bash # Install the CLI cargo install hayagriva --features cli # Convert BibTeX to YAML hayagriva literature.bib > literature.yaml # Generate reference list with APA style hayagriva literature.yaml reference --style apa # Generate Chicago-style bibliography hayagriva literature.yaml reference --style chicago-author-date # Generate in-text citations hayagriva literature.yaml cite --style mla --key einstein1905 # Combine multiple citations hayagriva literature.yaml cite --style apa --key key1,key2,key3 --combined # Add locators to citations hayagriva literature.yaml cite --style chicago-author-date --locators "p. 45,pp. 100-150" # Filter with selectors hayagriva literature.yaml --select "article > periodical" reference --style apa # Show matching keys hayagriva literature.yaml --select "*[url]" --show-keys # Show selector bindings hayagriva literature.yaml --select "a:article > b:periodical" --show-bound # Use custom CSL file hayagriva literature.yaml reference --csl custom-style.csl # Use custom locale files hayagriva literature.yaml reference --style apa --locales en-US.xml,de-DE.xml # List all available styles hayagriva styles # Output without ANSI formatting hayagriva literature.yaml reference --style apa --no-fmt ``` -------------------------------- ### Install Hayagriva CLI Source: https://github.com/typst/hayagriva/blob/main/README.md Installs the Hayagriva Command Line Interface using Cargo, the Rust package manager. This command enables the 'cli' feature for full functionality. ```bash cargo install hayagriva --features cli ``` -------------------------------- ### Date Field Example Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the 'date' field, specifying the publication date of an item. It accepts a date format, commonly YYYY-MM. ```typst date: 1949-05 ``` -------------------------------- ### Filter Bibliographic Entries with Hayagriva Selectors Source: https://github.com/typst/hayagriva/blob/main/README.md This example demonstrates how to parse a YAML bibliographic entry and apply a selector using the 'select!' macro. It shows the syntax for matching specific entry types and fields, ensuring the entry meets the defined criteria. ```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 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())); ``` -------------------------------- ### Publisher Field Examples Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates the 'publisher' field, which can be a simple name or a structured object including the publisher's name and location. ```typst publisher: Penguin Books ``` ```typst publisher: name: Penguin Books location: London ``` -------------------------------- ### YAML Example: Article with Multiple Parents (Conference and Video) Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates representing an article that has multiple publication contexts, such as being presented at a conference and also having an associated video. This uses a list for the 'parent' field to accommodate multiple entries. ```yaml wwdc-network: type: Article author: ["Mehta, Jiten", "Kinnear, Eric"] title: Boost Performance and Security with Modern Networking date: 2020-06-26 parent: - type: Conference title: World Wide Developer Conference 2020 organization: Apple Inc. location: Mountain View, CA - type: Video runtime: "00:13:42" url: https://developer.apple.com/videos/play/wwdc2020/10111/ ``` -------------------------------- ### CSL Delimiter Inheritance Example Source: https://github.com/typst/hayagriva/blob/main/tests/local/choose_UseAncestorsDelimiter.txt A CSL style demonstrating how delimiters interact with group and choose elements. It highlights how the underscore delimiter is applied to top-level elements but not within nested groups or macros. ```xml ``` -------------------------------- ### Bibliographic Data Input Example Source: https://github.com/typst/hayagriva/blob/main/tests/local/page_NumberPage.txt This JSON structure represents a sample input for bibliographic data. It includes essential fields like 'id', 'page' range, 'title', and 'type' of the work, which can be processed by citation management tools. ```json [ { "id": "ITEM-1", "page": "22-45", "title": "His Anonymous Life", "type": "book" } ] ``` -------------------------------- ### Location Field Example Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows the 'location' field for specifying the physical location where an item is located or an event took place. This is distinct from the publication location. ```typst location: Lahore, Pakistan ``` -------------------------------- ### Genre Field Example Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the 'genre' field, used to specify the type or class of the item, such as 'Doctoral dissertation'. It should not be used for topical categories. ```typst genre: Doctoral dissertation ``` -------------------------------- ### YAML Example: Nested Parent Hierarchy (Artwork within Anthology) Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows a complex publication hierarchy where an item (an informational plaque) has a parent (Artwork) which itself has a parent (Anthology). This demonstrates the recursive nature of the 'parent' field in Hayagriva. ```yaml plaque: type: Misc title: Informational plaque about Jacoby's 1967 photos publisher: name: Stiftung Reinbeckhallen location: Berlin, Germany date: 2020 parent: type: Artwork date: 1967 author: Jacoby, Max parent: type: Anthology title: Bleibtreustraße archive: Landesmuseum Koblenz archive-location: Koblenz, Germany ``` -------------------------------- ### Handling Complex Field Values with Nested Mappings in YAML Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows how to represent complex data within a single field using nested mappings. This example uses the 'url' field to store both the web address ('value') and an associated access date ('date'), demonstrating two YAML syntaxes for nested structures. ```yaml url: value: http://www.techno.org/electronic-music-guide/ date: 2020-11-30 ``` ```yaml url: { value: http://www.techno.org/electronic-music-guide/, date: 2020-11-30 } ``` -------------------------------- ### YAML Example: Article with Single Parent Periodical Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates how to represent an article published within a periodical using the 'parent' field in Hayagriva's YAML format. It shows fields for the article and its parent journal, including title, author, and publication details. ```yaml kinetics: type: Article title: Kinetics and luminescence of the excitations of a nonequilibrium polariton condensate author: ["Doan, T. D.", "Tran Thoai, D. B.", "Haug, Hartmut"] serial-number: doi: "10.1103/PhysRevB.102.165126" page-range: 165126-165139 date: 2020-10-14 parent: type: Periodical title: Physical Review B volume: 102 issue: 16 publisher: American Physical Society ``` -------------------------------- ### Construct Bibliography Entries Programmatically Source: https://context7.com/typst/hayagriva/llms.txt Shows how to use the Entry struct to build bibliography entries, set fields like authors, dates, and parent relationships, and export the resulting library to YAML format. ```rust use hayagriva::{Entry, Library}; use hayagriva::types::{EntryType, Date, Person, FormatString, Numeric, MaybeTyped}; use hayagriva::io::to_yaml_str; // Create a new article entry let mut article = Entry::new("my-article", EntryType::Article); article.set_title(FormatString::new("A Groundbreaking Discovery")); article.set_authors(vec![ Person::from_strings(&["Einstein"], Some(&["Albert"]), None, None), Person::from_strings(&["Curie"], Some(&["Marie"]), None, None), ]); article.set_date(Date::from_year(2023)); article.set_doi("10.1234/example.doi".to_string()); article.set_page_range(MaybeTyped::Typed("100-150".parse().unwrap())); // Create parent (journal) let mut journal = Entry::new("my-article", EntryType::Periodical); journal.set_title(FormatString::new("Nature Physics")); journal.set_volume(MaybeTyped::Typed(Numeric::from(15))); journal.set_issue(MaybeTyped::Typed(Numeric::from(3))); // Set parent relationship article.set_parents(vec![journal]); // Build a library let mut library = Library::new(); library.push(&article); // Export to YAML let yaml_output = to_yaml_str(&library).unwrap(); println!("{}", yaml_output); ``` -------------------------------- ### Define Formattable String with Short Form Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Configures a field to provide both a full value and a shortened version for citation styles. ```yaml journal: value: International Proceedings of Customs short: Int. Proc. Customs ``` -------------------------------- ### Hayagriva Advanced Selection and Output Source: https://github.com/typst/hayagriva/blob/main/README.md Demonstrates advanced usage of Hayagriva with custom selectors to filter entries and options to show bound sub-entries or just keys. The '--select' argument allows complex filtering based on entry fields, and '--show-bound' or '--keys' controls the output format. ```bash hayagriva literature.yaml --select "*[url] | *[doi]" reference ``` ```bash hayagriva literature.yaml --select "a:*[volume] | * > a:[volume]" --show-bound ``` ```bash hayagriva literature.yaml --select "a:*[volume] | * > a:[volume]" --keys ``` -------------------------------- ### Parse YAML Bibliography and Format Citations in Rust Source: https://github.com/typst/hayagriva/blob/main/README.md Demonstrates parsing a bibliography from a YAML string using `from_yaml_str` and then formatting it into a reference list using `BibliographyDriver`, `CitationRequest`, and CSL styles. It requires locale and style files. ```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_string()); } ``` -------------------------------- ### Basic YAML Structure for Literature Items Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the fundamental structure of a Hayagriva YAML file, showing how to define literature items with keys and their associated properties like type, title, author, and date. ```yaml harry: type: Book title: Harry Potter and the Order of the Phoenix author: Rowling, J. K. volume: 5 page-total: 768 date: 2003-06-21 electronic: type: Web title: Ishkur's Guide to Electronic Music serial-number: v2.5 author: Ishkur url: http://www.techno.org/electronic-music-guide/ ``` -------------------------------- ### Representing Multi-Value Fields (Authors) in YAML Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates two common YAML syntaxes for representing fields that can have multiple values, such as the 'author' field for works with multiple contributors. It shows both the compact array notation and the more verbose hyphen-prefixed list. ```yaml author: ["Omarova, Saule", "Steele, Graham"] ``` ```yaml author: - Omarova, Saule - Steele, Graham ``` -------------------------------- ### Define a List of Persons with Roles Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows how to associate a specific role with one or more persons using a mapping structure. ```yaml role: ExecutiveProducer names: ["Simon, David", "Colesberry, Robert F.", "Noble, Nina Kostroff"] ``` -------------------------------- ### Filter Bibliography Entries with Selectors Source: https://context7.com/typst/hayagriva/llms.txt Demonstrates how to use the select! macro and Selector::parse to filter bibliography entries based on types, hierarchical relationships, fields, and negation. It shows how to match specific parent-child relationships and extract data using bindings. ```rust use hayagriva::{Selector, select}; use hayagriva::io::from_yaml_str; let yaml = r#" journal-article: type: Article title: Research on Climate Change author: Smith, John date: 2023 url: https://example.com/article parent: type: Periodical title: Environmental Science Journal volume: 10 conference-paper: type: Article title: Machine Learning Advances author: Johnson, Alice date: 2022 parent: type: Proceedings title: ICML 2022 book-chapter: type: Chapter title: Introduction to Algorithms author: Williams, Bob date: 2021 parent: type: Book title: Computer Science Fundamentals website: type: Web title: Online Documentation url: https://docs.example.com date: 2023 "#; let library = from_yaml_str(yaml).unwrap(); // Match articles in periodicals (journals) let journal_selector = select!(Article > Periodical); for entry in library.iter().filter(|e| journal_selector.matches(e)) { println!("Journal article: {}", entry.key()); } // Match articles in proceedings (conferences) let conf_selector = Selector::parse("article > proceedings").unwrap(); for entry in library.iter().filter(|e| conf_selector.matches(e)) { println!("Conference paper: {}", entry.key()); } // Match entries with URL field let url_selector = select!(*["url"]); for entry in library.iter().filter(|e| url_selector.matches(e)) { println!("Has URL: {}", entry.key()); } // Bindings: capture matching parents let binding_selector = Selector::parse("article > parent:(periodical | newspaper)").unwrap(); for entry in library.iter() { if let Some(bindings) = binding_selector.apply(entry) { if let Some(parent) = bindings.get("parent") { println!("{} published in: {:?}", entry.key(), parent.title()); } } } ``` -------------------------------- ### Access Archived Citation Styles in Rust Source: https://context7.com/typst/hayagriva/llms.txt Shows how to access and use over 100 bundled citation styles from the CSL repository using the `archive` module. It covers listing all available styles, retrieving specific styles by name or enum, and accessing style metadata and locales for internationalization. Dependencies include the hayagriva crate. ```Rust use hayagriva::archive::ArchivedStyle; use citationberg::Style; // List all available styles for style in ArchivedStyle::all() { println!("{}: {}", style.names()[0], style.display_name()); } // Get style by name let ieee = ArchivedStyle::by_name("ieee").unwrap(); let Style::Independent(ieee_style) = ieee.get() else { panic!() }; println!("IEEE CSL ID: {}", ieee.csl_id()); // Common styles available: let apa = ArchivedStyle::AmericanPsychologicalAssociation; // "apa" let mla = ArchivedStyle::ModernLanguageAssociation; // "mla" let chicago = ArchivedStyle::ChicagoAuthorDate; // "chicago-author-date" let nature = ArchivedStyle::Nature; // "nature" let vancouver = ArchivedStyle::Vancouver; // "vancouver" // Get style metadata let style = apa.get(); println!("Style title: {}", style.info().title.value); for author in style.info().authors.iter() { println!("Style author: {}", author.name); } // Get locales for internationalization use hayagriva::archive::locales; let all_locales = locales(); // Returns Vec with 50+ locales ``` -------------------------------- ### Define a Person with Sub-fields Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates how to explicitly define a person using sub-fields like name, given-name, and alias when standard string formatting is insufficient. ```yaml author: given-name: Gloria Jean name: Watkins alias: bell hooks ``` -------------------------------- ### Define Formattable String with Case Preservation Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates how to preserve specific casing in a formattable string by wrapping segments in braces. ```yaml publisher: "{imagiNary} Publishing" ``` -------------------------------- ### Format Citations with BibliographyDriver in Rust Source: https://context7.com/typst/hayagriva/llms.txt Demonstrates how to use the BibliographyDriver to process citation requests and generate formatted in-text citations and bibliographies. It involves parsing YAML data for citation entries, selecting a CSL style (APA), and configuring the driver. Dependencies include the hayagriva and citationberg crates. ```Rust use hayagriva::{ BibliographyDriver, BibliographyRequest, CitationItem, CitationRequest, }; use hayagriva::io::from_yaml_str; use hayagriva::archive::{ArchivedStyle, locales}; use citationberg::Style; let yaml = r#" machine-learning: type: Article title: Deep Learning for Natural Language Processing author: ["Chen, Wei", "Zhang, Li"] date: 2022-08 page-range: 45-78 parent: type: Periodical title: AI Research Quarterly volume: 15 issue: 2 neural-networks: type: Book title: Neural Networks and Deep Learning author: Nielsen, Michael date: 2015 publisher: Determination Press "#; let library = from_yaml_str(yaml).unwrap(); // Get APA style from archive let Style::Independent(apa) = ArchivedStyle::AmericanPsychologicalAssociation.get() else { panic!("Expected independent style") }; let locales = locales(); // Create bibliography driver let mut driver = BibliographyDriver::new(); // Add citations for entry in library.iter() { let items = vec![CitationItem::with_entry(entry)]; driver.citation(CitationRequest::from_items(items, &apa, &locales)); } // Generate formatted output let result = driver.finish(BibliographyRequest { style: &apa, locale: None, locale_files: &locales, }); // Print in-text citations println!("Citations:"); for cite in &result.citations { println!(" {}", cite.citation); } // Print bibliography if let Some(bib) = &result.bibliography { println!("\nReferences:"); for item in &bib.items { println!(" {}", item.content); } } ``` -------------------------------- ### POST /api/bibliography/format Source: https://github.com/typst/hayagriva/blob/main/README.md Formats bibliography entries into citations using a specified CSL style. ```APIDOC ## POST /api/bibliography/format ### Description Uses a BibliographyDriver to process citation requests against a CSL style and locale, returning formatted output. ### Method POST ### Endpoint /api/bibliography/format ### Request Body - **entries** (array) - Required - List of bibliography entries to format. - **style_xml** (string) - Required - The CSL style definition in XML format. ### Request Example { "entries": [{"id": "crazy-rich"}], "style_xml": "" } ### Response #### Success Response (200) - **citations** (array) - List of formatted citation strings. #### Response Example { "citations": ["(Kwan, 2014)"] } ``` -------------------------------- ### Sample Citation Input Data Source: https://github.com/typst/hayagriva/blob/main/tests/local/page_NumberPageSort.txt This JSON array represents sample citation data, including item IDs, page numbers, titles, and types. This data would typically be processed by a citation engine using a CSL style. ```json [ { "id": "ITEM-1", "page": "3", "title": "A", "type": "book" }, { "id": "ITEM-2", "page": "5", "title": "B", "type": "book" }, { "id": "ITEM-3", "page": "22-45", "title": "C", "type": "book" }, { "id": "ITEM-4", "page": "33", "title": "D", "type": "book" }, { "id": "ITEM-5", "page": "46", "title": "E", "type": "book" }, { "id": "ITEM-6", "page": "450, 60-30 & 8", "title": "F", "type": "book" } ] ``` -------------------------------- ### Sample Citation Input Data Source: https://github.com/typst/hayagriva/blob/main/tests/local/date_LocalizedDateDelimiters.txt This JSON object represents sample data for a citation item. It includes an ID, issue date, title, and type. This data would be processed by a CSL style to generate a formatted citation. ```json [ { "id": "ITEM-1", "issued": { "date-parts": [ [ 2025, 9, 15 ] ] }, "title": "Ignore me", "type": "book" } ] ``` -------------------------------- ### Perform Standalone Citation Formatting in Rust Source: https://context7.com/typst/hayagriva/llms.txt Demonstrates how to use the standalone_citation function to generate citations without a full BibliographyDriver. It covers basic citation generation and the inclusion of specific locators like page ranges. ```rust use hayagriva::{standalone_citation, CitationItem, CitationRequest, SpecificLocator, LocatorPayload}; use hayagriva::io::from_yaml_str; use hayagriva::archive::{ArchivedStyle, locales}; use citationberg::{Style, taxonomy::Locator}; let yaml = r#" example: type: Book title: Example Book Title author: Smith, John date: 2020 publisher: Academic Press page-total: 350 "#; let library = from_yaml_str(yaml).unwrap(); let entry = library.get("example").unwrap(); let Style::Independent(chicago) = ArchivedStyle::ChicagoAuthorDate.get() else { panic!() }; let locales = locales(); // Basic citation let items = vec![CitationItem::with_entry(entry)]; let request = CitationRequest::from_items(items, &chicago, &locales); let citation = standalone_citation(request); println!("Citation: {}", citation); // Citation with page locator let mut item_with_locator = CitationItem::with_entry(entry); item_with_locator.locator = Some(SpecificLocator( Locator::Page, LocatorPayload::Str("45-50"), )); let request = CitationRequest::from_items(vec![item_with_locator], &chicago, &locales); let citation = standalone_citation(request); println!("With pages: {}", citation); ``` -------------------------------- ### POST /api/bibliography/parse Source: https://github.com/typst/hayagriva/blob/main/README.md Parses a YAML string into a Hayagriva bibliography collection. ```APIDOC ## POST /api/bibliography/parse ### Description Parses a raw YAML string representing a literature collection into a structured bibliography object. ### Method POST ### Endpoint /api/bibliography/parse ### Request Body - **yaml_content** (string) - Required - The YAML string containing literature entries. ### Request Example { "yaml_content": "crazy-rich:\n type: Book\n title: Crazy Rich Asians\n author: Kwan, Kevin\n date: 2014" } ### Response #### Success Response (200) - **status** (string) - Success message - **entries** (object) - Parsed bibliography entries #### Response Example { "status": "success", "entries": { "crazy-rich": { "title": "Crazy Rich Asians", "date": 2014 } } } ``` -------------------------------- ### Generate Reference List with Hayagriva Source: https://github.com/typst/hayagriva/blob/main/README.md Generates a formatted reference list from a Hayagriva YAML literature file. It defaults to the Chicago Manual of Style (17th edition), Author-Date style. The '--style' flag can be used to specify alternative citation styles like APA. ```bash hayagriva literature.yaml reference ``` ```bash hayagriva literature.yaml reference --style apa ``` -------------------------------- ### Convert BibLaTeX Entry to Hayagriva Entry in Rust Source: https://github.com/typst/hayagriva/blob/main/README.md Shows how to convert a BibLaTeX entry into Hayagriva's native `Entry` struct. This requires adding the `biblatex` crate as a dependency. ```rust use hayagriva::Entry; let converted: Entry = your_biblatex_entry.into(); ``` -------------------------------- ### Abstract Field Usage Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows the 'abstract' field for providing a summary or abstract of the item's content. It accepts a formattable string. ```typst abstract: The dominant sequence transduction models are based on complex... ``` -------------------------------- ### Define Verbatim Formattable String Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Shows how to disable automatic case transformation for a field by setting the verbatim property to true. ```yaml publisher: value: UN World Food Programme verbatim: true ``` -------------------------------- ### Define a Numeric Range Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the use of numeric variables which can include prefixes, suffixes, and range delimiters. ```yaml page-range: S10-15 ``` -------------------------------- ### Define a Timestamp Range Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates the format for a range of timestamps, requiring double-quotes due to the presence of colons. ```yaml time-range: "03:35:21-03:58:46" ``` -------------------------------- ### Hayagriva Selector Syntax Source: https://github.com/typst/hayagriva/blob/main/docs/selectors.md Overview of the selector syntax used to filter and retrieve bibliographic entries in Hayagriva. ```APIDOC ## Selector Syntax Overview ### Description Selectors provide a mechanism to query entries by structure, type, and field presence. They can be used via command-line strings or the `select!` macro in Rust. ### Selector Types - **Entry Type**: Matches top-level types (e.g., `thesis` or `Thesis`). - **Wildcard**: `*` matches every entry. - **Required Fields**: `type[field1, field2]` matches entries where specified fields are present. - **Negation**: `!selector` matches everything that does not satisfy the inner selector. - **Disjunction**: `selector1 | selector2` matches if either selector is satisfied. ### Usage Examples #### Basic Type Selection - String: `thesis` - Macro: `Thesis` #### Field Filtering - String: `artwork[archive, archive-location]` - Macro: `Artwork["archive", "archive-location"]` #### Complex Disjunction - String: `(video | audio | web[runtime])[affiliated]` - Macro: `(Video | Audio | (Web["runtime"]))["affiliated"]` ``` -------------------------------- ### Convert BibTeX to YAML with Hayagriva Source: https://github.com/typst/hayagriva/blob/main/README.md Converts a BibTeX file (.bib) to YAML format using Hayagriva. The output is printed to standard output, allowing redirection to a file. This is useful for migrating bibliography data. ```bash hayagriva literature.bib > converted.yaml ``` -------------------------------- ### Generate In-text Citation with Hayagriva Source: https://github.com/typst/hayagriva/blob/main/README.md Generates an in-text citation for specific entries in a literature file using the '--key' argument. Multiple keys can be provided as a comma-separated list. The '--style' flag can also be used to customize the citation format. ```bash hayagriva literature.yaml cite --key feminism ``` ```bash hayagriva literature.yaml cite --key feminism --style apa ``` -------------------------------- ### Use Hayagriva Without Default Features in TOML Source: https://github.com/typst/hayagriva/blob/main/README.md Illustrates how to configure Hayagriva in `Cargo.toml` to exclude default features, such as BibTeX and BibLaTeX compatibility, for a smaller dependency footprint. ```toml [dependencies] hayagriva = { version = "0.9", default-features = false } ``` -------------------------------- ### Parent Entry Structure Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates the 'parent' field, used to link an item to its parent entry or a strongly associated item. It can specify the parent's type, title, and editor. ```typst parent: type: Anthology title: Automata studies editor: ["Shannon, C. E.", "McCarthy, J."] ``` -------------------------------- ### Parse BibLaTeX/BibTeX String to Library in Rust Source: https://context7.com/typst/hayagriva/llms.txt Converts a BibTeX or BibLaTeX formatted string into Hayagriva's native `Library` format using `hayagriva::io::from_biblatex_str`. This function facilitates interoperability with existing bibliography databases by translating standard citation formats into Hayagriva's internal representation. It allows iteration over the parsed entries and extraction of specific fields like DOI. ```rust use hayagriva::io::from_biblatex_str; let bibtex = r#"@article{einstein1905, author = {Einstein, Albert}, title = {On the Electrodynamics of Moving Bodies}, journal = {Annalen der Physik}, year = {1905}, volume = {17}, pages = {891--921}, doi = {10.1002/andp.19053221004} } @book{knuth1997, author = {Knuth, Donald E.}, title = {The Art of Computer Programming}, publisher = {Addison-Wesley}, year = {1997}, volume = {1}, edition = {3} } @inproceedings{turing1936, author = {Turing, Alan M.}, title = {On Computable Numbers}, booktitle = {Proceedings of the London Mathematical Society}, year = {1936}, pages = {230--265} } "#; let library = from_biblatex_str(bibtex).unwrap(); for entry in library.iter() { println!("{}: {:?}", entry.key(), entry.entry_type()); if let Some(doi) = entry.doi() { println!(" DOI: {}", doi); } } ``` -------------------------------- ### Organization Field Usage Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the 'organization' field, used to indicate the organization at or for which an item was produced. ```typst organization: Technische Universität Berlin ``` -------------------------------- ### Define CSL Citation Style with Date Macros Source: https://github.com/typst/hayagriva/blob/main/tests/local/date_NegativeDateSortViaMacroOnYearMonthOnly.txt This CSL snippet defines macros for short and long date formats and configures a citation sort order based on the short date and title. It demonstrates how to structure date-part variables for citation output. ```xml ``` -------------------------------- ### Citation Data Structures Source: https://github.com/typst/hayagriva/blob/main/tests/local/collapse_CitationNumberRangesSort.txt These snippets represent the input data for citations and the structure of citation items. The CITATION-ITEMS show grouped citation IDs, while INPUT provides metadata for each item, including ID and title. ```json [ [ { "id": "ITEM-1" }, { "id": "ITEM-2" }, { "id": "ITEM-3" }, { "id": "ITEM-4" } ], [ { "id": "ITEM-2" }, { "id": "ITEM-1" }, { "id": "ITEM-4" }, { "id": "ITEM-3" } ] ] ``` ```json [ { "id": "ITEM-1", "title": "Paper 1", "type": "book" }, { "id": "ITEM-2", "title": "Paper 2", "type": "book" }, { "id": "ITEM-3", "title": "Paper 3", "type": "book" }, { "id": "ITEM-4", "title": "Paper 4", "type": "book" } ] ``` -------------------------------- ### Typst Citation Mode Configuration Source: https://github.com/typst/hayagriva/blob/main/tests/local/page_NumberPageSort.txt This section indicates the active mode for Typst processing, which is set to 'citation'. This mode is crucial for enabling citation-related functionalities within Typst. ```typst >>===== MODE =====>> citation <<===== MODE =====<< ``` -------------------------------- ### Abstract Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Provides an abstract or summary of the item, such as a journal article's abstract. ```APIDOC ## Abstract Field ### Description Abstract of the item (e.g. the abstract of a journal article). ### Data Type formattable string ### Example ```yaml abstract: The dominant sequence transduction models are based on complex... ``` ``` -------------------------------- ### Date Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Represents the date at which an item was published. ```APIDOC ## Date Field ### Description Represents the date at which the item was published. ### Data Type date ### Example ```yaml date: 1949-05 ``` ``` -------------------------------- ### Genre Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Defines the type, class, or subtype of the item. Use for classification, not topical descriptions. ```APIDOC ## Genre Field ### Description Type, class, or subtype of the item (e.g. "Doctoral dissertation" for a PhD thesis; "NIH Publication" for an NIH technical report). Do not use for topical descriptions or categories (e.g. "adventure" for an adventure movie). ### Data Type formattable string ### Example ```yaml genre: Doctoral dissertation ``` ``` -------------------------------- ### Parse YAML Bibliography String to Library in Rust Source: https://context7.com/typst/hayagriva/llms.txt Parses a YAML string into a `Library` object using `hayagriva::io::from_yaml_str`. This function handles the conversion of YAML-formatted bibliography data, including hierarchical parent relationships, into Hayagriva's internal data structures. It allows for accessing entries by key, iterating through all entries, and retrieving library size. ```rust use hayagriva::io::from_yaml_str; let yaml = r#"# quantum-computing: type: Article title: Quantum Computing Fundamentals author: ["Smith, Alice", "Johnson, Bob"] date: 2023-05-15 serial-number: doi: "10.1234/example.2023" page-range: 100-125 parent: type: Periodical title: Journal of Computer Science volume: 45 issue: 3 rust-book: type: Book title: The Rust Programming Language author: ["Klabnik, Steve", "Nichols, Carol"] date: 2019 publisher: No Starch Press location: San Francisco, CA edition: 2 "#; let library = from_yaml_str(yaml).unwrap(); // Access entries by key let article = library.get("quantum-computing").unwrap(); assert_eq!(article.date().unwrap().year, 2023); assert_eq!(article.authors().unwrap().len(), 2); // Iterate over all entries for entry in library.iter() { println!("Key: {}, Type: {:?}", entry.key(), entry.entry_type()); if let Some(title) = entry.title() { println!(" Title: {}", title.value); } } // Get library size println!("Total entries: {}", library.len()); ``` -------------------------------- ### Parent Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Specifies the item in which the current item was published or to which it is strongly associated. ```APIDOC ## Parent Field ### Description Item in which the item was published / to which it is strongly associated to. ### Data Type entry ### Example ```yaml parent: type: Anthology title: Automata studies editor: ["Shannon, C. E.", "McCarthy, J."] ``` ``` -------------------------------- ### CSL Citation Style Definition Source: https://github.com/typst/hayagriva/blob/main/tests/local/date_LocalizedDateDelimiters.txt This CSL (Citation Style Language) XML defines a citation style for Typst. It specifies how dates should be formatted within citations, using a 'text' form with month, day, and year components. The 'delimiter="FAIL"' in the date layout is likely a placeholder or an indicator of a specific formatting requirement. ```xml ``` -------------------------------- ### Define CSL Date Macro and Citation Sort Source: https://github.com/typst/hayagriva/blob/main/tests/local/date_NegativeDateSortViaMacro.txt This CSL snippet defines a macro for formatting dates and configures the citation element to sort entries based on the issued date. It demonstrates how to structure date parts for consistent citation output. ```xml ``` -------------------------------- ### Organization Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Indicates the organization at or for which the item was produced. ```APIDOC ## Organization Field ### Description Organization at/for which the item was produced. ### Data Type formattable string ### Example ```yaml organization: Technische Universität Berlin ``` ``` -------------------------------- ### Editor Field Format Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Illustrates the 'editor' field, which can be a single person or a list of persons responsible for the item's content. ```typst editor: - Stringer, Gary A. - Pebworth, Ted-Larry ``` -------------------------------- ### Location Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Specifies the physical location where an entry is located or an event took place. Use 'publisher' for publication locations. ```APIDOC ## Location Field ### Description Location at which an entry is physically located or took place. For the location where an item was published, see `publisher`. ### Data Type formattable string ### Example ```yaml location: Lahore, Pakistan ``` ``` -------------------------------- ### CSL Citation Style Configuration Source: https://github.com/typst/hayagriva/blob/main/tests/local/collapse_CitationNumberRangesSort.txt This snippet defines a CSL (Citation Style Language) style for citations. It specifies that citations should be collapsed into number ranges and formatted with square brackets around the citation number, separated by a comma and space. ```xml ``` -------------------------------- ### CSL Citation Style for Page Numbers Source: https://github.com/typst/hayagriva/blob/main/tests/local/page_NumberPageSort.txt This CSL (Citation Style Language) file defines a citation style specifically for formatting page numbers. It sorts citations by page number and uses a semicolon and space as a delimiter. ```xml ``` -------------------------------- ### Publisher Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Identifies the publisher of the item, optionally including location. ```APIDOC ## Publisher Field ### Description Publisher of the item. ### Data Type publisher ### Example ```yaml publisher: Penguin Books ``` ### Example with Location ```yaml publisher: name: Penguin Books location: London ``` ``` -------------------------------- ### Input Data for Citations Source: https://github.com/typst/hayagriva/blob/main/tests/local/position_IbidIsNotIbidWithLocator.txt This JSON structure represents the input data for citations, including unique item identifiers and their associated metadata such as titles. This data is processed by the CSL style to generate the final citation output. ```json [ { "id": "ITEM-1", "title": "A", "type": "book" } ] ``` -------------------------------- ### Citation Items Structure Source: https://github.com/typst/hayagriva/blob/main/tests/local/position_IbidIsNotIbidWithLocator.txt This JSON array represents the structured citation items, where each inner array contains objects with 'id' and 'locator' properties. This format is used to track which items are being cited and their specific locations. ```json [ [ { "id": "ITEM-1", "locator": "33" } ], [ { "id": "ITEM-1", "locator": "33" } ], [ { "id": "ITEM-1", "locator": "34" } ] ] ``` -------------------------------- ### Configure CSL Citation Sorting Source: https://github.com/typst/hayagriva/blob/main/tests/local/date_NegativeDateSort.txt This CSL snippet defines a citation style that sorts items based on the 'issued' variable. It uses a layout that formats the date components (year, month, day) separated by hyphens. ```xml ``` -------------------------------- ### Call Number Field Source: https://github.com/typst/hayagriva/blob/main/docs/file-format.md Demonstrates the 'call-number' field, used for library or collection identification numbers. It is typically used in conjunction with the 'archive' field. ```typst call-number: "F16 D14" ```