hs-bibutils-4.15: Haskell bindings to bibutils, the bibliography conversion utilities.

Safe HaskellNone




Here is a simple program using hs-bibutils to conver a MODS collection into a bibtex file, sending the output to stdout:

 import Text.Bibutils

 main :: IO ()
 main = do
   bibl  <- bibl_init
   param <- bibl_initparams mods_in bibtex_out "mods2bibtex"
   setFormatOpts param [bibout_brackets, bibout_uppercase]
   setBOM        param
   setVerbose    param
   bibl_read     param bibl "/path/to/bibtex.bib"
   bibl_write    param bibl "-"
   bibl_free       bibl
   bibl_freeparams param


Basic Functions

data Bibl Source

A type for storing the C struct with the bibliography data. Mostly opaque to the Haskell side. See numberOfRefs to retrieve the number of references stored in the struct.


data Param Source

A type for storing the Param C struct. It should be accessed with the functions provided, such as setCharsetIn, etc.


bibl_init :: IO (ForeignPtr Bibl)Source

Initialize the Bibl C struct. Usually the first function being called.

bibl_initparams :: BiblioIn -> BiblioOut -> String -> IO (ForeignPtr Param)Source

Initialize the Param C struct, given the input bibliographic format, the output bibliographic format, and the program name to be used for displaying debugging information.

bibl_read :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO StatusSource

Given a Param C structure, a Bibl C structure, the path to the input file ("-" for the standard input), read the file, storing the data in the Bibl struct, and report a Status.

bibl_write :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO StatusSource

Given a Param C structure, a Bibl C structure, the path to an output file ("-" for the standard output), write the file returning a Status.

bibl_free :: ForeignPtr Bibl -> IO ()Source

Free the Bibl C struct.

bibl_freeparams :: ForeignPtr Param -> IO ()Source

Free the Param C struct.

Auxiliary Functions

numberOfRefs :: ForeignPtr Bibl -> IO IntSource

Retrieve the number of references from a Bibl C struct.

Functions for Setting Parameters

setParam :: ForeignPtr Param -> (Param -> Param) -> IO ()Source

Set fields of the Param C struct directly.

setFormatOpts :: ForeignPtr Param -> [FormatOpt] -> IO ()Source

Set output format specific options. See FormatOpt.

setCharsetIn :: ForeignPtr Param -> Charset -> IO ()Source

Set the input charset. Default is Latin-1 (ISO8859-1). See Charset.

setCharsetOut :: ForeignPtr Param -> Charset -> IO ()Source

Set the output charset.

setBOM :: ForeignPtr Param -> IO ()Source

Write utf8 byte-order-mark.

setNoSplitTitle :: ForeignPtr Param -> IO ()Source

Do not split titles.

setLatexOut :: ForeignPtr Param -> IO ()Source

Write Latex codes.

setXmlOut :: ForeignPtr Param -> IO ()Source

Write characters in XML entities.

setAddcount :: ForeignPtr Param -> IO ()Source

Add reference count to reference id.

setSinglerefperfile :: ForeignPtr Param -> IO ()Source

Output a single reference for each file.

setVerbose :: ForeignPtr Param -> IO ()Source

Verbose output.

unsetVerbose :: ForeignPtr Param -> IO ()Source

Suppress verbose output.

Input Formats

data BiblioIn Source


Output Formats

data BiblioOut Source


Options for Specific Output Formats


data Charset Source


Return Status

data Status Source