git.iko.soy/typeable/pandoc
on master help sign in
Add support for the LineBlock element to writers

The following markup features are used to output the lines of the `LineBlock` element: - AsciiDoc: a `[verse]` block, - ConTeXt: text surrounded by `\startlines` and `\endlines`, - HTML: `div` with an per-element style setting to interpret the content as pre-wrapped, - Markdown: line blocks if the `line_blocks` extension is enabled, a simple paragraph with hard linebreaks otherwise, - Org: VERSE block, - RST: a line block, and - all other formats: a paragraph, containing hard linebreaks between lines. Custom lua writers should be updated to use the `LineBlock` element.

commit22cb9e3327ff4aea6109c048a185506e67f07ef1 authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 13 Oct 2016, 08:46 (10 years ago) parent64b77cc
24 files changed+102−28
src/Text/Pandoc/Writers/AsciiDoc.hs+7−1 src/Text/Pandoc/Writers/CommonMark.hs+2−1 src/Text/Pandoc/Writers/ConTeXt.hs+3−1 src/Text/Pandoc/Writers/Custom.hs+2 src/Text/Pandoc/Writers/Docbook.hs+2−1 src/Text/Pandoc/Writers/Docx.hs+5−6 src/Text/Pandoc/Writers/DokuWiki.hs+5−2 src/Text/Pandoc/Writers/FB2.hs+3−1 src/Text/Pandoc/Writers/HTML.hs+8−1 src/Text/Pandoc/Writers/Haddock.hs+2 src/Text/Pandoc/Writers/ICML.hs+4−2 src/Text/Pandoc/Writers/LaTeX.hs+2 src/Text/Pandoc/Writers/Man.hs+2−1 src/Text/Pandoc/Writers/Markdown.hs+7−1 src/Text/Pandoc/Writers/MediaWiki.hs+3 src/Text/Pandoc/Writers/Native.hs+2 src/Text/Pandoc/Writers/OpenDocument.hs+2 src/Text/Pandoc/Writers/Org.hs+11 src/Text/Pandoc/Writers/RST.hs+9−2 src/Text/Pandoc/Writers/RTF.hs+2 src/Text/Pandoc/Writers/TEI.hs+8−7 src/Text/Pandoc/Writers/Texinfo.hs+3 src/Text/Pandoc/Writers/Textile.hs+3 src/Text/Pandoc/Writers/ZimWiki.hs+5−1
src/Text/Pandoc/Writers/AsciiDoc.hs+7−1
@@ -137,6 +137,13 @@ blockToAsciiDoc opts (Para inlines) = do
137137 then text "\\"
138138 else empty
139139 return $ esc <> contents <> blankline
140+blockToAsciiDoc opts (LineBlock lns) = do
141+ let docify line = if null line
142+ then return blankline
143+ else inlineListToAsciiDoc opts line
144+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr
145+ contents <- joinWithLinefeeds <$> mapM docify lns
146+ return $ "[verse]" $$ text "--" $$ contents $$ text "--" $$ blankline
140147blockToAsciiDoc _ (RawBlock f s)
141148 | f == "asciidoc" = return $ text s
142149 | otherwise = return empty
@@ -459,4 +466,3 @@ inlineToAsciiDoc opts (Span (ident,_,_) ils) = do
459466 let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
460467 contents <- inlineListToAsciiDoc opts ils
461468 return $ identifier <> contents
462−
src/Text/Pandoc/Writers/CommonMark.hs+2−1
@@ -33,7 +33,7 @@ module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
3333
3434import Text.Pandoc.Writers.HTML (writeHtmlString)
3535import Text.Pandoc.Definition
36−import Text.Pandoc.Shared (isTightList)
36+import Text.Pandoc.Shared (isTightList, linesToPara)
3737import Text.Pandoc.Templates (renderTemplate')
3838import Text.Pandoc.Writers.Shared
3939import Text.Pandoc.Options
@@ -94,6 +94,7 @@ blocksToNodes = foldr blockToNodes []
9494blockToNodes :: Block -> [Node] -> [Node]
9595blockToNodes (Plain xs) = (node PARAGRAPH (inlinesToNodes xs) :)
9696blockToNodes (Para xs) = (node PARAGRAPH (inlinesToNodes xs) :)
97+blockToNodes (LineBlock lns) = blockToNodes $ linesToPara lns
9798blockToNodes (CodeBlock (_,classes,_) xs) =
9899 (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] :)
99100blockToNodes (RawBlock fmt xs)
src/Text/Pandoc/Writers/ConTeXt.hs+3−1
@@ -163,6 +163,9 @@ blockToConTeXt (Para [Image attr txt (src,'f':'i':'g':':':_)]) = do
163163blockToConTeXt (Para lst) = do
164164 contents <- inlineListToConTeXt lst
165165 return $ contents <> blankline
166+blockToConTeXt (LineBlock lns) = do
167+ doclines <- nowrap . vcat <$> mapM inlineListToConTeXt lns
168+ return $ "\\startlines" $$ doclines $$ "\\stoplines" <> blankline
166169blockToConTeXt (BlockQuote lst) = do
167170 contents <- blockListToConTeXt lst
168171 return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline
@@ -467,4 +470,3 @@ fromBcp47 x = fromIso $ head x
467470 fromIso "vi" = "vn"
468471 fromIso "zh" = "cn"
469472 fromIso l = l
470−
src/Text/Pandoc/Writers/Custom.hs+2
@@ -227,6 +227,8 @@ blockToCustom lua (Para [Image attr txt (src,tit)]) =
227227
228228blockToCustom lua (Para inlines) = callfunc lua "Para" inlines
229229
230+blockToCustom lua (LineBlock linesList) = callfunc lua "LineBlock" linesList
231+
230232blockToCustom lua (RawBlock format str) =
231233 callfunc lua "RawBlock" format str
232234
src/Text/Pandoc/Writers/Docbook.hs+2−1
@@ -198,6 +198,8 @@ blockToDocbook opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) =
198198blockToDocbook opts (Para lst)
199199 | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst
200200 | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst
201+blockToDocbook opts (LineBlock lns) =
202+ blockToDocbook opts $ linesToPara lns
201203blockToDocbook opts (BlockQuote blocks) =
202204 inTagsIndented "blockquote" $ blocksToDocbook opts blocks
203205blockToDocbook _ (CodeBlock (_,classes,_) str) =
@@ -385,4 +387,3 @@ idAndRole (id',cls,_) = ident ++ role
385387 role = if null cls
386388 then []
387389 else [("role", unwords cls)]
388−
src/Text/Pandoc/Writers/Docx.hs+5−6
@@ -275,7 +275,7 @@ writeDocx opts doc@(Pandoc meta _) = do
275275 }
276276
277277
278− ((contents, footnotes), st) <- runStateT
278+ ((contents, footnotes), st) <- runStateT
279279 (runReaderT
280280 (writeOpenXML opts{writerWrapText = WrapNone} doc')
281281 env)
@@ -446,7 +446,7 @@ writeDocx opts doc@(Pandoc meta _) = do
446446
447447 let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
448448 map newTextPropToOpenXml newDynamicTextProps ++
449− (styleToOpenXml styleMaps $ writerHighlightStyle opts)
449+ (styleToOpenXml styleMaps $ writerHighlightStyle opts)
450450 let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) }
451451 where
452452 modifyContent
@@ -859,6 +859,7 @@ blockToOpenXML' opts (Para lst) = do
859859 modify $ \s -> s { stFirstPara = False }
860860 contents <- inlinesToOpenXML opts lst
861861 return [mknode "w:p" [] (paraProps' ++ contents)]
862+blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns
862863blockToOpenXML' _ (RawBlock format str)
863864 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
864865 | otherwise = return []
@@ -1032,7 +1033,7 @@ setFirstPara = modify $ \s -> s { stFirstPara = True }
10321033
10331034-- | Convert an inline element to OpenXML.
10341035inlineToOpenXML :: WriterOptions -> Inline -> WS [Element]
1035−inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
1036+inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
10361037
10371038inlineToOpenXML' :: WriterOptions -> Inline -> WS [Element]
10381039inlineToOpenXML' _ (Str str) = formattedString str
@@ -1286,7 +1287,7 @@ withDirection x = do
12861287 textProps <- asks envTextProperties
12871288 -- We want to clean all bidirection (bidi) and right-to-left (rtl)
12881289 -- properties from the props first. This is because we don't want
1289− -- them to stack up.
1290+ -- them to stack up.
12901291 let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps
12911292 textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps
12921293 if isRTL
@@ -1298,5 +1299,3 @@ withDirection x = do
12981299 else flip local x $ \env -> env { envParaProperties = paraProps'
12991300 , envTextProperties = textProps'
13001301 }
1301−
1302−
src/Text/Pandoc/Writers/DokuWiki.hs+5−2
@@ -45,8 +45,8 @@ import Text.Pandoc.Options ( WriterOptions(
4545 , writerStandalone
4646 , writerTemplate
4747 , writerWrapText), WrapOption(..) )
48−import Text.Pandoc.Shared ( escapeURI, removeFormatting, camelCaseToHyphenated
49− , trimr, normalize, substitute )
48+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting
49+ , camelCaseToHyphenated, trimr, normalize, substitute )
5050import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
5151import Text.Pandoc.ImageSize
5252import Text.Pandoc.Templates ( renderTemplate' )
@@ -147,6 +147,9 @@ blockToDokuWiki opts (Para inlines) = do
147147 then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>"
148148 else contents ++ if null indent then "\n" else ""
149149
150+blockToDokuWiki opts (LineBlock lns) =
151+ blockToDokuWiki opts $ linesToPara lns
152+
150153blockToDokuWiki _ (RawBlock f str)
151154 | f == Format "dokuwiki" = return str
152155 -- See https://www.dokuwiki.org/wiki:syntax
src/Text/Pandoc/Writers/FB2.hs+3−1
@@ -46,7 +46,8 @@ import qualified Text.XML.Light.Cursor as XC
4646
4747import Text.Pandoc.Definition
4848import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
49−import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize)
49+import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,
50+ linesToPara)
5051
5152-- | Data to be written at the end of the document:
5253-- (foot)notes, URLs, references, images.
@@ -323,6 +324,7 @@ blockToXml (RawBlock _ s) = return . spaceBeforeAfter .
323324 map (el "p" . el "code") . lines $ s
324325blockToXml (Div _ bs) = cMapM blockToXml bs
325326blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs
327+blockToXml (LineBlock lns) = blockToXml $ linesToPara lns
326328blockToXml (OrderedList a bss) = do
327329 state <- get
328330 let pmrk = parentListMarker state
src/Text/Pandoc/Writers/HTML.hs+8−1
@@ -463,6 +463,13 @@ blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) = do
463463blockToHtml opts (Para lst) = do
464464 contents <- inlineListToHtml opts lst
465465 return $ H.p contents
466+blockToHtml opts (LineBlock lns) =
467+ if writerWrapText opts == WrapNone
468+ then blockToHtml opts $ linesToPara lns
469+ else do
470+ let lf = preEscapedString "\n"
471+ htmlLines <- mconcat . intersperse lf <$> mapM (inlineListToHtml opts) lns
472+ return $ H.div ! A.style "white-space: pre-line;" $ htmlLines
466473blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
467474 let speakerNotes = "notes" `elem` classes
468475 -- we don't want incremental output inside speaker notes, see #1394
@@ -807,7 +814,7 @@ inlineToHtml opts inline =
807814 let brtag = if writerHtml5 opts then H5.br else H.br
808815 return $ case t of
809816 InlineMath -> m
810− DisplayMath -> brtag >> m >> brtag
817+ DisplayMath -> brtag >> m >> brtag
811818 (RawInline f str)
812819 | f == Format "html" -> return $ preEscapedString str
813820 | otherwise -> return mempty
src/Text/Pandoc/Writers/Haddock.hs+2
@@ -108,6 +108,8 @@ blockToHaddock opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
108108blockToHaddock opts (Para inlines) =
109109 -- TODO: if it contains linebreaks, we need to use a @...@ block
110110 (<> blankline) `fmap` blockToHaddock opts (Plain inlines)
111+blockToHaddock opts (LineBlock lns) =
112+ blockToHaddock opts $ linesToPara lns
111113blockToHaddock _ (RawBlock f str)
112114 | f == "haddock" = do
113115 return $ text str <> text "\n"
src/Text/Pandoc/Writers/ICML.hs+4−2
@@ -2,7 +2,7 @@
22
33{- |
44 Module : Text.Pandoc.Writers.ICML
5− Copyright : Copyright (C) 2013 github.com/mb21
5+ Copyright : Copyright (C) 2013-2016 github.com/mb21
66 License : GNU GPL, version 2 or above
77
88 Stability : alpha
@@ -18,7 +18,7 @@ import Text.Pandoc.Definition
1818import Text.Pandoc.XML
1919import Text.Pandoc.Readers.TeXMath (texMathToInlines)
2020import Text.Pandoc.Writers.Shared
21−import Text.Pandoc.Shared (splitBy, fetchItem, warn)
21+import Text.Pandoc.Shared (linesToPara, splitBy, fetchItem, warn)
2222import Text.Pandoc.Options
2323import Text.Pandoc.Templates (renderTemplate')
2424import Text.Pandoc.Pretty
@@ -297,6 +297,8 @@ blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do
297297 caption <- parStyle opts (imgCaptionName:style) txt
298298 return $ intersperseBrs [figure, caption]
299299blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
300+blockToICML opts style (LineBlock lns) =
301+ blockToICML opts style $ linesToPara lns
300302blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
301303blockToICML _ _ (RawBlock f str)
302304 | f == Format "icml" = return $ text str
src/Text/Pandoc/Writers/LaTeX.hs+2
@@ -437,6 +437,8 @@ blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
437437 else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."]
438438blockToLaTeX (Para lst) =
439439 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
440+blockToLaTeX (LineBlock lns) = do
441+ blockToLaTeX $ linesToPara lns
440442blockToLaTeX (BlockQuote lst) = do
441443 beamer <- writerBeamer `fmap` gets stOptions
442444 case lst of
src/Text/Pandoc/Writers/Man.hs+2−1
@@ -171,6 +171,8 @@ blockToMan opts (Para inlines) = do
171171 contents <- liftM vcat $ mapM (inlineListToMan opts) $
172172 splitSentences inlines
173173 return $ text ".PP" $$ contents
174+blockToMan opts (LineBlock lns) =
175+ blockToMan opts $ linesToPara lns
174176blockToMan _ (RawBlock f str)
175177 | f == Format "man" = return $ text str
176178 | otherwise = return empty
@@ -367,4 +369,3 @@ inlineToMan _ (Note contents) = do
367369 notes <- liftM stNotes get
368370 let ref = show $ (length notes)
369371 return $ char '[' <> text ref <> char ']'
370−
src/Text/Pandoc/Writers/Markdown.hs+7−1
@@ -79,7 +79,7 @@ instance Default WriterEnv
7979 , envRefShortcutable = True
8080 , envBlockLevel = 0
8181 }
82−
82+
8383data WriterState = WriterState { stNotes :: Notes
8484 , stRefs :: Refs
8585 , stIds :: Set.Set String
@@ -390,6 +390,12 @@ blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
390390 blockToMarkdown opts (Para [Image attr alt (src,tit)])
391391blockToMarkdown' opts (Para inlines) =
392392 (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
393+blockToMarkdown' opts (LineBlock lns) =
394+ if isEnabled Ext_line_blocks opts
395+ then do
396+ mdLines <- mapM (inlineListToMarkdown opts) lns
397+ return $ (vcat $ map (hang 2 (text "| ")) mdLines) <> blankline
398+ else blockToMarkdown opts $ linesToPara lns
393399blockToMarkdown' opts (RawBlock f str)
394400 | f == "markdown" = return $ text str <> text "\n"
395401 | f == "html" && isEnabled Ext_raw_html opts = do
src/Text/Pandoc/Writers/MediaWiki.hs+3
@@ -120,6 +120,9 @@ blockToMediaWiki (Para inlines) = do
120120 then "<p>" ++ contents ++ "</p>"
121121 else contents ++ if null lev then "\n" else ""
122122
123+blockToMediaWiki (LineBlock lns) =
124+ blockToMediaWiki $ linesToPara lns
125+
123126blockToMediaWiki (RawBlock f str)
124127 | f == Format "mediawiki" = return str
125128 | f == Format "html" = return str
src/Text/Pandoc/Writers/Native.hs+2
@@ -45,6 +45,8 @@ prettyList ds =
4545
4646-- | Prettyprint Pandoc block element.
4747prettyBlock :: Block -> Doc
48+prettyBlock (LineBlock lines') =
49+ "LineBlock" $$ prettyList (map (text . show) lines')
4850prettyBlock (BlockQuote blocks) =
4951 "BlockQuote" $$ prettyList (map prettyBlock blocks)
5052prettyBlock (OrderedList attribs blockLists) =
src/Text/Pandoc/Writers/OpenDocument.hs+2
@@ -33,6 +33,7 @@ module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Options
3535import Text.Pandoc.XML
36+import Text.Pandoc.Shared (linesToPara)
3637import Text.Pandoc.Templates (renderTemplate')
3738import Text.Pandoc.Readers.TeXMath
3839import Text.Pandoc.Pretty
@@ -291,6 +292,7 @@ blockToOpenDocument o bs
291292 | Para b <- bs = if null b
292293 then return empty
293294 else inParagraphTags =<< inlinesToOpenDocument o b
295+ | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
294296 | Div _ xs <- bs = blocksToOpenDocument o xs
295297 | Header i _ b <- bs = setFirstPara >>
296298 (inHeaderTags i =<< inlinesToOpenDocument o b)
src/Text/Pandoc/Writers/Org.hs+11
@@ -164,6 +164,17 @@ blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
164164blockToOrg (Para inlines) = do
165165 contents <- inlineListToOrg inlines
166166 return $ contents <> blankline
167+blockToOrg (LineBlock lns) = do
168+ let splitStanza [] = []
169+ splitStanza xs = case break (== mempty) xs of
170+ (l, []) -> l : []
171+ (l, _:r) -> l : splitStanza r
172+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr
173+ let joinWithBlankLines = mconcat . intersperse blankline
174+ let prettyfyStanza ls = joinWithLinefeeds <$> mapM inlineListToOrg ls
175+ contents <- joinWithBlankLines <$> mapM prettyfyStanza (splitStanza lns)
176+ return $ blankline $$ "#+BEGIN_VERSE" $$
177+ nest 2 contents $$ "#+END_VERSE" <> blankline
167178blockToOrg (RawBlock "html" str) =
168179 return $ blankline $$ "#+BEGIN_HTML" $$
169180 nest 2 (text str) $$ "#+END_HTML" $$ blankline
src/Text/Pandoc/Writers/RST.hs+9−2
@@ -201,11 +201,12 @@ blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
201201 return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline
202202blockToRST (Para inlines)
203203 | LineBreak `elem` inlines = do -- use line block if LineBreaks
204− lns <- mapM inlineListToRST $ splitBy (==LineBreak) inlines
205− return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline
204+ linesToLineBlock $ splitBy (==LineBreak) inlines
206205 | otherwise = do
207206 contents <- inlineListToRST inlines
208207 return $ contents <> blankline
208+blockToRST (LineBlock lns) =
209+ linesToLineBlock lns
209210blockToRST (RawBlock f@(Format f') str)
210211 | f == "rst" = return $ text str
211212 | otherwise = return $ blankline <> ".. raw:: " <>
@@ -328,6 +329,12 @@ definitionListItemToRST (label, defs) = do
328329 tabstop <- get >>= (return . writerTabStop . stOptions)
329330 return $ label' $$ nest tabstop (nestle contents <> cr)
330331
332+-- | Format a list of lines as line block.
333+linesToLineBlock :: [[Inline]] -> State WriterState Doc
334+linesToLineBlock inlineLines = do
335+ lns <- mapM inlineListToRST inlineLines
336+ return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline
337+
331338-- | Convert list of Pandoc block elements to RST.
332339blockListToRST' :: Bool
333340 -> [Block] -- ^ List of block elements
src/Text/Pandoc/Writers/RTF.hs+2
@@ -233,6 +233,8 @@ blockToRTF indent alignment (Plain lst) =
233233 rtfCompact indent 0 alignment $ inlineListToRTF lst
234234blockToRTF indent alignment (Para lst) =
235235 rtfPar indent 0 alignment $ inlineListToRTF lst
236+blockToRTF indent alignment (LineBlock lns) =
237+ blockToRTF indent alignment $ linesToPara lns
236238blockToRTF indent alignment (BlockQuote lst) =
237239 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
238240blockToRTF indent _ (CodeBlock _ str) =
src/Text/Pandoc/Writers/TEI.hs+8−7
@@ -108,7 +108,7 @@ plainToPara :: Block -> Block
108108plainToPara (Plain x) = Para x
109109plainToPara x = x
110110
111−-- | Convert a list of pairs of terms and definitions into a TEI
111+-- | Convert a list of pairs of terms and definitions into a TEI
112112-- list with labels and items.
113113deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc
114114deflistItemsToTEI opts items =
@@ -167,6 +167,8 @@ blockToTEI opts (Plain lst) = blockToTEI opts $ Para lst
167167-- inTagsSimple "textobject" (inTagsSimple "phrase" alt))
168168blockToTEI opts (Para lst) =
169169 inTags False "p" [] $ inlinesToTEI opts lst
170+blockToTEI opts (LineBlock lns) =
171+ blockToTEI opts $ linesToPara lns
170172blockToTEI opts (BlockQuote blocks) =
171173 inTagsIndented "quote" $ blocksToTEI opts blocks
172174blockToTEI _ (CodeBlock (_,classes,_) str) =
@@ -174,7 +176,7 @@ blockToTEI _ (CodeBlock (_,classes,_) str) =
174176 flush (text (escapeStringForXML str) <> cr <> text "</ab>")
175177 where lang = if null langs
176178 then ""
177− else escapeStringForXML (head langs)
179+ else escapeStringForXML (head langs)
178180 isLang l = map toLower l `elem` map (map toLower) languages
179181 langsFrom s = if isLang s
180182 then [s]
@@ -210,7 +212,7 @@ blockToTEI _ HorizontalRule =
210212 selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")]
211213
212214-- | TEI Tables
213−-- TEI Simple's tables are composed of cells and rows; other
215+-- TEI Simple's tables are composed of cells and rows; other
214216-- table info in the AST is here lossily discard.
215217blockToTEI opts (Table _ _ _ headers rows) =
216218 let
@@ -219,8 +221,8 @@ blockToTEI opts (Table _ _ _ headers rows) =
219221-- then return empty
220222-- else tableRowToTEI opts headers
221223 in
222− inTags True "table" [] $
223− vcat $ [headers'] <> map (tableRowToTEI opts) rows
224+ inTags True "table" [] $
225+ vcat $ [headers'] <> map (tableRowToTEI opts) rows
224226
225227tableRowToTEI :: WriterOptions
226228 -> [[Block]]
@@ -276,7 +278,7 @@ inlineToTEI _ (Math t str) =
276278 text (str)
277279 DisplayMath -> inTags True "figure" [("type","math")] $
278280 inTags False "formula" [("notation","TeX")] $ text (str)
279−
281+
280282inlineToTEI _ (RawInline f x) | f == "tei" = text x
281283 | otherwise = empty
282284inlineToTEI _ LineBreak = selfClosingTag "lb" []
@@ -317,4 +319,3 @@ idAndRole (id',cls,_) = ident ++ role
317319 role = if null cls
318320 then []
319321 else [("role", unwords cls)]
320−
src/Text/Pandoc/Writers/Texinfo.hs+3
@@ -145,6 +145,9 @@ blockToTexinfo (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
145145blockToTexinfo (Para lst) =
146146 inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo
147147
148+blockToTexinfo (LineBlock lns) =
149+ blockToTexinfo $ linesToPara lns
150+
148151blockToTexinfo (BlockQuote lst) = do
149152 contents <- blockListToTexinfo lst
150153 return $ text "@quotation" $$
src/Text/Pandoc/Writers/Textile.hs+3
@@ -130,6 +130,9 @@ blockToTextile opts (Para inlines) = do
130130 then "<p>" ++ contents ++ "</p>"
131131 else contents ++ if null listLevel then "\n" else ""
132132
133+blockToTextile opts (LineBlock lns) =
134+ blockToTextile opts $ linesToPara lns
135+
133136blockToTextile _ (RawBlock f str)
134137 | f == Format "html" || f == Format "textile" = return str
135138 | otherwise = return ""
src/Text/Pandoc/Writers/ZimWiki.hs+5−1
@@ -33,7 +33,8 @@ http://zim-wiki.org/manual/Help/Wiki_Syntax.html
3333module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
3434import Text.Pandoc.Definition
3535import Text.Pandoc.Options ( WriterOptions(writerTableOfContents, writerStandalone, writerTemplate, writerWrapText), WrapOption(..) )
36−import Text.Pandoc.Shared ( escapeURI, removeFormatting, trimr, substitute )
36+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting, trimr
37+ , substitute )
3738import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
3839import Text.Pandoc.ImageSize
3940import Text.Pandoc.Templates ( renderTemplate' )
@@ -111,6 +112,9 @@ blockToZimWiki opts (Para inlines) = do
111112 contents <- inlineListToZimWiki opts inlines
112113 return $ contents ++ if null indent then "\n" else ""
113114
115+blockToZimWiki opts (LineBlock lns) = do
116+ blockToZimWiki opts $ linesToPara lns
117+
114118blockToZimWiki opts (RawBlock f str)
115119 | f == Format "zimwiki" = return str
116120 | f == Format "html" = do cont <- indentFromHTML opts str; return cont