module Text.BibTeX.Format where
import qualified Text.BibTeX.Entry as Entry
import Data.List (intersperse, )
import Data.List.HT (switchR, )
entry :: Entry.T -> String
entry :: T -> String
entry (Entry.Cons String
entryType String
bibId [(String, String)]
items) =
let formatItem :: (String, String) -> String
formatItem (String
name, String
value) =
String
" "forall a. [a] -> [a] -> [a]
++String
nameforall a. [a] -> [a] -> [a]
++String
" = {"forall a. [a] -> [a] -> [a]
++String
valueforall a. [a] -> [a] -> [a]
++String
"},\n"
in String
"@" forall a. [a] -> [a] -> [a]
++ String
entryType forall a. [a] -> [a] -> [a]
++ String
"{" forall a. [a] -> [a] -> [a]
++ String
bibId forall a. [a] -> [a] -> [a]
++ String
",\n" forall a. [a] -> [a] -> [a]
++
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (String, String) -> String
formatItem [(String, String)]
items forall a. [a] -> [a] -> [a]
++
String
"}\n"
enumerate :: [String] -> String
enumerate :: [String] -> String
enumerate =
forall b a. b -> ([a] -> a -> b) -> [a] -> b
switchR String
"" forall a b. (a -> b) -> a -> b
$ \[String]
xs0 String
lastWord0 ->
forall a b c. (a -> b -> c) -> b -> a -> c
flip (forall b a. b -> ([a] -> a -> b) -> [a] -> b
switchR String
lastWord0) [String]
xs0 forall a b. (a -> b) -> a -> b
$ \[String]
xs1 String
lastWord1 ->
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
(\String
word -> (String
word forall a. [a] -> [a] -> [a]
++) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
", " forall a. [a] -> [a] -> [a]
++))
(String
lastWord1 forall a. [a] -> [a] -> [a]
++ String
" and " forall a. [a] -> [a] -> [a]
++ String
lastWord0) [String]
xs1
authorList :: [String] -> String
authorList :: [String] -> String
authorList =
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> [a] -> [a]
intersperse String
" and "
commaSepList :: [String] -> String
commaSepList :: [String] -> String
commaSepList = Char -> [String] -> String
sepList Char
','
sepList :: Char -> [String] -> String
sepList :: Char -> [String] -> String
sepList Char
sep = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> [a] -> [a]
intersperse (Char
sepforall a. a -> [a] -> [a]
:String
" ")