git.iko.soy/typeable/pandoc
on master help sign in
FB2 writer: convert metadata value "abstract" to book annotation
commitcaeb963447440edb14a67bb02cb6c956232dce63 authorAlexander Krotov <ilabdsf@gmail.com> dateThu 19 Apr 2018, 17:03 (9 years ago) parentce4326a
4 files changed+15−1
src/Text/Pandoc/Writers/FB2.hs+4−1 test/Tests/Old.hs+1 test/fb2/meta.fb2+3 test/fb2/meta.markdown+7
src/Text/Pandoc/Writers/FB2.hs+4−1
@@ -118,6 +118,9 @@ description meta' = do
118118 bt <- booktitle meta'
119119 let as = authors meta'
120120 dd <- docdate meta'
121+ annotation <- case lookupMeta "abstract" meta' of
122+ Just (MetaBlocks bs) -> (list . el "annotation") <$> cMapM blockToXml bs
123+ _ -> pure mempty
121124 let lang = case lookupMeta "lang" meta' of
122125 Just (MetaInlines [Str s]) -> [el "lang" $ iso639 s]
123126 Just (MetaString s) -> [el "lang" $ iso639 s]
@@ -132,7 +135,7 @@ description meta' = do
132135 Just (MetaString s) -> coverimage s
133136 _ -> return []
134137 return $ el "description"
135− [ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
138+ [ el "title-info" (genre : (bt ++ annotation ++ as ++ dd ++ lang))
136139 , el "document-info" (el "program-used" "pandoc" : coverpage)
137140 ]
138141
test/Tests/Old.hs+1
@@ -95,6 +95,7 @@ tests = [ testGroup "markdown"
9595 , fb2WriterTest "images" [] "fb2/images.markdown" "fb2/images.fb2"
9696 , fb2WriterTest "images-embedded" [] "fb2/images-embedded.html" "fb2/images-embedded.fb2"
9797 , fb2WriterTest "math" [] "fb2/math.markdown" "fb2/math.fb2"
98+ , fb2WriterTest "meta" [] "fb2/meta.markdown" "fb2/meta.fb2"
9899 , fb2WriterTest "tables" [] "tables.native" "tables.fb2"
99100 , fb2WriterTest "testsuite" [] "testsuite.native" "writer.fb2"
100101 ]
test/fb2/meta.fb2new file+3
@@ -0,0 +1,3 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><genre>unrecognised</genre><book-title>Book title</book-title><annotation><p>This is the abstract.</p>It consists of two paragraphs.</annotation></title-info><document-info><program-used>pandoc</program-used></document-info></description><body><title><p>Book title</p></title></body></FictionBook>
3+
test/fb2/meta.markdownnew file+7
@@ -0,0 +1,7 @@
1+---
2+title: Book title
3+abstract: |
4+ This is the abstract.
5+
6+ It consists of two paragraphs.
7+---