aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-04-04 02:41:56 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-04-05 19:53:36 +0300
commitf224567d52096fd6219a2a4a4d2b9cbcc5219e7a (patch)
tree026b5b925aa36d3415ccd615bc8ba0cec74d63d0 /src
parent87dda2109d01098dcf41c01559d3e91e2627cd10 (diff)
downloadpandoc-f224567d52096fd6219a2a4a4d2b9cbcc5219e7a.tar.gz
FB2 writer: represent HorizontalRule as empty line
HorizontalRule corresponds to <hr> element in the default output format, HTML. Current HTML standard defines <hr> 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 <empty-line /> anymore. Previously line breaks generated <empty-line /> 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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs11
1 files changed, 4 insertions, 7 deletions
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 <empty-line />
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