mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-24 01:06:30 +00:00
FB2 writer: convert metadata value "abstract" to book annotation
This commit is contained in:
@@ -118,6 +118,9 @@ description meta' = do
|
||||
bt <- booktitle meta'
|
||||
let as = authors meta'
|
||||
dd <- docdate meta'
|
||||
annotation <- case lookupMeta "abstract" meta' of
|
||||
Just (MetaBlocks bs) -> (list . el "annotation") <$> cMapM blockToXml bs
|
||||
_ -> pure mempty
|
||||
let lang = case lookupMeta "lang" meta' of
|
||||
Just (MetaInlines [Str s]) -> [el "lang" $ iso639 s]
|
||||
Just (MetaString s) -> [el "lang" $ iso639 s]
|
||||
@@ -132,7 +135,7 @@ description meta' = do
|
||||
Just (MetaString s) -> coverimage s
|
||||
_ -> return []
|
||||
return $ el "description"
|
||||
[ el "title-info" (genre : (bt ++ as ++ dd ++ lang))
|
||||
[ el "title-info" (genre : (bt ++ annotation ++ as ++ dd ++ lang))
|
||||
, el "document-info" (el "program-used" "pandoc" : coverpage)
|
||||
]
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ tests = [ testGroup "markdown"
|
||||
, fb2WriterTest "images" [] "fb2/images.markdown" "fb2/images.fb2"
|
||||
, fb2WriterTest "images-embedded" [] "fb2/images-embedded.html" "fb2/images-embedded.fb2"
|
||||
, fb2WriterTest "math" [] "fb2/math.markdown" "fb2/math.fb2"
|
||||
, fb2WriterTest "meta" [] "fb2/meta.markdown" "fb2/meta.fb2"
|
||||
, fb2WriterTest "tables" [] "tables.native" "tables.fb2"
|
||||
, fb2WriterTest "testsuite" [] "testsuite.native" "writer.fb2"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Book title
|
||||
abstract: |
|
||||
This is the abstract.
|
||||
|
||||
It consists of two paragraphs.
|
||||
---
|
||||
Reference in New Issue
Block a user