citeproc-hs-0.3.2: A Citation Style Language implementation in Haskell

Portability | unportable
Stability | unstable
Maintainer | Andrea Rossato <andrea.rossato@unitn.it>

Text.CSL.Style

Description

The Style types

Synopsis

- data Style = Style {
  - styleVersion :: String
  - styleClass :: String
  - styleInfo :: Maybe CSInfo
  - styleDefaultLocale :: String
  - styleLocale :: [Locale]
  - csOptions :: [Option]
  - csMacros :: [MacroMap]
  - citation :: Citation
  - biblio :: Maybe Bibliography
  }
- data Locale = Locale {
  - localeVersion :: String
  - localeLang :: String
  - localeOptions :: [Option]
  - localeTermMap :: [TermMap]
  - localeDate :: [Element]
  }
- mergeLocales :: String -> Locale -> [Locale] -> [Locale]
- type TermMap = ((String, Form), (String, String))
- type MacroMap = (String, [Element])
- data Citation = Citation {
  - citOptions :: [Option]
  - citSort :: [Sort]
  - citLayout :: Layout
  }
- data Bibliography = Bibliography {
  - bibOptions :: [Option]
  - bibSort :: [Sort]
  - bibLayout :: Layout
  }
- type Option = (String, String)
- mergeOptions :: [Option] -> [Option] -> [Option]
- data Layout = Layout {
  - layFormat :: Formatting
  - layDelim :: Delimiter
  - elements :: [Element]
  }
- data Element
  - = Choose IfThen [IfThen] [Element]
  - | Macro String Formatting
  - | Const String Formatting
  - | Variable [String] Form Formatting Delimiter
  - | Term String Form Formatting Bool
  - | Label String Form Formatting Plural
  - | Number String NumericForm Formatting
  - | ShortNames [String] Formatting Delimiter
  - | Names [String] [Name] Formatting Delimiter [Element]
  - | Substitute [Element]
  - | Group Formatting Delimiter [Element]
  - | Date [String] DateForm Formatting Delimiter [DatePart] String
- data IfThen = IfThen Condition Match [Element]
- data Condition = Condition {
  - isType :: [String]
  - isSet :: [String]
  - isNumeric :: [String]
  - isUncertainDate :: [String]
  - isPosition :: [String]
  - disambiguation :: [String]
  - isLocator :: [String]
  }
- type Delimiter = String
- data Match
  - = Any
  - | All
  - | None
- match :: Match -> [Bool] -> Bool
- data DatePart = DatePart {
  - dpName :: String
  - dpForm :: String
  - dpRangeDelim :: String
  - dpFormatting :: Formatting
  }
- defaultDate :: [DatePart]
- data Sort
  - = SortVariable String Sorting
  - | SortMacro String Sorting Int Int String
- data Sorting
  - = Ascending String
  - | Descending String
- compare' :: String -> String -> Ordering
- data Form
  - = Long
  - | Short
  - | Count
  - | Verb
  - | VerbShort
  - | Symbol
  - | NotSet
- data NumericForm
  - = Numeric
  - | Ordinal
  - | Roman
  - | LongOrdinal
- data DateForm
  - = TextDate
  - | NumericDate
  - | NoFormDate
- data Plural
  - = Contextual
  - | Always
  - | Never
- data Name
  - = Name Form Formatting NameAttrs Delimiter [NamePart]
  - | NameLabel Form Formatting Plural
  - | EtAl Formatting String
- type NameAttrs = [(String, String)]
- data NamePart = NamePart String Formatting
- isName :: Name -> Bool
- isNames :: Element -> Bool
- hasEtAl :: [Name] -> Bool
- data Formatting = Formatting {
  - prefix :: String
  - suffix :: String
  - fontFamily :: String
  - fontStyle :: String
  - fontVariant :: String
  - fontWeight :: String
  - textDecoration :: String
  - verticalAlign :: String
  - textCase :: String
  - display :: String
  - quotes :: Bool
  - stripPeriods :: Bool
  - noCase :: Bool
  - noDecor :: Bool
  }
- emptyFormatting :: Formatting
- unsetAffixes :: Formatting -> Formatting
- mergeFM :: Formatting -> Formatting -> Formatting
- data CSInfo = CSInfo {
  - csiTitle :: String
  - csiAuthor :: CSAuthor
  - csiCategories :: [CSCategory]
  - csiId :: String
  - csiUpdated :: String
  }
- data CSAuthor = CSAuthor String String String
- data CSCategory = CSCategory String String String
- data FormattedOutput
  - = FO Formatting [FormattedOutput]
  - | FN String Formatting
  - | FS String Formatting
  - | FDel String
  - | FPan [Inline]
  - | FNull
- data Output
  - = ONull
  - | OSpace
  - | OPan [Inline]
  - | ODel String
  - | OStr String Formatting
  - | ONum Int Formatting
  - | OCitNum Int Formatting
  - | OYear String String Formatting
  - | OYearSuf String String [Output] Formatting
  - | OName String [Output] [[Output]] Formatting
  - | OContrib String String [Output] [Output] [[Output]]
  - | Output [Output] Formatting
- data Affix
  - = PlainText String
  - | PandocText [Inline]
- type Citations = [[Cite]]
- data Cite = Cite {
  - citeId :: String
  - citePrefix :: Affix
  - citeSuffix :: Affix
  - citeLabel :: String
  - citeLocator :: String
  - citeNoteNumber :: String
  - citePosition :: String
  - nearNote :: Bool
  - authorInText :: Bool
  - suppressAuthor :: Bool
  - citeHash :: Int
  }
- emptyAffix :: Affix
- emptyCite :: Cite
- data CitationGroup = CG [(Cite, Output)] Formatting Delimiter [(Cite, Output)]
- data BiblioData = BD {
  - citations :: [[FormattedOutput]]
  - bibliography :: [[FormattedOutput]]
  }
- data CiteData = CD {
  - key :: String
  - collision :: [Output]
  - disambYS :: [Output]
  - disambData :: [[Output]]
  - disambed :: [Output]
  - citYear :: String
  }
- data NameData = ND {
  - nameKey :: String
  - nameCollision :: [Output]
  - nameDisambData :: [[Output]]
  - nameDataSolved :: [Output]
  }
- formatOutputList :: [Output] -> [FormattedOutput]
- formatOutput :: Output -> FormattedOutput
- mapGroupOutput :: (Output -> [a]) -> CitationGroup -> [a]
- proc :: (Typeable a, Data b) => (a -> a) -> b -> b
- proc' :: (Typeable a, Data b) => (a -> a) -> b -> b
- query :: (Typeable a, Data b) => (a -> [c]) -> b -> [c]
- rmGivenNames :: Output -> Output
- rmNameHash :: Output -> Output
- rmContribs :: Output -> Output
- addGivenNames :: [Output] -> [Output]
- addYearSuffix :: Output -> Output
- hasYear :: Output -> Bool
- hasYearSuf :: Output -> Bool
- betterThen :: Eq a => [a] -> [a] -> [a]

# Documentation

data Style

The representation of a parsed CSL style.

Constructors

Style |

Fields

styleVersion :: String
styleClass :: String
styleInfo :: Maybe CSInfo
styleDefaultLocale :: String
styleLocale :: [Locale]
csOptions :: [Option]
csMacros :: [MacroMap]
citation :: Citation
biblio :: Maybe Bibliography

Instances

Data Style |
Show Style |
Typeable Style |

data Locale

Constructors

Locale |

Fields

localeVersion :: String
localeLang :: String
localeOptions :: [Option]
localeTermMap :: [TermMap]
localeDate :: [Element]

Instances

Eq Locale |
Data Locale |
Show Locale |
Typeable Locale |

mergeLocales :: String -> Locale -> [Locale] -> [Locale]

With the `defaultLocale`, the locales-xx-XX.xml loaded file and the parsed `Style` cs:locale elements, produce the final `Locale` as the only element of a list, taking into account CSL locale prioritization.

type TermMap = ((String, Form), (String, String))

type MacroMap = (String, [Element])

data Citation

Constructors

Citation |

Fields

citOptions :: [Option]
citSort :: [Sort]
citLayout :: Layout

Instances

Data Citation |
Show Citation |
Typeable Citation |

data Bibliography

Constructors

Bibliography |

Fields

bibOptions :: [Option]
bibSort :: [Sort]
bibLayout :: Layout

Instances

Data Bibliography |
Show Bibliography |
Typeable Bibliography |

type Option = (String, String)

mergeOptions :: [Option] -> [Option] -> [Option]

data Layout

Constructors

Layout |

Fields

layFormat :: Formatting
layDelim :: Delimiter
elements :: [Element]

Instances

Data Layout |
Show Layout |
Typeable Layout |
XmlPickler Layout |

data Element

Constructors

Choose IfThen [IfThen] [Element] |
Macro String Formatting |
Const String Formatting |
Variable [String] Form Formatting Delimiter |
Term String Form Formatting Bool |
Label String Form Formatting Plural |
Number String NumericForm Formatting |
ShortNames [String] Formatting Delimiter |
Names [String] [Name] Formatting Delimiter [Element] |
Substitute [Element] |
Group Formatting Delimiter [Element] |
Date [String] DateForm Formatting Delimiter [DatePart] String |

Instances

Eq Element |
Data Element |
Show Element |
Typeable Element |
XmlPickler Element |

data IfThen

Constructors

IfThen Condition Match [Element] |

Instances

Eq IfThen |
Data IfThen |
Show IfThen |
Typeable IfThen |
XmlPickler IfThen |

data Condition

Constructors

Condition |

Fields

isType :: [String]
isSet :: [String]
isNumeric :: [String]
isUncertainDate :: [String]
isPosition :: [String]
disambiguation :: [String]
isLocator :: [String]

Instances

Eq Condition |
Data Condition |
Show Condition |
Typeable Condition |
XmlPickler Condition |

type Delimiter = String

data Match

Constructors

Any |
All |
None |

Instances

Eq Match |
Data Match |
Read Match |
Show Match |
Typeable Match |
XmlPickler Match |

match :: Match -> [Bool] -> Bool

data DatePart

Constructors

DatePart |

Fields

dpName :: String
dpForm :: String
dpRangeDelim :: String
dpFormatting :: Formatting

Instances

Eq DatePart |
Data DatePart |
Show DatePart |
Typeable DatePart |
XmlPickler DatePart |

defaultDate :: [DatePart]

data Sort

Constructors

SortVariable String Sorting |
SortMacro String Sorting Int Int String |

Instances

Eq Sort |
Data Sort |
Show Sort |
Typeable Sort |
XmlPickler Sort |

data Sorting

Constructors

Ascending String |
Descending String |

Instances

Eq Sorting |
Data Sorting |
Ord Sorting |
Read Sorting |
Show Sorting |
Typeable Sorting |

compare' :: String -> String -> Ordering

data Form

Constructors

Long |
Short |
Count |
Verb |
VerbShort |
Symbol |
NotSet |

Instances

Eq Form |
Data Form |
Read Form |
Show Form |
Typeable Form |
XmlPickler Form |

data NumericForm

Constructors

Numeric |
Ordinal |
Roman |
LongOrdinal |

Instances

Eq NumericForm |
Data NumericForm |
Read NumericForm |
Show NumericForm |
Typeable NumericForm |
XmlPickler NumericForm |

data DateForm

Constructors

TextDate |
NumericDate |
NoFormDate |

Instances

Eq DateForm |
Data DateForm |
Read DateForm |
Show DateForm |
Typeable DateForm |
XmlPickler DateForm |

data Plural

Constructors

Contextual |
Always |
Never |

Instances

Eq Plural |
Data Plural |
Read Plural |
Show Plural |
Typeable Plural |

data Name

Constructors

Name Form Formatting NameAttrs Delimiter [NamePart] |
NameLabel Form Formatting Plural |
EtAl Formatting String |

Instances

Eq Name |
Data Name |
Show Name |
Typeable Name |
XmlPickler Name |

type NameAttrs = [(String, String)]

data NamePart

Constructors

NamePart String Formatting |

Instances

Eq NamePart |
Data NamePart |
Show NamePart |
Typeable NamePart |
XmlPickler NamePart |

isName :: Name -> Bool

isNames :: Element -> Bool

hasEtAl :: [Name] -> Bool

data Formatting

Constructors

Formatting |

Fields

prefix :: String
suffix :: String
fontFamily :: String
fontStyle :: String
fontVariant :: String
fontWeight :: String
textDecoration :: String
verticalAlign :: String
textCase :: String
display :: String
quotes :: Bool
stripPeriods :: Bool
noCase :: Bool
noDecor :: Bool

Instances

Eq Formatting |
Data Formatting |
Ord Formatting |
Read Formatting |
Show Formatting |
Typeable Formatting |
XmlPickler Formatting |

emptyFormatting :: Formatting

unsetAffixes :: Formatting -> Formatting

mergeFM :: Formatting -> Formatting -> Formatting

data CSInfo

Constructors

CSInfo |

Fields

csiTitle :: String
csiAuthor :: CSAuthor
csiCategories :: [CSCategory]
csiId :: String
csiUpdated :: String

Instances

Data CSInfo |
Read CSInfo |
Show CSInfo |
Typeable CSInfo |
XmlPickler CSInfo |

data CSAuthor

Constructors

CSAuthor String String String |

Instances

Eq CSAuthor |
Data CSAuthor |
Read CSAuthor |
Show CSAuthor |
Typeable CSAuthor |
XmlPickler CSAuthor |

data CSCategory

Constructors

CSCategory String String String |

Instances

Eq CSCategory |
Data CSCategory |
Read CSCategory |
Show CSCategory |
Typeable CSCategory |
XmlPickler CSCategory |

data FormattedOutput

The formatted output, produced after post-processing the evaluated citations.

Constructors

FO Formatting [FormattedOutput] |
FN String Formatting |
FS String Formatting |
FDel String |
FPan [Inline] |
FNull |

Instances

Eq FormattedOutput |
Show FormattedOutput |

data Output

The `Output` generated by the evaluation of a style. Must be further processed for disambiguation and collapsing.

Constructors

ONull |
OSpace |
OPan [Inline] |
ODel String | A delimiter string.
OStr String Formatting | A simple `String`
ONum Int Formatting | A number (used to count contributors)
OCitNum Int Formatting | The citation number
OYear String String Formatting | The year and the citeId
OYearSuf String String [Output] Formatting | The year suffix, the citeId and a holder for collision data
OName String [Output] [[Output]] Formatting | A (family) name with the list of given names.
OContrib String String [Output] [Output] [[Output]] | The citation key, the role (author, editor, etc.), the contributor(s), the output needed for year suf. disambiguation, and everything used for name disambiguation.
Output [Output] Formatting | Some nested `Output`

Instances

Eq Output |
Data Output |
Ord Output |
Show Output |
Typeable Output |

data Affix

Constructors

PlainText String |
PandocText [Inline] |

Instances

Eq Affix |
Data Affix |
Ord Affix |
Read Affix |
Show Affix |
Typeable Affix |
JSON Affix | Needed for the test-suite.

type Citations = [[Cite]]

data Cite

Constructors

Cite |

Fields

citeId :: String
citePrefix :: Affix
citeSuffix :: Affix
citeLabel :: String
citeLocator :: String
citeNoteNumber :: String
citePosition :: String
nearNote :: Bool
authorInText :: Bool
suppressAuthor :: Bool
citeHash :: Int

Instances

Eq Cite |
Data Cite |
Show Cite |
Typeable Cite |

emptyAffix :: Affix

emptyCite :: Cite

data CitationGroup

A citation group: a list of evaluated citations, the `Formatting` to be applied to them, and the `Delimiter` between individual citations.

Constructors

CG [(Cite, Output)] Formatting Delimiter [(Cite, Output)] |

Instances

Eq CitationGroup |
Data CitationGroup |
Show CitationGroup |
Typeable CitationGroup |

data BiblioData

Constructors

BD |

Fields

citations :: [[FormattedOutput]]
bibliography :: [[FormattedOutput]]

Instances

Show BiblioData |

data CiteData

A record with all the data to produce the `FormattedOutput` of a citation: the citation key, the part of the citation that may be colliding with other citations (the list of contributors for the same year), the data to disambiguate it (all possible contributors and all possible given names), and the disambiguated citation and its year.

Constructors

CD |

Fields

key :: String
collision :: [Output]
disambYS :: [Output]
disambData :: [[Output]]
disambed :: [Output]
citYear :: String

Instances

Eq CiteData |
Data CiteData |
Show CiteData |
Typeable CiteData |

data NameData

Constructors

ND |

Fields

nameKey :: String
nameCollision :: [Output]
nameDisambData :: [[Output]]
nameDataSolved :: [Output]

Instances

Eq NameData |
Data NameData |
Show NameData |
Typeable NameData |

formatOutputList :: [Output] -> [FormattedOutput]

formatOutput :: Output -> FormattedOutput

Convert evaluated `Output` into `FormattedOutput`, ready for the output filters.

mapGroupOutput :: (Output -> [a]) -> CitationGroup -> [a]

Map the evaluated output of a citation group.

proc :: (Typeable a, Data b) => (a -> a) -> b -> b

A generic processing function.

proc' :: (Typeable a, Data b) => (a -> a) -> b -> b

A generic processing function: process a data structure in top-down manner.

query :: (Typeable a, Data b) => (a -> [c]) -> b -> [c]

A generic query function.

rmGivenNames :: Output -> Output

Removes all given names form a `OName` element with `proc`.

rmNameHash :: Output -> Output

rmContribs :: Output -> Output

Removes all contributors' names.

addGivenNames :: [Output] -> [Output]

Add, with `proc`, a give name to the family name. Needed for disambiguation.

addYearSuffix :: Output -> Output

Add the year suffix to the year. Needed for disambiguation.

hasYear :: Output -> Bool

hasYearSuf :: Output -> Bool

betterThen :: Eq a => [a] -> [a] -> [a]