FB2 Writer: format LineBlock as poem

Previously writer produced one paragraph with <empty-line/> elements,
which are not allowed inside <p> according to FB2 schema.
This commit is contained in:
Alexander Krotov 2017-10-09 05:38:02 +03:00
parent 0ff96117d3
commit 00013c21eb

View file

@ -56,7 +56,7 @@ import qualified Text.Pandoc.Class as P
import Text.Pandoc.Definition import Text.Pandoc.Definition
import Text.Pandoc.Logging import Text.Pandoc.Logging
import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..), def) import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..), def)
import Text.Pandoc.Shared (capitalize, isHeaderBlock, isURI, linesToPara, import Text.Pandoc.Shared (capitalize, isHeaderBlock, isURI,
orderedListMarkers) orderedListMarkers)
-- | Data to be written at the end of the document: -- | Data to be written at the end of the document:
@ -331,7 +331,11 @@ blockToXml b@(RawBlock _ _) = do
return [] return []
blockToXml (Div _ bs) = cMapM blockToXml bs blockToXml (Div _ bs) = cMapM blockToXml bs
blockToXml (BlockQuote bs) = (list . el "cite") <$> cMapM blockToXml bs blockToXml (BlockQuote bs) = (list . el "cite") <$> cMapM blockToXml bs
blockToXml (LineBlock lns) = blockToXml $ linesToPara lns blockToXml (LineBlock lns) =
(list . el "poem") <$> mapM stanza (split null lns)
where
v xs = el "v" <$> cMapM toXml xs
stanza xs = el "stanza" <$> mapM v xs
blockToXml (OrderedList a bss) = do blockToXml (OrderedList a bss) = do
state <- get state <- get
let pmrk = parentListMarker state let pmrk = parentListMarker state