packages feed

citeproc-hs-0.1: test/test_basic.hs

import Control.Monad.State

import Text.XML.HXT.Arrow
import Control.Arrow

import Text.CSL.Reference
import Text.CSL.Style
import Text.CSL.Proc
import Text.CSL.Parser
import Text.CSL.Output.Plain

import RefData

file :: String
file = "test/apa"

localeFile :: String
localeFile = "test/locales-it-IT.xml"

main :: IO ()
main
    = do
      s <- readCSLFile file
      processCitation s

processCitation :: Style -> IO ()
processCitation s@(Style {biblio = b, citation = c, csMacros = m , csTerms = terms})
    = do
      let (lb,ob,sb) = case b of
                         Just (Bibliography o s lay) -> (lay,o,s)
                         _ -> error $ "no bibliography layout in style"
          (lc,oc,sc) = case c of
                         Citation o s lay -> (lay,o,s)
      putStrLn . concatMap renderPlain . processCitations s [rossato2006] $ [[("Rossato2006","p. 10-12")]]
      putStrLn . unlines . map renderPlain . processBibliography s $ someReferences

rossato2006 :: Reference
rossato2006
    = emptyReference { citeKey        = "Rossato2006"
                     , refType        = Book
                     , author         = [Person "" ["Andrea"]   "" "" "Rossato" ""
                                        ,Person "On." ["Amedea"]   "" "" "Uggino" ""
                                        ,Person "" ["Luigi"]    "" "" "Gazzoni" ""]
                     , editor         = [Person "" ["Paola"]    "" "" "Locatin" ""]
                     , translator     = [Person "" ["Roberto"]  "" "" "Caso" ""
                                        ,Person "" ["Federico"] "" "" "Uggino" ""]
                     , title          = "Diritto e architettura nello spazio digitale"
                     , issued         = [RefDate 2006 1 16 ""]
                     , accessed       = [RefDate 2006 1 16 ""]
                     , publisher      = [Entity "Cedam"]
                     , publisherPlace = "Bologna"
                     , edition        = "I"
                     , page           = "12"
                     , url            = "http://some.url.com"
                     }