Text.CSL

pandoc-citeproc-0.10.5.1: Supports using pandoc with citeproc

Copyright | (c) Andrea Rossato
License | BSD-style (see LICENSE)
Maintainer | Andrea Rossato <andrea.rossato@unitn.it>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

Text.CSL

Contents

- Introduction
- Overview: A Simple Example
- Reading Bibliographic Databases
  - Reference Representation
- CSL Parser, Representation, and Processing
  - The Style Types
  - High Level Processing
- The output and the rendering functions

Description

citeproc-hs is a library for automatically formatting bibliographic reference citations into a variety of styles using a macro language called Citation Style Language (CSL). More details on CSL can be found here: http://citationstyles.org/.

This module documents and exports the library API.

Synopsis

- readBiblioFile :: FilePath -> IO [Reference]
- data BibFormat
  - = Json
  - | Yaml
  - | Bibtex
  - | BibLatex
  - | Ris
  - | Endnote
  - | EndnotXml
  - | Isi
  - | Medline
  - | Copac
  - | Mods
- readBiblioString :: BibFormat -> String -> IO [Reference]
- data Reference = Reference {
  - refId :: Literal
  - refType :: RefType
  - author :: [Agent]
  - editor :: [Agent]
  - translator :: [Agent]
  - recipient :: [Agent]
  - interviewer :: [Agent]
  - composer :: [Agent]
  - director :: [Agent]
  - illustrator :: [Agent]
  - originalAuthor :: [Agent]
  - containerAuthor :: [Agent]
  - collectionEditor :: [Agent]
  - editorialDirector :: [Agent]
  - reviewedAuthor :: [Agent]
  - issued :: [RefDate]
  - eventDate :: [RefDate]
  - accessed :: [RefDate]
  - container :: [RefDate]
  - originalDate :: [RefDate]
  - submitted :: [RefDate]
  - title :: Formatted
  - titleShort :: Formatted
  - reviewedTitle :: Formatted
  - containerTitle :: Formatted
  - volumeTitle :: Formatted
  - collectionTitle :: Formatted
  - containerTitleShort :: Formatted
  - collectionNumber :: Formatted
  - originalTitle :: Formatted
  - publisher :: Formatted
  - originalPublisher :: Formatted
  - publisherPlace :: Formatted
  - originalPublisherPlace :: Formatted
  - authority :: Formatted
  - jurisdiction :: Formatted
  - archive :: Formatted
  - archivePlace :: Formatted
  - archiveLocation :: Formatted
  - event :: Formatted
  - eventPlace :: Formatted
  - page :: Formatted
  - pageFirst :: Formatted
  - numberOfPages :: Formatted
  - version :: Formatted
  - volume :: Formatted
  - numberOfVolumes :: Formatted
  - issue :: Formatted
  - chapterNumber :: Formatted
  - medium :: Formatted
  - status :: Formatted
  - edition :: Formatted
  - section :: Formatted
  - source :: Formatted
  - genre :: Formatted
  - note :: Formatted
  - annote :: Formatted
  - abstract :: Formatted
  - keyword :: Formatted
  - number :: Formatted
  - references :: Formatted
  - url :: Literal
  - doi :: Literal
  - isbn :: Literal
  - issn :: Literal
  - pmcid :: Literal
  - pmid :: Literal
  - callNumber :: Literal
  - dimensions :: Literal
  - scale :: Literal
  - categories :: [Literal]
  - language :: Literal
  - citationNumber :: CNum
  - firstReferenceNoteNumber :: Int
  - citationLabel :: CLabel
  }
- getReference :: [Reference] -> Cite -> Maybe Reference
- setNearNote :: Style -> [[Cite]] -> [[Cite]]
- readCSLFile :: Maybe String -> FilePath -> IO Style
- parseCSL :: String -> Style
- parseCSL' :: ByteString -> Style
- localizeCSL :: Maybe String -> Style -> IO Style
- data Style = Style {
  - styleVersion :: String
  - styleClass :: String
  - styleInfo :: Maybe CSInfo
  - styleDefaultLocale :: String
  - styleLocale :: [Locale]
  - styleAbbrevs :: Abbreviations
  - csOptions :: [Option]
  - csMacros :: [MacroMap]
  - citation :: Citation
  - biblio :: Maybe Bibliography
  }
- data Citation = Citation {
  - citOptions :: [Option]
  - citSort :: [Sort]
  - citLayout :: Layout
  }
- data Bibliography = Bibliography {
  - bibOptions :: [Option]
  - bibSort :: [Sort]
  - bibLayout :: Layout
  }
- data Cite = Cite {
  - citeId :: String
  - citePrefix :: Formatted
  - citeSuffix :: Formatted
  - citeLabel :: String
  - citeLocator :: String
  - citeNoteNumber :: String
  - citePosition :: String
  - nearNote :: Bool
  - authorInText :: Bool
  - suppressAuthor :: Bool
  - citeHash :: Int
  }
- newtype Abbreviations = Abbreviations {
  - unAbbreviations :: Map String (Map String (Map String String))
  }
- emptyCite :: Cite
- data ProcOpts = ProcOpts {
  - bibOpts :: BibOpts
  - linkCitations :: Bool
  }
- procOpts :: ProcOpts
- data BibOpts
  - = Select [(String, String)] [(String, String)]
  - | Include [(String, String)] [(String, String)]
  - | Exclude [(String, String)] [(String, String)]
- citeproc :: ProcOpts -> Style -> [Reference] -> Citations -> BiblioData
- processCitations :: ProcOpts -> Style -> [Reference] -> Citations -> [Formatted]
- processBibliography :: ProcOpts -> Style -> [Reference] -> [Formatted]
- data BiblioData = BD {
  - citations :: [Formatted]
  - bibliography :: [Formatted]
  - citationIds :: [String]
  }
- renderPlain :: Formatted -> String
- renderPandoc :: Style -> Formatted -> [Inline]
- renderPandoc' :: Style -> (Formatted, String) -> Block

# Introduction

citeproc-hs provides functions for reading bibliographic databases, for reading and parsing CSL files and for generating citations in an internal format, `Formatted`, that can be easily rendered into different final formats. At the present time only `Pandoc` and plain text rendering functions are provided by the library.

The library also provides a wrapper around hs-bibutils, the Haskell bindings to Chris Putnam's bibutils, a library that interconverts between various bibliography formats using a common MODS-format XML intermediate. For more information about hs-bibutils see here: http://hackage.haskell.org/package/hs-bibutils.

citeproc-hs can natively read MODS and JSON formatted bibliographic databases. The JSON format is only partially documented. It is used by citeproc-js, by the CSL processor test-suite and is derived by the CSL scheme. More information can be read here: http://citationstyles.org/.

A (git) repository of styles can be found here: https://github.com/citation-style-language/styles.

# Overview: A Simple Example

The following example assumes you have installed citeproc-hs with hs-bibutils support (which is the default).

Suppose you have a small bibliographic database, like this one:

    @Book{Rossato2006,
    author="Andrea Rossato",
    title="My Second Book",
    year="2006"
    }

    @Book{Caso2007,
    author="Roberto Caso",
    title="Roberto's Book",
    year="2007"
    }

Save it as `mybibdb.bib`.

Then you can grab one of the CSL styles that come with the test-suite for CSL processors. Suppose this one:

https://bitbucket.org/bdarcus/citeproc-test/raw/18141149d1d3/styles/apa-x.csl

saved locally as `apa-x.csl`.

This would be a simple program that formats a list of citations according to that style:

    import Text.CSL

    cites :: [Cite]
    cites = [emptyCite { citeId = "Caso2007"
                       , citeLabel = "page"
                       , citeLocator = "15"}
            ,emptyCite { citeId = "Rossato2006"
                       , citeLabel = "page"
                       , citeLocator = "10"}
            ]

    main :: IO ()
    main = do
      m <- readBiblioFile "mybibdb.bib"
      s <- readCSLFile Nothing "apa-x.csl"
      let result = citeproc procOpts s m $ [cites]
      putStrLn . unlines . map renderPlain . citations $ result

The result would be:

    (Caso, 2007, p. 15; Rossato, 2006, p. 10)

# Reading Bibliographic Databases

readBiblioFile :: FilePath -> IO [Reference] #

Read a file with a bibliographic database. The database format is recognized by the file extension.

Supported formats are: `json`, `mods`, `bibtex`, `biblatex`, `ris`, `endnote`, `endnotexml`, `isi`, `medline`, and `copac`.

data BibFormat #

Constructors

Json |
Yaml |
Bibtex |
BibLatex |
Ris |
Endnote |
EndnotXml |
Isi |
Medline |
Copac |
Mods |

readBiblioString :: BibFormat -> String -> IO [Reference] #

## Reference Representation

data Reference #

The `Reference` record.

Constructors

Reference |
Fields refId :: Literal refType :: RefType author :: [Agent] editor :: [Agent] translator :: [Agent] recipient :: [Agent] interviewer :: [Agent] composer :: [Agent] director :: [Agent] illustrator :: [Agent] originalAuthor :: [Agent] containerAuthor :: [Agent] collectionEditor :: [Agent] editorialDirector :: [Agent] reviewedAuthor :: [Agent] issued :: [RefDate] eventDate :: [RefDate] accessed :: [RefDate] container :: [RefDate] originalDate :: [RefDate] submitted :: [RefDate] title :: Formatted titleShort :: Formatted reviewedTitle :: Formatted containerTitle :: Formatted volumeTitle :: Formatted collectionTitle :: Formatted containerTitleShort :: Formatted collectionNumber :: Formatted originalTitle :: Formatted publisher :: Formatted originalPublisher :: Formatted publisherPlace :: Formatted originalPublisherPlace :: Formatted authority :: Formatted jurisdiction :: Formatted archive :: Formatted archivePlace :: Formatted archiveLocation :: Formatted event :: Formatted eventPlace :: Formatted page :: Formatted pageFirst :: Formatted numberOfPages :: Formatted version :: Formatted volume :: Formatted numberOfVolumes :: Formatted issue :: Formatted chapterNumber :: Formatted medium :: Formatted status :: Formatted edition :: Formatted section :: Formatted source :: Formatted genre :: Formatted note :: Formatted annote :: Formatted abstract :: Formatted keyword :: Formatted number :: Formatted references :: Formatted url :: Literal doi :: Literal isbn :: Literal issn :: Literal pmcid :: Literal pmid :: Literal callNumber :: Literal dimensions :: Literal scale :: Literal categories :: [Literal] language :: Literal citationNumber :: CNum firstReferenceNoteNumber :: Int citationLabel :: CLabel

Instances

Eq Reference # |
Methods (==) :: Reference -> Reference -> Bool # (/=) :: Reference -> Reference -> Bool #
Data Reference # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Reference -> c Reference # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Reference # toConstr :: Reference -> Constr # dataTypeOf :: Reference -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Reference) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Reference) # gmapT :: (forall b. Data b => b -> b) -> Reference -> Reference # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Reference -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Reference -> r # gmapQ :: (forall d. Data d => d -> u) -> Reference -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Reference -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Reference -> m Reference # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Reference -> m Reference # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Reference -> m Reference #
Read Reference # |
Methods readsPrec :: Int -> ReadS Reference # readList :: ReadS [Reference] # readPrec :: ReadPrec Reference # readListPrec :: ReadPrec [Reference] #
Show Reference # |
Methods showsPrec :: Int -> Reference -> ShowS # show :: Reference -> String # showList :: [Reference] -> ShowS #
Generic Reference # |
Associated Types type Rep Reference :: * -> * # Methods from :: Reference -> Rep Reference x # to :: Rep Reference x -> Reference #
ToJSON Reference # |
Methods toJSON :: Reference -> Value # toEncoding :: Reference -> Encoding # toJSONList :: [Reference] -> Value # toEncodingList :: [Reference] -> Encoding #
FromJSON Reference # |
Methods parseJSON :: Value -> Parser Reference # parseJSONList :: Value -> Parser [Reference] #
ToYaml Reference # |
Methods toYaml :: Reference -> YamlBuilder #
type Rep Reference # |
type Rep Reference = D1 (MetaData "Reference" "Text.CSL.Reference" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "Reference" PrefixI True) ((:*:) ((:*:) ((:*:) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "refId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) (S1 (MetaSel (Just Symbol "refType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 RefType))) ((:*:) (S1 (MetaSel (Just Symbol "author") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "editor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "translator") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "recipient") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent]))) ((:*:) (S1 (MetaSel (Just Symbol "interviewer") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) ((:*:) (S1 (MetaSel (Just Symbol "composer") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "director") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])))))) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "illustrator") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "originalAuthor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent]))) ((:*:) (S1 (MetaSel (Just Symbol "containerAuthor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "collectionEditor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "editorialDirector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent])) (S1 (MetaSel (Just Symbol "reviewedAuthor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Agent]))) ((:*:) (S1 (MetaSel (Just Symbol "issued") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate])) ((:*:) (S1 (MetaSel (Just Symbol "eventDate") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate])) (S1 (MetaSel (Just Symbol "accessed") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate]))))))) ((:*:) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "container") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate])) (S1 (MetaSel (Just Symbol "originalDate") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate]))) ((:*:) (S1 (MetaSel (Just Symbol "submitted") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [RefDate])) (S1 (MetaSel (Just Symbol "title") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "titleShort") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "reviewedTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "containerTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "volumeTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "collectionTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))))) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "containerTitleShort") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "collectionNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "originalTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "publisher") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "originalPublisher") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "publisherPlace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "originalPublisherPlace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "authority") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "jurisdiction") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "archive") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))))))) ((:*:) ((:*:) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "archivePlace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "archiveLocation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "event") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "eventPlace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "page") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "pageFirst") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "numberOfPages") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "version") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "volume") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))))) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "numberOfVolumes") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "issue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "chapterNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "medium") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "status") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "edition") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "section") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "source") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "genre") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "note") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))))))) ((:*:) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "annote") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "abstract") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "keyword") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "number") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "references") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) (S1 (MetaSel (Just Symbol "url") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal))) ((:*:) (S1 (MetaSel (Just Symbol "doi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) ((:*:) (S1 (MetaSel (Just Symbol "isbn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) (S1 (MetaSel (Just Symbol "issn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)))))) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "pmcid") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) (S1 (MetaSel (Just Symbol "pmid") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal))) ((:*:) (S1 (MetaSel (Just Symbol "callNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) ((:*:) (S1 (MetaSel (Just Symbol "dimensions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal)) (S1 (MetaSel (Just Symbol "scale") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "categories") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Literal])) (S1 (MetaSel (Just Symbol "language") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Literal))) ((:*:) (S1 (MetaSel (Just Symbol "citationNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CNum)) ((:*:) (S1 (MetaSel (Just Symbol "firstReferenceNoteNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Just Symbol "citationLabel") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CLabel))))))))))

getReference :: [Reference] -> Cite -> Maybe Reference #

setNearNote :: Style -> [[Cite]] -> [[Cite]] #

# CSL Parser, Representation, and Processing

readCSLFile :: Maybe String -> FilePath -> IO Style #

Read and parse a CSL style file into a localized sytle.

parseCSL :: String -> Style #

Parse a `String` into a `Style` (with default locale).

parseCSL' :: ByteString -> Style #

localizeCSL :: Maybe String -> Style -> IO Style #

Merge locale into a CSL style.

## The Style Types

data Style #

The representation of a parsed CSL style.

Constructors

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

Instances

Data Style # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Style -> c Style # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Style # toConstr :: Style -> Constr # dataTypeOf :: Style -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Style) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style) # gmapT :: (forall b. Data b => b -> b) -> Style -> Style # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r # gmapQ :: (forall d. Data d => d -> u) -> Style -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Style -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Style -> m Style # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Style -> m Style #
Read Style # |
Methods readsPrec :: Int -> ReadS Style # readList :: ReadS [Style] # readPrec :: ReadPrec Style # readListPrec :: ReadPrec [Style] #
Show Style # |
Methods showsPrec :: Int -> Style -> ShowS # show :: Style -> String # showList :: [Style] -> ShowS #
Generic Style # |
Associated Types type Rep Style :: * -> * # Methods from :: Style -> Rep Style x # to :: Rep Style x -> Style #
type Rep Style # |
type Rep Style = D1 (MetaData "Style" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "Style" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "styleVersion") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "styleClass") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) ((:*:) (S1 (MetaSel (Just Symbol "styleInfo") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe CSInfo))) ((:*:) (S1 (MetaSel (Just Symbol "styleDefaultLocale") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "styleLocale") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Locale]))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "styleAbbrevs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Abbreviations)) (S1 (MetaSel (Just Symbol "csOptions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Option]))) ((:*:) (S1 (MetaSel (Just Symbol "csMacros") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [MacroMap])) ((:*:) (S1 (MetaSel (Just Symbol "citation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Citation)) (S1 (MetaSel (Just Symbol "biblio") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Bibliography))))))))

data Citation #

Constructors

Citation |
Fields citOptions :: [Option] citSort :: [Sort] citLayout :: Layout

Instances

Data Citation # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Citation -> c Citation # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Citation # toConstr :: Citation -> Constr # dataTypeOf :: Citation -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Citation) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Citation) # gmapT :: (forall b. Data b => b -> b) -> Citation -> Citation # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Citation -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Citation -> r # gmapQ :: (forall d. Data d => d -> u) -> Citation -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Citation -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Citation -> m Citation # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Citation -> m Citation # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Citation -> m Citation #
Read Citation # |
Methods readsPrec :: Int -> ReadS Citation # readList :: ReadS [Citation] # readPrec :: ReadPrec Citation # readListPrec :: ReadPrec [Citation] #
Show Citation # |
Methods showsPrec :: Int -> Citation -> ShowS # show :: Citation -> String # showList :: [Citation] -> ShowS #
Generic Citation # |
Associated Types type Rep Citation :: * -> * # Methods from :: Citation -> Rep Citation x # to :: Rep Citation x -> Citation #
type Rep Citation # |
type Rep Citation = D1 (MetaData "Citation" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "Citation" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "citOptions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Option])) ((:*:) (S1 (MetaSel (Just Symbol "citSort") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Sort])) (S1 (MetaSel (Just Symbol "citLayout") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Layout)))))

data Bibliography #

Constructors

Bibliography |
Fields bibOptions :: [Option] bibSort :: [Sort] bibLayout :: Layout

Instances

Data Bibliography # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bibliography -> c Bibliography # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bibliography # toConstr :: Bibliography -> Constr # dataTypeOf :: Bibliography -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Bibliography) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bibliography) # gmapT :: (forall b. Data b => b -> b) -> Bibliography -> Bibliography # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bibliography -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bibliography -> r # gmapQ :: (forall d. Data d => d -> u) -> Bibliography -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Bibliography -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bibliography -> m Bibliography # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bibliography -> m Bibliography # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bibliography -> m Bibliography #
Read Bibliography # |
Methods readsPrec :: Int -> ReadS Bibliography # readList :: ReadS [Bibliography] # readPrec :: ReadPrec Bibliography # readListPrec :: ReadPrec [Bibliography] #
Show Bibliography # |
Methods showsPrec :: Int -> Bibliography -> ShowS # show :: Bibliography -> String # showList :: [Bibliography] -> ShowS #
Generic Bibliography # |
Associated Types type Rep Bibliography :: * -> * # Methods from :: Bibliography -> Rep Bibliography x # to :: Rep Bibliography x -> Bibliography #
type Rep Bibliography # |
type Rep Bibliography = D1 (MetaData "Bibliography" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "Bibliography" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "bibOptions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Option])) ((:*:) (S1 (MetaSel (Just Symbol "bibSort") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Sort])) (S1 (MetaSel (Just Symbol "bibLayout") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Layout)))))

data Cite #

Constructors

Cite |
Fields citeId :: String citePrefix :: Formatted citeSuffix :: Formatted citeLabel :: String citeLocator :: String citeNoteNumber :: String citePosition :: String nearNote :: Bool authorInText :: Bool suppressAuthor :: Bool citeHash :: Int

Instances

Eq Cite # |
Methods (==) :: Cite -> Cite -> Bool # (/=) :: Cite -> Cite -> Bool #
Data Cite # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Cite -> c Cite # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Cite # toConstr :: Cite -> Constr # dataTypeOf :: Cite -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Cite) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Cite) # gmapT :: (forall b. Data b => b -> b) -> Cite -> Cite # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Cite -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Cite -> r # gmapQ :: (forall d. Data d => d -> u) -> Cite -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Cite -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Cite -> m Cite # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Cite -> m Cite # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Cite -> m Cite #
Show Cite # |
Methods showsPrec :: Int -> Cite -> ShowS # show :: Cite -> String # showList :: [Cite] -> ShowS #
Generic Cite # |
Associated Types type Rep Cite :: * -> * # Methods from :: Cite -> Rep Cite x # to :: Rep Cite x -> Cite #
FromJSON Cite # |
Methods parseJSON :: Value -> Parser Cite # parseJSONList :: Value -> Parser [Cite] #
FromJSON [[Cite]] # |
Methods parseJSON :: Value -> Parser [[Cite]] # parseJSONList :: Value -> Parser [[[Cite]]] #
type Rep Cite # |
type Rep Cite = D1 (MetaData "Cite" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "Cite" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "citeId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "citePrefix") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted))) ((:*:) (S1 (MetaSel (Just Symbol "citeSuffix") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Formatted)) ((:*:) (S1 (MetaSel (Just Symbol "citeLabel") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "citeLocator") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "citeNoteNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) ((:*:) (S1 (MetaSel (Just Symbol "citePosition") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "nearNote") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))) ((:*:) (S1 (MetaSel (Just Symbol "authorInText") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)) ((:*:) (S1 (MetaSel (Just Symbol "suppressAuthor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)) (S1 (MetaSel (Just Symbol "citeHash") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))))))

newtype Abbreviations #

Constructors

Abbreviations |
Fields unAbbreviations :: Map String (Map String (Map String String))

Instances

Data Abbreviations # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Abbreviations -> c Abbreviations # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Abbreviations # toConstr :: Abbreviations -> Constr # dataTypeOf :: Abbreviations -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Abbreviations) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Abbreviations) # gmapT :: (forall b. Data b => b -> b) -> Abbreviations -> Abbreviations # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Abbreviations -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Abbreviations -> r # gmapQ :: (forall d. Data d => d -> u) -> Abbreviations -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Abbreviations -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Abbreviations -> m Abbreviations # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Abbreviations -> m Abbreviations # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Abbreviations -> m Abbreviations #
Read Abbreviations # |
Methods readsPrec :: Int -> ReadS Abbreviations # readList :: ReadS [Abbreviations] # readPrec :: ReadPrec Abbreviations # readListPrec :: ReadPrec [Abbreviations] #
Show Abbreviations # |
Methods showsPrec :: Int -> Abbreviations -> ShowS # show :: Abbreviations -> String # showList :: [Abbreviations] -> ShowS #
Generic Abbreviations # |
Associated Types type Rep Abbreviations :: * -> * # Methods from :: Abbreviations -> Rep Abbreviations x # to :: Rep Abbreviations x -> Abbreviations #
FromJSON Abbreviations # |
Methods parseJSON :: Value -> Parser Abbreviations # parseJSONList :: Value -> Parser [Abbreviations] #
type Rep Abbreviations # |
type Rep Abbreviations = D1 (MetaData "Abbreviations" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" True) (C1 (MetaCons "Abbreviations" PrefixI True) (S1 (MetaSel (Just Symbol "unAbbreviations") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String (Map String (Map String String))))))

emptyCite :: Cite #

## High Level Processing

data ProcOpts #

Constructors

ProcOpts |
Fields bibOpts :: BibOpts linkCitations :: Bool

Instances

Eq ProcOpts # |
Methods (==) :: ProcOpts -> ProcOpts -> Bool # (/=) :: ProcOpts -> ProcOpts -> Bool #
Read ProcOpts # |
Methods readsPrec :: Int -> ReadS ProcOpts # readList :: ReadS [ProcOpts] # readPrec :: ReadPrec ProcOpts # readListPrec :: ReadPrec [ProcOpts] #
Show ProcOpts # |
Methods showsPrec :: Int -> ProcOpts -> ShowS # show :: ProcOpts -> String # showList :: [ProcOpts] -> ShowS #

procOpts :: ProcOpts #

data BibOpts #

Constructors

Select [(String, String)] [(String, String)] |
Include [(String, String)] [(String, String)] |
Exclude [(String, String)] [(String, String)] |

Instances

Eq BibOpts # |
Methods (==) :: BibOpts -> BibOpts -> Bool # (/=) :: BibOpts -> BibOpts -> Bool #
Read BibOpts # |
Methods readsPrec :: Int -> ReadS BibOpts # readList :: ReadS [BibOpts] # readPrec :: ReadPrec BibOpts # readListPrec :: ReadPrec [BibOpts] #
Show BibOpts # |
Methods showsPrec :: Int -> BibOpts -> ShowS # show :: BibOpts -> String # showList :: [BibOpts] -> ShowS #
FromJSON BibOpts # |
Methods parseJSON :: Value -> Parser BibOpts # parseJSONList :: Value -> Parser [BibOpts] #

citeproc :: ProcOpts -> Style -> [Reference] -> Citations -> BiblioData #

With a `Style`, a list of `Reference`s and the list of `Citations`, produce the `Formatted` for each citation group and the bibliography.

processCitations :: ProcOpts -> Style -> [Reference] -> Citations -> [Formatted] #

With a `Style`, a list of `Reference`s and the list of citation groups (the list of citations with their locator), produce the `Formatted` for each citation group.

processBibliography :: ProcOpts -> Style -> [Reference] -> [Formatted] #

With a `Style` and the list of `Reference`s produce the `Formatted` for the bibliography.

data BiblioData #

Constructors

BD |
Fields citations :: [Formatted] bibliography :: [Formatted] citationIds :: [String]

Instances

Data BiblioData # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BiblioData -> c BiblioData # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BiblioData # toConstr :: BiblioData -> Constr # dataTypeOf :: BiblioData -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c BiblioData) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BiblioData) # gmapT :: (forall b. Data b => b -> b) -> BiblioData -> BiblioData # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BiblioData -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BiblioData -> r # gmapQ :: (forall d. Data d => d -> u) -> BiblioData -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BiblioData -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BiblioData -> m BiblioData # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BiblioData -> m BiblioData # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BiblioData -> m BiblioData #
Show BiblioData # |
Methods showsPrec :: Int -> BiblioData -> ShowS # show :: BiblioData -> String # showList :: [BiblioData] -> ShowS #
Generic BiblioData # |
Associated Types type Rep BiblioData :: * -> * # Methods from :: BiblioData -> Rep BiblioData x # to :: Rep BiblioData x -> BiblioData #
type Rep BiblioData # |
type Rep BiblioData = D1 (MetaData "BiblioData" "Text.CSL.Style" "pandoc-citeproc-0.10.5.1-CeON6I53B0a1SvSDfWDfSM" False) (C1 (MetaCons "BD" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "citations") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Formatted])) ((:*:) (S1 (MetaSel (Just Symbol "bibliography") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Formatted])) (S1 (MetaSel (Just Symbol "citationIds") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [String])))))

# The output and the rendering functions

renderPlain :: Formatted -> String #

Render the `Formatted` into a plain text string.

renderPandoc :: Style -> Formatted -> [Inline] #

renderPandoc' :: Style -> (Formatted, String) -> Block #