Crate citationberg

Crate citationberg 

Source
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.
ChooseBranch
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.
DatePart
Override the default date parts.
DependentStyle
A dependent CSL style.
ElseBranch
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.
IndependentStyle
An independent CSL style.
IndependentStyleSettings
A style with its own formatting rules.
InfoLink
A link with more information about the style.
InheritableNameOptions
Global configuration of how to print names.
Label
Print a label for a number variable.
Layout
A formatting rule.
License
A license description.
LocalString
A string annotated with a locale.
Locale
Supplemental localization data in a citation style.
LocaleCode
An RFC 1766 language code.
LocaleFile
Root element of a locale file.
LocaleInfo
Metadata of a locale.
LocaleOptions
Options for the locale.
LocalizedTerm
A localized term.
Name
Configuration of how to print names.
NameOptions
Definite name options. Obtain from Name::options using InheritableNameOptions.
NamePart
How to format a given name part.
Names
Renders a list of names.
Number
Renders a number.
OrdinalLookup
Get the right forms of ordinal terms for numbers.
Sort
How to sort elements in a bibliography or citation.
StyleAttribution
A person affiliated with the style.
StyleInfo
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.
VariablelessLabel
A label without its variable.

Enums§

BaseLanguage
The base language in a LocaleCode.
ChooseMatch
How to handle the set of tests in a conditional group.
ChooseTest
A single test in a conditional group.
CitationFormat
What type of in-text citation is used.
Collapse
How to collapse cites with similar items.
DateAnyForm
Any allowable date part format.
DateDayForm
How a day is formatted.
DateForm
Localized date formats.
DateMonthForm
How a month is formatted.
DatePartName
The kind of a date part with its form attribute.
DateParts
Which parts of a date should be included.
DateStrongAnyForm
Strongly typed date part formats.
DelimiterBehavior
When delimiters shall be inserted.
DemoteNonDroppingParticle
How to treat the non-dropping name particle when printing names.
DisambiguationRule
When to expand names that are ambiguous in short form.
Display
On which layout level to display the citation.
EtAlTerm
Which term to use for et al.
Field
In which academic field the style is used.
FontStyle
Font style.
FontVariant
Font variant.
FontWeight
Font weight.
GrammarGender
A grammatical gender. Use None for neutral.
InfoLinkRel
How a link relates to the style.
LabelPluralize
How to pluralize a label.
LayoutRenderingElement
Possible parts of a formatting rule.
LongShortForm
Whether to format something in long or short form.
NameAnd
How to render the delimiter before the last name.
NameAsSortOrder
In which order to print the names.
NameForm
How many name parts to print.
NameLabelPosition
Where the cs:label element within a cs:names element appeared relative to cs:name.
NamePartName
Which part of the name a NamePart applies to.
NamesChild
Possible children for a cs:names element.
NumberForm
How a number is formatted.
OrdinalMatch
Specify when which ordinal term is used.
PageRangeFormat
How to reformat page ranges.
PurgeLevel
How much metadata to remove from the style.
RenderingElement
Rendering elements.
SecondFieldAlign
How to position the first field if the second field is aligned in a bibliography.
SortDirection
The direction to sort in.
SortKey
A sorting key.
Style
A CSL style.
StyleCategory
Which category this style belongs in.
StyleClass
How the citations are displayed.
StyleValidationError
An error that occurred while validating a style.
SubsequentAuthorSubstituteRule
How to replace subsequent identical names in a bibliography.
TermForm
The variant of a term translation.
TestPosition
Possible positions of a citation in the citations to the same item.
TextCase
How to format text.
TextDecoration
Text decoration.
TextTarget
Various kinds of text targets.
VerticalAlign
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§

XmlDeError
Error type for functions that deserialize XML.
XmlDeResult
Result type for functions that deserialize XML.
XmlSeError
Error type for functions that serialize XML.
XmlSeResult
Result type for functions that serialize XML.