From f224567d52096fd6219a2a4a4d2b9cbcc5219e7a Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 4 Apr 2018 02:41:56 +0300 Subject: FB2 writer: represent HorizontalRule as empty line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HorizontalRule corresponds to
element in the default output format, HTML. Current HTML standard defines
element as "paragraph-level thematic break". In typography it is often represented by extra space or centered asterism ("⁂"), but since FB2 does not support text centering, empty line (similar to extra space) is the only solution. Line breaks, on the other hand, don't generate anymore. Previously line breaks generated element inside paragraph, which is not allowed. So, this commit addresses issue #2424 ("FB2 produced by pandoc doesn't validate"). FB2 does not have a way to represent line breaks inside paragraphs. They are replaced with LF character, which is not rendered by FB2 readers, but at least preserves some information. --- src/Text/Pandoc/Writers/FB2.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index a62cf4524..7fcb50b05 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -365,10 +365,7 @@ blockToXml h@Header{} = do -- should not occur after hierarchicalize, except inside lists/blockquotes report $ BlockNotRendered h return [] -blockToXml HorizontalRule = return - [ el "empty-line" () - , el "p" (txt (replicate 10 '—')) - , el "empty-line" () ] +blockToXml HorizontalRule = return [ el "empty-line" () ] blockToXml (Table caption aligns _ headers rows) = do hd <- mkrow "th" headers aligns bd <- mapM (\r -> mkrow "td" r aligns) rows @@ -398,7 +395,7 @@ plainToPara [] = [] plainToPara (Plain inlines : rest) = Para inlines : plainToPara rest plainToPara (Para inlines : rest) = - Para inlines : Plain [LineBreak] : plainToPara rest + Para inlines : HorizontalRule : plainToPara rest -- HorizontalRule will be converted to plainToPara (p:rest) = p : plainToPara rest -- Simulate increased indentation level. Will not really work @@ -449,8 +446,8 @@ toXml (Quoted DoubleQuote ss) = do toXml (Cite _ ss) = cMapM toXml ss -- FIXME: support citation styles toXml (Code _ s) = return [el "code" s] toXml Space = return [txt " "] -toXml SoftBreak = return [txt " "] -toXml LineBreak = return [el "empty-line" ()] +toXml SoftBreak = return [txt "\n"] +toXml LineBreak = return [txt "\n"] toXml (Math _ formula) = insertMath InlineImage formula toXml il@(RawInline _ _) = do report $ InlineNotRendered il -- cgit v1.2.3