From ff3ed5c9f8ee985bb6026dd10b8c2549782c0296 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 4 Apr 2018 13:45:28 +0300 Subject: FB2 writer: allow emphasis and notes in titles Only

and are allowed in titles, but

has the same type as an ordinary paragraphs. Therefore, there is no need to remove emphasis from titles. Also, don't intersperse paragraph with empty lines. --- src/Text/Pandoc/Writers/FB2.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index 3f90f47b1..a62cf4524 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -46,7 +46,7 @@ import Data.ByteString.Base64 (encode) import qualified Data.ByteString.Char8 as B8 import Data.Char (isAscii, isControl, isSpace, toLower) import Data.Either (lefts, rights) -import Data.List (intercalate, intersperse, isPrefixOf, stripPrefix) +import Data.List (intercalate, isPrefixOf, stripPrefix) import Data.Text (Text, pack) import Network.HTTP (urlEncode) import Text.XML.Light @@ -180,7 +180,7 @@ renderSection :: PandocMonad m => Int -> ([Inline], [Block]) -> FBM m Content renderSection level (ttl, body) = do title <- if null ttl then return [] - else return . list . el "title" . formatTitle $ ttl + else list . el "title" <$> formatTitle ttl content <- if hasSubsections body then renderSections (level + 1) body else cMapM blockToXml body @@ -189,11 +189,9 @@ renderSection level (ttl, body) = do hasSubsections = any isHeaderBlock -- | Only

and are allowed within in FB2. -formatTitle :: [Inline] -> [Content] +formatTitle :: PandocMonad m => [Inline] -> FBM m [Content] formatTitle inlines = - let lns = split isLineBreak inlines - lns' = map (el "p" . cMap plain) lns - in intersperse (el "empty-line" ()) lns' + cMapM (blockToXml . Para) $ split (== LineBreak) inlines split :: (a -> Bool) -> [a] -> [[a]] split _ [] = [] -- cgit v1.2.3