@@ -94,53 +94,59 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
94 xlink = "http://www.w3.org/1999/xlink"
94 xlink = "http://www.w3.org/1999/xlink"
95 in [ uattr "xmlns" xmlns
95 in [ uattr "xmlns" xmlns
96 , attr ("xmlns", "l") xlink ]
96 , attr ("xmlns", "l") xlink ]
98− frontpage :: Meta -> FBM [Content]
99+frontpage :: Meta -> FBM [Content]
99− frontpage meta' = do
100+frontpage meta' = do
100− t <- cMapM toXml . docTitle $ meta'
101+ t <- cMapM toXml . docTitle $ meta'
101− return $
102+ return $
102− [ el "title" (el "p" t)
103+ [ el "title" (el "p" t)
103− , el "annotation" (map (el "p" . cMap plain)
104+ , el "annotation" (map (el "p" . cMap plain)
104− (docAuthors meta' ++ [docDate meta']))
105+ (docAuthors meta' ++ [docDate meta']))
106− description :: Meta -> FBM Content
108+description :: Meta -> FBM Content
107− description meta' = do
109+description meta' = do
108− bt <- booktitle meta'
110+ bt <- booktitle meta'
109− let as = authors meta'
111+ let as = authors meta'
110− dd <- docdate meta'
112+ dd <- docdate meta'
111− return $ el "description"
113+ return $ el "description"
112− [ el "title-info" (bt ++ as ++ dd)
114+ [ el "title-info" (bt ++ as ++ dd)
113− , el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
115+ , el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
115− booktitle :: Meta -> FBM [Content]
118+booktitle :: Meta -> FBM [Content]
116− booktitle meta' = do
119+booktitle meta' = do
117− t <- cMapM toXml . docTitle $ meta'
120+ t <- cMapM toXml . docTitle $ meta'
118− return $ if null t
121+ return $ if null t
120− else [ el "book-title" t ]
123+ else [ el "book-title" t ]
121− authors :: Meta -> [Content]
125+authors :: Meta -> [Content]
122− authors meta' = cMap author (docAuthors meta')
126+authors meta' = cMap author (docAuthors meta')
123− author :: [Inline] -> [Content]
128+author :: [Inline] -> [Content]
124− author ss =
129+author ss =
125− let ws = words . cMap plain $ ss
130+ let ws = words . cMap plain $ ss
126− email = (el "email") `fmap` (take 1 $ filter ('@' `elem`) ws)
131+ email = (el "email") `fmap` (take 1 $ filter ('@' `elem`) ws)
127− ws' = filter ('@' `notElem`) ws
132+ ws' = filter ('@' `notElem`) ws
128− names = case ws' of
133+ names = case ws' of
129− (nickname:[]) -> [ el "nickname" nickname ]
134+ (nickname:[]) -> [ el "nickname" nickname ]
130− (fname:lname:[]) -> [ el "first-name" fname
135+ (fname:lname:[]) -> [ el "first-name" fname
131− , el "last-name" lname ]
136+ , el "last-name" lname ]
132− (fname:rest) -> [ el "first-name" fname
137+ (fname:rest) -> [ el "first-name" fname
133− , el "middle-name" (concat . init $ rest)
138+ , el "middle-name" (concat . init $ rest)
134− , el "last-name" (last rest) ]
139+ , el "last-name" (last rest) ]
135− ([]) -> []
140+ ([]) -> []
136− in list $ el "author" (names ++ email)
141+ in list $ el "author" (names ++ email)
137− docdate :: Meta -> FBM [Content]
143+docdate :: Meta -> FBM [Content]
138− docdate meta' = do
144+docdate meta' = do
139− let ss = docDate meta'
145+ let ss = docDate meta'
140− d <- cMapM toXml ss
146+ d <- cMapM toXml ss
141− return $ if null d
147+ return $ if null d
143− else [el "date" d]
149+ else [el "date" d]
145-- | Divide the stream of blocks into sections and convert to XML
151-- | Divide the stream of blocks into sections and convert to XML
146-- representation.
152-- representation.