git.iko.soy/typeable/pandoc
on master help sign in
OpenDocument writer: Fixed RawInline, RawBlock so they don't escape.
commitac100f27249e4c572e687d027330ca2cc53cb1ed authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 2 Jan 2014, 15:23 (13 years ago) parente3d48da
1 file changed+10−6
src/Text/Pandoc/Writers/OpenDocument.hs+10−6
src/Text/Pandoc/Writers/OpenDocument.hs+10−6
@@ -285,8 +285,12 @@ blocksToOpenDocument o b = vcat <$> mapM (blockToOpenDocument o) b
285285-- | Convert a Pandoc block element to OpenDocument.
286286blockToOpenDocument :: WriterOptions -> Block -> State WriterState Doc
287287blockToOpenDocument o bs
288− | Plain b <- bs = inParagraphTags =<< inlinesToOpenDocument o b
289− | Para b <- bs = inParagraphTags =<< inlinesToOpenDocument o b
288+ | Plain b <- bs = if null b
289+ then return empty
290+ else inParagraphTags =<< inlinesToOpenDocument o b
291+ | Para b <- bs = if null b
292+ then return empty
293+ else inParagraphTags =<< inlinesToOpenDocument o b
290294 | Div _ xs <- bs = blocksToOpenDocument o xs
291295 | Header i _ b <- bs = setFirstPara >>
292296 (inHeaderTags i =<< inlinesToOpenDocument o b)
@@ -298,8 +302,8 @@ blockToOpenDocument o bs
298302 | Table c a w h r <- bs = setFirstPara >> table c a w h r
299303 | HorizontalRule <- bs = setFirstPara >> return (selfClosingTag "text:p"
300304 [ ("text:style-name", "Horizontal_20_Line") ])
301− | RawBlock f s <- bs = if f == "opendocument"
302− then preformatted s
305+ | RawBlock f s <- bs = if f == Format "opendocument"
306+ then return $ text s
303307 else return empty
304308 | Null <- bs = return empty
305309 | otherwise = return empty
@@ -378,8 +382,8 @@ inlineToOpenDocument o ils
378382 | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s
379383 | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s)
380384 | Cite _ l <- ils = inlinesToOpenDocument o l
381− | RawInline f s <- ils = if f == "opendocument"
382− then return $ preformatted s
385+ | RawInline f s <- ils = if f == Format "opendocument"
386+ then return $ text s
383387 else return empty
384388 | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l
385389 | Image _ (s,t) <- ils = mkImg s t