Expand description
A library for parsing CSL styles.
Citationberg deserializes CSL styles from XML into Rust structs. It supports CSL 1.0.2.
This crate is not a CSL processor, so you are free to choose whatever data model and data types you need for your bibliographic needs. If you need to render citations, you can use Hayagriva which uses this crate under the hood.
Parse your style like this:
use std::fs;
use citationberg::Style;
let string = fs::read_to_string("tests/independent/ieee.csl")?;
let style = citationberg::Style::from_xml(&string)?;
let Style::Independent(independent) = style else {
panic!("IEEE is an independent style");
};
assert_eq!(independent.info.title.value, "IEEE");You can also parse a DependentStyle or a IndependentStyle directly.
Modules§
- taxonomy
- CSL constants that describe entries, terms, and variables.
Structs§
- Affixes
- Prefixes and suffixes.
- Bibliography
- Formatting instructions for the bibliography.
- Choose
- A conditional group of formatting instructions.
- Choose
Branch - A single branch of a conditional group.
- Citation
- Formatting instructions for in-text or note citations.
- CslMacro
- A reusable set of formatting instructions.
- Date
- Formats a date.
- Date
Part - Override the default date parts.
- Dependent
Style - A dependent CSL style.
- Else
Branch - The formatting instructions to use if no branch matches.
- EtAl
- Configure the et al. abbreviation.
- Formatting
- Formatting properties.
- Group
- A group of formatting instructions that is only shown if no variable is referenced or at least one referenced variable is populated.
- Independent
Style - An independent CSL style.
- Independent
Style Settings - A style with its own formatting rules.
- Info
Link - A link with more information about the style.
- Inheritable
Name Options - Global configuration of how to print names.
- Label
- Print a label for a number variable.
- Layout
- A formatting rule.
- License
- A license description.
- Local
String - A string annotated with a locale.
- Locale
- Supplemental localization data in a citation style.
- Locale
Code - An RFC 1766 language code.
- Locale
File - Root element of a locale file.
- Locale
Info - Metadata of a locale.
- Locale
Options - Options for the locale.
- Localized
Term - A localized term.
- Name
- Configuration of how to print names.
- Name
Options - Definite name options. Obtain from
Name::optionsusingInheritableNameOptions. - Name
Part - How to format a given name part.
- Names
- Renders a list of names.
- Number
- Renders a number.
- Ordinal
Lookup - Get the right forms of ordinal terms for numbers.
- Sort
- How to sort elements in a bibliography or citation.
- Style
Attribution - A person affiliated with the style.
- Style
Info - Citation style metadata
- Substitute
- What to do if the name variable is empty.
- Terms
- Term localization container.
- Text
- Print a term or variable.
- Timestamp
- An ISO 8601 chapter 5.4 timestamp.
- Variableless
Label - A label without its variable.
Enums§
- Base
Language - The base language in a
LocaleCode. - Choose
Match - How to handle the set of tests in a conditional group.
- Choose
Test - A single test in a conditional group.
- Citation
Format - What type of in-text citation is used.
- Collapse
- How to collapse cites with similar items.
- Date
AnyForm - Any allowable date part format.
- Date
DayForm - How a day is formatted.
- Date
Form - Localized date formats.
- Date
Month Form - How a month is formatted.
- Date
Part Name - The kind of a date part with its
formattribute. - Date
Parts - Which parts of a date should be included.
- Date
Strong AnyForm - Strongly typed date part formats.
- Delimiter
Behavior - When delimiters shall be inserted.
- Demote
NonDropping Particle - How to treat the non-dropping name particle when printing names.
- Disambiguation
Rule - When to expand names that are ambiguous in short form.
- Display
- On which layout level to display the citation.
- EtAl
Term - Which term to use for et al.
- Field
- In which academic field the style is used.
- Font
Style - Font style.
- Font
Variant - Font variant.
- Font
Weight - Font weight.
- Grammar
Gender - A grammatical gender. Use
Nonefor neutral. - Info
Link Rel - How a link relates to the style.
- Label
Pluralize - How to pluralize a label.
- Layout
Rendering Element - Possible parts of a formatting rule.
- Long
Short Form - Whether to format something in long or short form.
- NameAnd
- How to render the delimiter before the last name.
- Name
AsSort Order - In which order to print the names.
- Name
Form - How many name parts to print.
- Name
Label Position - Where the
cs:labelelement within acs:nameselement appeared relative tocs:name. - Name
Part Name - Which part of the name a
NamePartapplies to. - Names
Child - Possible children for a
cs:nameselement. - Number
Form - How a number is formatted.
- Ordinal
Match - Specify when which ordinal term is used.
- Page
Range Format - How to reformat page ranges.
- Purge
Level - How much metadata to remove from the style.
- Rendering
Element - Rendering elements.
- Second
Field Align - How to position the first field if the second field is aligned in a bibliography.
- Sort
Direction - The direction to sort in.
- SortKey
- A sorting key.
- Style
- A CSL style.
- Style
Category - Which category this style belongs in.
- Style
Class - How the citations are displayed.
- Style
Validation Error - An error that occurred while validating a style.
- Subsequent
Author Substitute Rule - How to replace subsequent identical names in a bibliography.
- Term
Form - The variant of a term translation.
- Test
Position - Possible positions of a citation in the citations to the same item.
- Text
Case - How to format text.
- Text
Decoration - Text decoration.
- Text
Target - Various kinds of text targets.
- Vertical
Align - Vertical alignment.
Traits§
- ToAffixes
- Allow every struct with affix properties to convert to a
Affixes. - ToFormatting
- Allow every struct with formatting properties to convert to a
Formatting.
Type Aliases§
- XmlDe
Error - Error type for functions that deserialize XML.
- XmlDe
Result - Result type for functions that deserialize XML.
- XmlSe
Error - Error type for functions that serialize XML.
- XmlSe
Result - Result type for functions that serialize XML.