git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3072 from tarleb/lineblock
4eff607John MacFarlane
pandoc.cabal+5−5
@@ -205,8 +205,8 @@ Extra-Source-Files:
205 tests/lhs-test.html+lhs
205 tests/lhs-test.html+lhs
206 tests/lhs-test.fragment.html+lhs
206 tests/lhs-test.fragment.html+lhs
207 tests/pipe-tables.txt
207 tests/pipe-tables.txt
208− tests/dokuwiki_external_images.dokuwiki
208+ tests/dokuwiki_external_images.dokuwiki
209− tests/dokuwiki_external_images.native
209+ tests/dokuwiki_external_images.native
210 tests/dokuwiki_multiblock_table.dokuwiki
210 tests/dokuwiki_multiblock_table.dokuwiki
211 tests/dokuwiki_multiblock_table.native
211 tests/dokuwiki_multiblock_table.native
212 tests/fb2/*.markdown
212 tests/fb2/*.markdown
@@ -267,7 +267,7 @@ Library
267 xml >= 1.3.12 && < 1.4,
267 xml >= 1.3.12 && < 1.4,
268 random >= 1 && < 1.2,
268 random >= 1 && < 1.2,
269 extensible-exceptions >= 0.1 && < 0.2,
269 extensible-exceptions >= 0.1 && < 0.2,
270− pandoc-types >= 1.16 && < 1.17,
270+ pandoc-types >= 1.17 && < 1.18,
271 aeson >= 0.7 && < 1.1,
271 aeson >= 0.7 && < 1.1,
272 tagsoup >= 0.13.7 && < 0.15,
272 tagsoup >= 0.13.7 && < 0.15,
273 base64-bytestring >= 0.1 && < 1.1,
273 base64-bytestring >= 0.1 && < 1.1,
@@ -422,7 +422,7 @@ Library
422
422
423Executable pandoc
423Executable pandoc
424 Build-Depends: pandoc,
424 Build-Depends: pandoc,
425− pandoc-types >= 1.16 && < 1.17,
425+ pandoc-types >= 1.17 && < 1.18,
426 base >= 4.2 && <5,
426 base >= 4.2 && <5,
427 directory >= 1.2 && < 1.3,
427 directory >= 1.2 && < 1.3,
428 filepath >= 1.1 && < 1.5,
428 filepath >= 1.1 && < 1.5,
@@ -479,7 +479,7 @@ Test-Suite test-pandoc
479 Build-Depends: base >= 4.2 && < 5,
479 Build-Depends: base >= 4.2 && < 5,
480 syb >= 0.1 && < 0.7,
480 syb >= 0.1 && < 0.7,
481 pandoc,
481 pandoc,
482− pandoc-types >= 1.16 && < 1.17,
482+ pandoc-types >= 1.17 && < 1.18,
483 bytestring >= 0.9 && < 0.11,
483 bytestring >= 0.9 && < 0.11,
484 text >= 0.11 && < 1.3,
484 text >= 0.11 && < 1.3,
485 directory >= 1 && < 1.3,
485 directory >= 1 && < 1.3,
src/Text/Pandoc/Parsing.hs+5−2
@@ -718,11 +718,14 @@ lineBlockLine = try $ do
718 continuations <- many (try $ char ' ' >> anyLine)
718 continuations <- many (try $ char ' ' >> anyLine)
719 return $ white ++ unwords (line : continuations)
719 return $ white ++ unwords (line : continuations)
720
720
721+blankLineBlockLine :: Stream [Char] m Char => ParserT [Char] st m Char
722+blankLineBlockLine = try (char '|' >> blankline)
723+
721-- | Parses an RST-style line block and returns a list of strings.
724-- | Parses an RST-style line block and returns a list of strings.
722lineBlockLines :: Stream [Char] m Char => ParserT [Char] st m [String]
725lineBlockLines :: Stream [Char] m Char => ParserT [Char] st m [String]
723lineBlockLines = try $ do
726lineBlockLines = try $ do
724− lines' <- many1 lineBlockLine
727+ lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
725− skipMany1 $ blankline <|> try (char '|' >> blankline)
728+ skipMany1 $ blankline <|> blankLineBlockLine
726 return lines'
729 return lines'
727
730
728-- | Parse a table using 'headerParser', 'rowParser',
731-- | Parse a table using 'headerParser', 'rowParser',
src/Text/Pandoc/Readers/DocBook.hs+3−3
@@ -592,8 +592,6 @@ checkInMeta p = do
592 when accepts p
592 when accepts p
593 return mempty
593 return mempty
594
594
595−
596−
597addMeta :: ToMetaValue a => String -> a -> DB ()
595addMeta :: ToMetaValue a => String -> a -> DB ()
598addMeta field val = modify (setMeta field val)
596addMeta field val = modify (setMeta field val)
599
597
@@ -612,7 +610,7 @@ isBlockElement (Elem e) = qName (elName e) `elem` blocktags
612 "important","caution","note","tip","warning","qandadiv",
610 "important","caution","note","tip","warning","qandadiv",
613 "question","answer","abstract","itemizedlist","orderedlist",
611 "question","answer","abstract","itemizedlist","orderedlist",
614 "variablelist","article","book","table","informaltable",
612 "variablelist","article","book","table","informaltable",
615− "informalexample",
613+ "informalexample", "linegroup",
616 "screen","programlisting","example","calloutlist"]
614 "screen","programlisting","example","calloutlist"]
617isBlockElement _ = False
615isBlockElement _ = False
618
616
@@ -779,6 +777,7 @@ parseBlock (Elem e) =
779 "informaltable" -> parseTable
777 "informaltable" -> parseTable
780 "informalexample" -> divWith ("", ["informalexample"], []) <$>
778 "informalexample" -> divWith ("", ["informalexample"], []) <$>
781 getBlocks e
779 getBlocks e
780+ "linegroup" -> lineBlock <$> lineItems
782 "literallayout" -> codeBlockWithLang
781 "literallayout" -> codeBlockWithLang
783 "screen" -> codeBlockWithLang
782 "screen" -> codeBlockWithLang
784 "programlisting" -> codeBlockWithLang
783 "programlisting" -> codeBlockWithLang
@@ -900,6 +899,7 @@ parseBlock (Elem e) =
900 let ident = attrValue "id" e
899 let ident = attrValue "id" e
901 modify $ \st -> st{ dbSectionLevel = n - 1 }
900 modify $ \st -> st{ dbSectionLevel = n - 1 }
902 return $ headerWith (ident,[],[]) n' headerText <> b
901 return $ headerWith (ident,[],[]) n' headerText <> b
902+ lineItems = mapM getInlines $ filterChildren (named "line") e
903 metaBlock = acceptingMetadata (getBlocks e) >> return mempty
903 metaBlock = acceptingMetadata (getBlocks e) >> return mempty
904
904
905getInlines :: Element -> DB Inlines
905getInlines :: Element -> DB Inlines
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -32,7 +32,7 @@ Conversion of markdown-formatted plain text to 'Pandoc' document.
32module Text.Pandoc.Readers.Markdown ( readMarkdown,
32module Text.Pandoc.Readers.Markdown ( readMarkdown,
33 readMarkdownWithWarnings ) where
33 readMarkdownWithWarnings ) where
34
34
35−import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
35+import Data.List ( transpose, sortBy, findIndex, intercalate )
36import qualified Data.Map as M
36import qualified Data.Map as M
37import Data.Scientific (coefficient, base10Exponent)
37import Data.Scientific (coefficient, base10Exponent)
38import Data.Ord ( comparing )
38import Data.Ord ( comparing )
@@ -1106,7 +1106,7 @@ lineBlock = try $ do
1106 guardEnabled Ext_line_blocks
1106 guardEnabled Ext_line_blocks
1107 lines' <- lineBlockLines >>=
1107 lines' <- lineBlockLines >>=
1108 mapM (parseFromString (trimInlinesF . mconcat <$> many inline))
1108 mapM (parseFromString (trimInlinesF . mconcat <$> many inline))
1109− return $ B.para <$> (mconcat $ intersperse (return B.linebreak) lines')
1109+ return $ B.lineBlock <$> sequence lines'
1110
1110
1111--
1111--
1112-- Tables
1112-- Tables
src/Text/Pandoc/Readers/Org/Blocks.hs+2−2
@@ -50,7 +50,7 @@ import Text.Pandoc.Shared ( compactify', compactify'DL )
50
50
51import Control.Monad ( foldM, guard, mzero, void )
51import Control.Monad ( foldM, guard, mzero, void )
52import Data.Char ( isSpace, toLower, toUpper)
52import Data.Char ( isSpace, toLower, toUpper)
53−import Data.List ( foldl', intersperse, isPrefixOf )
53+import Data.List ( foldl', isPrefixOf )
54import Data.Maybe ( fromMaybe, isNothing )
54import Data.Maybe ( fromMaybe, isNothing )
55import Data.Monoid ((<>))
55import Data.Monoid ((<>))
56
56
@@ -427,7 +427,7 @@ verseBlock :: String -> OrgParser (F Blocks)
427verseBlock blockType = try $ do
427verseBlock blockType = try $ do
428 ignHeaders
428 ignHeaders
429 content <- rawBlockContent blockType
429 content <- rawBlockContent blockType
430− fmap B.para . mconcat . intersperse (pure B.linebreak)
430+ fmap B.lineBlock . sequence
431 <$> mapM parseVerseLine (lines content)
431 <$> mapM parseVerseLine (lines content)
432 where
432 where
433 -- replace initial spaces with nonbreaking spaces to preserve
433 -- replace initial spaces with nonbreaking spaces to preserve
src/Text/Pandoc/Readers/RST.hs+2−2
@@ -39,7 +39,7 @@ import Text.Pandoc.Shared
39import Text.Pandoc.Parsing
39import Text.Pandoc.Parsing
40import Text.Pandoc.Options
40import Text.Pandoc.Options
41import Control.Monad ( when, liftM, guard, mzero )
41import Control.Monad ( when, liftM, guard, mzero )
42−import Data.List ( findIndex, intersperse, intercalate,
42+import Data.List ( findIndex, intercalate,
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
44import Data.Maybe (fromMaybe)
44import Data.Maybe (fromMaybe)
45import qualified Data.Map as M
45import qualified Data.Map as M
@@ -228,7 +228,7 @@ lineBlock :: RSTParser Blocks
228lineBlock = try $ do
228lineBlock = try $ do
229 lines' <- lineBlockLines
229 lines' <- lineBlockLines
230 lines'' <- mapM parseInlineFromString lines'
230 lines'' <- mapM parseInlineFromString lines'
231− return $ B.para (mconcat $ intersperse B.linebreak lines'')
231+ return $ B.lineBlock lines''
232
232
233--
233--
234-- paragraph block
234-- paragraph block
src/Text/Pandoc/Shared.hs+11
@@ -64,6 +64,7 @@ module Text.Pandoc.Shared (
64 compactify,
64 compactify,
65 compactify',
65 compactify',
66 compactify'DL,
66 compactify'DL,
67+ linesToPara,
67 Element (..),
68 Element (..),
68 hierarchicalize,
69 hierarchicalize,
69 uniqueIdent,
70 uniqueIdent,
@@ -630,6 +631,15 @@ compactify'DL items =
630 | otherwise -> items
631 | otherwise -> items
631 _ -> items
632 _ -> items
632
633
634+-- | Combine a list of lines by adding hard linebreaks.
635+combineLines :: [[Inline]] -> [Inline]
636+combineLines = intercalate [LineBreak]
637+
638+-- | Convert a list of lines into a paragraph with hard line breaks. This is
639+-- useful e.g. for rudimentary support of LineBlock elements in writers.
640+linesToPara :: [[Inline]] -> Block
641+linesToPara = Para . combineLines
642+
633isPara :: Block -> Bool
643isPara :: Block -> Bool
634isPara (Para _) = True
644isPara (Para _) = True
635isPara _ = False
645isPara _ = False
@@ -1035,6 +1045,7 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories
1035blockToInlines :: Block -> [Inline]
1045blockToInlines :: Block -> [Inline]
1036blockToInlines (Plain ils) = ils
1046blockToInlines (Plain ils) = ils
1037blockToInlines (Para ils) = ils
1047blockToInlines (Para ils) = ils
1048+blockToInlines (LineBlock lns) = combineLines lns
1038blockToInlines (CodeBlock attr str) = [Code attr str]
1049blockToInlines (CodeBlock attr str) = [Code attr str]
1039blockToInlines (RawBlock fmt str) = [RawInline fmt str]
1050blockToInlines (RawBlock fmt str) = [RawInline fmt str]
1040blockToInlines (BlockQuote blks) = blocksToInlines blks
1051blockToInlines (BlockQuote blks) = blocksToInlines blks
src/Text/Pandoc/Writers/AsciiDoc.hs+7−1
@@ -137,6 +137,13 @@ blockToAsciiDoc opts (Para inlines) = do
137 then text "\\"
137 then text "\\"
138 else empty
138 else empty
139 return $ esc <> contents <> blankline
139 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
140blockToAsciiDoc _ (RawBlock f s)
147blockToAsciiDoc _ (RawBlock f s)
141 | f == "asciidoc" = return $ text s
148 | f == "asciidoc" = return $ text s
142 | otherwise = return empty
149 | otherwise = return empty
@@ -459,4 +466,3 @@ inlineToAsciiDoc opts (Span (ident,_,_) ils) = do
459 let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
466 let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
460 contents <- inlineListToAsciiDoc opts ils
467 contents <- inlineListToAsciiDoc opts ils
461 return $ identifier <> contents
468 return $ identifier <> contents
462−
src/Text/Pandoc/Writers/CommonMark.hs+2−1
@@ -33,7 +33,7 @@ module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
33
33
34import Text.Pandoc.Writers.HTML (writeHtmlString)
34import Text.Pandoc.Writers.HTML (writeHtmlString)
35import Text.Pandoc.Definition
35import Text.Pandoc.Definition
36−import Text.Pandoc.Shared (isTightList)
36+import Text.Pandoc.Shared (isTightList, linesToPara)
37import Text.Pandoc.Templates (renderTemplate')
37import Text.Pandoc.Templates (renderTemplate')
38import Text.Pandoc.Writers.Shared
38import Text.Pandoc.Writers.Shared
39import Text.Pandoc.Options
39import Text.Pandoc.Options
@@ -94,6 +94,7 @@ blocksToNodes = foldr blockToNodes []
94blockToNodes :: Block -> [Node] -> [Node]
94blockToNodes :: Block -> [Node] -> [Node]
95blockToNodes (Plain xs) = (node PARAGRAPH (inlinesToNodes xs) :)
95blockToNodes (Plain xs) = (node PARAGRAPH (inlinesToNodes xs) :)
96blockToNodes (Para xs) = (node PARAGRAPH (inlinesToNodes xs) :)
96blockToNodes (Para xs) = (node PARAGRAPH (inlinesToNodes xs) :)
97+blockToNodes (LineBlock lns) = blockToNodes $ linesToPara lns
97blockToNodes (CodeBlock (_,classes,_) xs) =
98blockToNodes (CodeBlock (_,classes,_) xs) =
98 (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] :)
99 (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] :)
99blockToNodes (RawBlock fmt xs)
100blockToNodes (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
163blockToConTeXt (Para lst) = do
163blockToConTeXt (Para lst) = do
164 contents <- inlineListToConTeXt lst
164 contents <- inlineListToConTeXt lst
165 return $ contents <> blankline
165 return $ contents <> blankline
166+blockToConTeXt (LineBlock lns) = do
167+ doclines <- nowrap . vcat <$> mapM inlineListToConTeXt lns
168+ return $ "\\startlines" $$ doclines $$ "\\stoplines" <> blankline
166blockToConTeXt (BlockQuote lst) = do
169blockToConTeXt (BlockQuote lst) = do
167 contents <- blockListToConTeXt lst
170 contents <- blockListToConTeXt lst
168 return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline
171 return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline
@@ -467,4 +470,3 @@ fromBcp47 x = fromIso $ head x
467 fromIso "vi" = "vn"
470 fromIso "vi" = "vn"
468 fromIso "zh" = "cn"
471 fromIso "zh" = "cn"
469 fromIso l = l
472 fromIso l = l
470−
src/Text/Pandoc/Writers/Custom.hs+2
@@ -227,6 +227,8 @@ blockToCustom lua (Para [Image attr txt (src,tit)]) =
227
227
228blockToCustom lua (Para inlines) = callfunc lua "Para" inlines
228blockToCustom lua (Para inlines) = callfunc lua "Para" inlines
229
229
230+blockToCustom lua (LineBlock linesList) = callfunc lua "LineBlock" linesList
231+
230blockToCustom lua (RawBlock format str) =
232blockToCustom lua (RawBlock format str) =
231 callfunc lua "RawBlock" format str
233 callfunc lua "RawBlock" format str
232
234
src/Text/Pandoc/Writers/Docbook.hs+2−1
@@ -198,6 +198,8 @@ blockToDocbook opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) =
198blockToDocbook opts (Para lst)
198blockToDocbook opts (Para lst)
199 | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst
199 | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst
200 | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst
200 | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst
201+blockToDocbook opts (LineBlock lns) =
202+ blockToDocbook opts $ linesToPara lns
201blockToDocbook opts (BlockQuote blocks) =
203blockToDocbook opts (BlockQuote blocks) =
202 inTagsIndented "blockquote" $ blocksToDocbook opts blocks
204 inTagsIndented "blockquote" $ blocksToDocbook opts blocks
203blockToDocbook _ (CodeBlock (_,classes,_) str) =
205blockToDocbook _ (CodeBlock (_,classes,_) str) =
@@ -385,4 +387,3 @@ idAndRole (id',cls,_) = ident ++ role
385 role = if null cls
387 role = if null cls
386 then []
388 then []
387 else [("role", unwords cls)]
389 else [("role", unwords cls)]
388−
src/Text/Pandoc/Writers/Docx.hs+5−6
@@ -275,7 +275,7 @@ writeDocx opts doc@(Pandoc meta _) = do
275 }
275 }
276
276
277
277
278− ((contents, footnotes), st) <- runStateT
278+ ((contents, footnotes), st) <- runStateT
279 (runReaderT
279 (runReaderT
280 (writeOpenXML opts{writerWrapText = WrapNone} doc')
280 (writeOpenXML opts{writerWrapText = WrapNone} doc')
281 env)
281 env)
@@ -446,7 +446,7 @@ writeDocx opts doc@(Pandoc meta _) = do
446
446
447 let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
447 let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
448 map newTextPropToOpenXml newDynamicTextProps ++
448 map newTextPropToOpenXml newDynamicTextProps ++
449− (styleToOpenXml styleMaps $ writerHighlightStyle opts)
449+ (styleToOpenXml styleMaps $ writerHighlightStyle opts)
450 let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) }
450 let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) }
451 where
451 where
452 modifyContent
452 modifyContent
@@ -859,6 +859,7 @@ blockToOpenXML' opts (Para lst) = do
859 modify $ \s -> s { stFirstPara = False }
859 modify $ \s -> s { stFirstPara = False }
860 contents <- inlinesToOpenXML opts lst
860 contents <- inlinesToOpenXML opts lst
861 return [mknode "w:p" [] (paraProps' ++ contents)]
861 return [mknode "w:p" [] (paraProps' ++ contents)]
862+blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns
862blockToOpenXML' _ (RawBlock format str)
863blockToOpenXML' _ (RawBlock format str)
863 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
864 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
864 | otherwise = return []
865 | otherwise = return []
@@ -1032,7 +1033,7 @@ setFirstPara = modify $ \s -> s { stFirstPara = True }
1032
1033
1033-- | Convert an inline element to OpenXML.
1034-- | Convert an inline element to OpenXML.
1034inlineToOpenXML :: WriterOptions -> Inline -> WS [Element]
1035inlineToOpenXML :: WriterOptions -> Inline -> WS [Element]
1035−inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
1036+inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
1036
1037
1037inlineToOpenXML' :: WriterOptions -> Inline -> WS [Element]
1038inlineToOpenXML' :: WriterOptions -> Inline -> WS [Element]
1038inlineToOpenXML' _ (Str str) = formattedString str
1039inlineToOpenXML' _ (Str str) = formattedString str
@@ -1286,7 +1287,7 @@ withDirection x = do
1286 textProps <- asks envTextProperties
1287 textProps <- asks envTextProperties
1287 -- We want to clean all bidirection (bidi) and right-to-left (rtl)
1288 -- We want to clean all bidirection (bidi) and right-to-left (rtl)
1288 -- properties from the props first. This is because we don't want
1289 -- properties from the props first. This is because we don't want
1289− -- them to stack up.
1290+ -- them to stack up.
1290 let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps
1291 let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps
1291 textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps
1292 textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps
1292 if isRTL
1293 if isRTL
@@ -1298,5 +1299,3 @@ withDirection x = do
1298 else flip local x $ \env -> env { envParaProperties = paraProps'
1299 else flip local x $ \env -> env { envParaProperties = paraProps'
1299 , envTextProperties = textProps'
1300 , envTextProperties = textProps'
1300 }
1301 }
1301−
1302−
src/Text/Pandoc/Writers/DokuWiki.hs+5−2
@@ -45,8 +45,8 @@ import Text.Pandoc.Options ( WriterOptions(
45 , writerStandalone
45 , writerStandalone
46 , writerTemplate
46 , writerTemplate
47 , writerWrapText), WrapOption(..) )
47 , writerWrapText), WrapOption(..) )
48−import Text.Pandoc.Shared ( escapeURI, removeFormatting, camelCaseToHyphenated
48+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting
49− , trimr, normalize, substitute )
49+ , camelCaseToHyphenated, trimr, normalize, substitute )
50import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
50import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
51import Text.Pandoc.ImageSize
51import Text.Pandoc.ImageSize
52import Text.Pandoc.Templates ( renderTemplate' )
52import Text.Pandoc.Templates ( renderTemplate' )
@@ -147,6 +147,9 @@ blockToDokuWiki opts (Para inlines) = do
147 then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>"
147 then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>"
148 else contents ++ if null indent then "\n" else ""
148 else contents ++ if null indent then "\n" else ""
149
149
150+blockToDokuWiki opts (LineBlock lns) =
151+ blockToDokuWiki opts $ linesToPara lns
152+
150blockToDokuWiki _ (RawBlock f str)
153blockToDokuWiki _ (RawBlock f str)
151 | f == Format "dokuwiki" = return str
154 | f == Format "dokuwiki" = return str
152 -- See https://www.dokuwiki.org/wiki:syntax
155 -- 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
46
46
47import Text.Pandoc.Definition
47import Text.Pandoc.Definition
48import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
48import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
49−import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize)
49+import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,
50+ linesToPara)
50
51
51-- | Data to be written at the end of the document:
52-- | Data to be written at the end of the document:
52-- (foot)notes, URLs, references, images.
53-- (foot)notes, URLs, references, images.
@@ -323,6 +324,7 @@ blockToXml (RawBlock _ s) = return . spaceBeforeAfter .
323 map (el "p" . el "code") . lines $ s
324 map (el "p" . el "code") . lines $ s
324blockToXml (Div _ bs) = cMapM blockToXml bs
325blockToXml (Div _ bs) = cMapM blockToXml bs
325blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs
326blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs
327+blockToXml (LineBlock lns) = blockToXml $ linesToPara lns
326blockToXml (OrderedList a bss) = do
328blockToXml (OrderedList a bss) = do
327 state <- get
329 state <- get
328 let pmrk = parentListMarker state
330 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
463blockToHtml opts (Para lst) = do
463blockToHtml opts (Para lst) = do
464 contents <- inlineListToHtml opts lst
464 contents <- inlineListToHtml opts lst
465 return $ H.p contents
465 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
466blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
473blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
467 let speakerNotes = "notes" `elem` classes
474 let speakerNotes = "notes" `elem` classes
468 -- we don't want incremental output inside speaker notes, see #1394
475 -- we don't want incremental output inside speaker notes, see #1394
@@ -807,7 +814,7 @@ inlineToHtml opts inline =
807 let brtag = if writerHtml5 opts then H5.br else H.br
814 let brtag = if writerHtml5 opts then H5.br else H.br
808 return $ case t of
815 return $ case t of
809 InlineMath -> m
816 InlineMath -> m
810− DisplayMath -> brtag >> m >> brtag
817+ DisplayMath -> brtag >> m >> brtag
811 (RawInline f str)
818 (RawInline f str)
812 | f == Format "html" -> return $ preEscapedString str
819 | f == Format "html" -> return $ preEscapedString str
813 | otherwise -> return mempty
820 | 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)]) =
108blockToHaddock opts (Para inlines) =
108blockToHaddock opts (Para inlines) =
109 -- TODO: if it contains linebreaks, we need to use a @...@ block
109 -- TODO: if it contains linebreaks, we need to use a @...@ block
110 (<> blankline) `fmap` blockToHaddock opts (Plain inlines)
110 (<> blankline) `fmap` blockToHaddock opts (Plain inlines)
111+blockToHaddock opts (LineBlock lns) =
112+ blockToHaddock opts $ linesToPara lns
111blockToHaddock _ (RawBlock f str)
113blockToHaddock _ (RawBlock f str)
112 | f == "haddock" = do
114 | f == "haddock" = do
113 return $ text str <> text "\n"
115 return $ text str <> text "\n"
src/Text/Pandoc/Writers/ICML.hs+4−2
@@ -2,7 +2,7 @@
2
2
3{- |
3{- |
4 Module : Text.Pandoc.Writers.ICML
4 Module : Text.Pandoc.Writers.ICML
5− Copyright : Copyright (C) 2013 github.com/mb21
5+ Copyright : Copyright (C) 2013-2016 github.com/mb21
6 License : GNU GPL, version 2 or above
6 License : GNU GPL, version 2 or above
7
7
8 Stability : alpha
8 Stability : alpha
@@ -18,7 +18,7 @@ import Text.Pandoc.Definition
18import Text.Pandoc.XML
18import Text.Pandoc.XML
19import Text.Pandoc.Readers.TeXMath (texMathToInlines)
19import Text.Pandoc.Readers.TeXMath (texMathToInlines)
20import Text.Pandoc.Writers.Shared
20import Text.Pandoc.Writers.Shared
21−import Text.Pandoc.Shared (splitBy, fetchItem, warn)
21+import Text.Pandoc.Shared (linesToPara, splitBy, fetchItem, warn)
22import Text.Pandoc.Options
22import Text.Pandoc.Options
23import Text.Pandoc.Templates (renderTemplate')
23import Text.Pandoc.Templates (renderTemplate')
24import Text.Pandoc.Pretty
24import Text.Pandoc.Pretty
@@ -297,6 +297,8 @@ blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do
297 caption <- parStyle opts (imgCaptionName:style) txt
297 caption <- parStyle opts (imgCaptionName:style) txt
298 return $ intersperseBrs [figure, caption]
298 return $ intersperseBrs [figure, caption]
299blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
299blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
300+blockToICML opts style (LineBlock lns) =
301+ blockToICML opts style $ linesToPara lns
300blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
302blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
301blockToICML _ _ (RawBlock f str)
303blockToICML _ _ (RawBlock f str)
302 | f == Format "icml" = return $ text str
304 | 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
437 else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."]
437 else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."]
438blockToLaTeX (Para lst) =
438blockToLaTeX (Para lst) =
439 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
439 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
440+blockToLaTeX (LineBlock lns) = do
441+ blockToLaTeX $ linesToPara lns
440blockToLaTeX (BlockQuote lst) = do
442blockToLaTeX (BlockQuote lst) = do
441 beamer <- writerBeamer `fmap` gets stOptions
443 beamer <- writerBeamer `fmap` gets stOptions
442 case lst of
444 case lst of
src/Text/Pandoc/Writers/Man.hs+2−1
@@ -171,6 +171,8 @@ blockToMan opts (Para inlines) = do
171 contents <- liftM vcat $ mapM (inlineListToMan opts) $
171 contents <- liftM vcat $ mapM (inlineListToMan opts) $
172 splitSentences inlines
172 splitSentences inlines
173 return $ text ".PP" $$ contents
173 return $ text ".PP" $$ contents
174+blockToMan opts (LineBlock lns) =
175+ blockToMan opts $ linesToPara lns
174blockToMan _ (RawBlock f str)
176blockToMan _ (RawBlock f str)
175 | f == Format "man" = return $ text str
177 | f == Format "man" = return $ text str
176 | otherwise = return empty
178 | otherwise = return empty
@@ -367,4 +369,3 @@ inlineToMan _ (Note contents) = do
367 notes <- liftM stNotes get
369 notes <- liftM stNotes get
368 let ref = show $ (length notes)
370 let ref = show $ (length notes)
369 return $ char '[' <> text ref <> char ']'
371 return $ char '[' <> text ref <> char ']'
370−
src/Text/Pandoc/Writers/Markdown.hs+7−1
@@ -79,7 +79,7 @@ instance Default WriterEnv
79 , envRefShortcutable = True
79 , envRefShortcutable = True
80 , envBlockLevel = 0
80 , envBlockLevel = 0
81 }
81 }
82−
82+
83data WriterState = WriterState { stNotes :: Notes
83data WriterState = WriterState { stNotes :: Notes
84 , stRefs :: Refs
84 , stRefs :: Refs
85 , stIds :: Set.Set String
85 , stIds :: Set.Set String
@@ -390,6 +390,12 @@ blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
390 blockToMarkdown opts (Para [Image attr alt (src,tit)])
390 blockToMarkdown opts (Para [Image attr alt (src,tit)])
391blockToMarkdown' opts (Para inlines) =
391blockToMarkdown' opts (Para inlines) =
392 (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
392 (<> 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
393blockToMarkdown' opts (RawBlock f str)
399blockToMarkdown' opts (RawBlock f str)
394 | f == "markdown" = return $ text str <> text "\n"
400 | f == "markdown" = return $ text str <> text "\n"
395 | f == "html" && isEnabled Ext_raw_html opts = do
401 | f == "html" && isEnabled Ext_raw_html opts = do
src/Text/Pandoc/Writers/MediaWiki.hs+3
@@ -120,6 +120,9 @@ blockToMediaWiki (Para inlines) = do
120 then "<p>" ++ contents ++ "</p>"
120 then "<p>" ++ contents ++ "</p>"
121 else contents ++ if null lev then "\n" else ""
121 else contents ++ if null lev then "\n" else ""
122
122
123+blockToMediaWiki (LineBlock lns) =
124+ blockToMediaWiki $ linesToPara lns
125+
123blockToMediaWiki (RawBlock f str)
126blockToMediaWiki (RawBlock f str)
124 | f == Format "mediawiki" = return str
127 | f == Format "mediawiki" = return str
125 | f == Format "html" = return str
128 | f == Format "html" = return str
src/Text/Pandoc/Writers/Native.hs+2
@@ -45,6 +45,8 @@ prettyList ds =
45
45
46-- | Prettyprint Pandoc block element.
46-- | Prettyprint Pandoc block element.
47prettyBlock :: Block -> Doc
47prettyBlock :: Block -> Doc
48+prettyBlock (LineBlock lines') =
49+ "LineBlock" $$ prettyList (map (text . show) lines')
48prettyBlock (BlockQuote blocks) =
50prettyBlock (BlockQuote blocks) =
49 "BlockQuote" $$ prettyList (map prettyBlock blocks)
51 "BlockQuote" $$ prettyList (map prettyBlock blocks)
50prettyBlock (OrderedList attribs blockLists) =
52prettyBlock (OrderedList attribs blockLists) =
src/Text/Pandoc/Writers/OpenDocument.hs+2
@@ -33,6 +33,7 @@ module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where
33import Text.Pandoc.Definition
33import Text.Pandoc.Definition
34import Text.Pandoc.Options
34import Text.Pandoc.Options
35import Text.Pandoc.XML
35import Text.Pandoc.XML
36+import Text.Pandoc.Shared (linesToPara)
36import Text.Pandoc.Templates (renderTemplate')
37import Text.Pandoc.Templates (renderTemplate')
37import Text.Pandoc.Readers.TeXMath
38import Text.Pandoc.Readers.TeXMath
38import Text.Pandoc.Pretty
39import Text.Pandoc.Pretty
@@ -291,6 +292,7 @@ blockToOpenDocument o bs
291 | Para b <- bs = if null b
292 | Para b <- bs = if null b
292 then return empty
293 then return empty
293 else inParagraphTags =<< inlinesToOpenDocument o b
294 else inParagraphTags =<< inlinesToOpenDocument o b
295+ | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
294 | Div _ xs <- bs = blocksToOpenDocument o xs
296 | Div _ xs <- bs = blocksToOpenDocument o xs
295 | Header i _ b <- bs = setFirstPara >>
297 | Header i _ b <- bs = setFirstPara >>
296 (inHeaderTags i =<< inlinesToOpenDocument o b)
298 (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
164blockToOrg (Para inlines) = do
164blockToOrg (Para inlines) = do
165 contents <- inlineListToOrg inlines
165 contents <- inlineListToOrg inlines
166 return $ contents <> blankline
166 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
167blockToOrg (RawBlock "html" str) =
178blockToOrg (RawBlock "html" str) =
168 return $ blankline $$ "#+BEGIN_HTML" $$
179 return $ blankline $$ "#+BEGIN_HTML" $$
169 nest 2 (text str) $$ "#+END_HTML" $$ blankline
180 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
201 return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline
201 return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline
202blockToRST (Para inlines)
202blockToRST (Para inlines)
203 | LineBreak `elem` inlines = do -- use line block if LineBreaks
203 | LineBreak `elem` inlines = do -- use line block if LineBreaks
204− lns <- mapM inlineListToRST $ splitBy (==LineBreak) inlines
204+ linesToLineBlock $ splitBy (==LineBreak) inlines
205− return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline
206 | otherwise = do
205 | otherwise = do
207 contents <- inlineListToRST inlines
206 contents <- inlineListToRST inlines
208 return $ contents <> blankline
207 return $ contents <> blankline
208+blockToRST (LineBlock lns) =
209+ linesToLineBlock lns
209blockToRST (RawBlock f@(Format f') str)
210blockToRST (RawBlock f@(Format f') str)
210 | f == "rst" = return $ text str
211 | f == "rst" = return $ text str
211 | otherwise = return $ blankline <> ".. raw:: " <>
212 | otherwise = return $ blankline <> ".. raw:: " <>
@@ -328,6 +329,12 @@ definitionListItemToRST (label, defs) = do
328 tabstop <- get >>= (return . writerTabStop . stOptions)
329 tabstop <- get >>= (return . writerTabStop . stOptions)
329 return $ label' $$ nest tabstop (nestle contents <> cr)
330 return $ label' $$ nest tabstop (nestle contents <> cr)
330
331
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+
331-- | Convert list of Pandoc block elements to RST.
338-- | Convert list of Pandoc block elements to RST.
332blockListToRST' :: Bool
339blockListToRST' :: Bool
333 -> [Block] -- ^ List of block elements
340 -> [Block] -- ^ List of block elements
src/Text/Pandoc/Writers/RTF.hs+2
@@ -233,6 +233,8 @@ blockToRTF indent alignment (Plain lst) =
233 rtfCompact indent 0 alignment $ inlineListToRTF lst
233 rtfCompact indent 0 alignment $ inlineListToRTF lst
234blockToRTF indent alignment (Para lst) =
234blockToRTF indent alignment (Para lst) =
235 rtfPar indent 0 alignment $ inlineListToRTF lst
235 rtfPar indent 0 alignment $ inlineListToRTF lst
236+blockToRTF indent alignment (LineBlock lns) =
237+ blockToRTF indent alignment $ linesToPara lns
236blockToRTF indent alignment (BlockQuote lst) =
238blockToRTF indent alignment (BlockQuote lst) =
237 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
239 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
238blockToRTF indent _ (CodeBlock _ str) =
240blockToRTF indent _ (CodeBlock _ str) =
src/Text/Pandoc/Writers/TEI.hs+8−7
@@ -108,7 +108,7 @@ plainToPara :: Block -> Block
108plainToPara (Plain x) = Para x
108plainToPara (Plain x) = Para x
109plainToPara x = x
109plainToPara x = x
110
110
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
112-- list with labels and items.
112-- list with labels and items.
113deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc
113deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc
114deflistItemsToTEI opts items =
114deflistItemsToTEI opts items =
@@ -167,6 +167,8 @@ blockToTEI opts (Plain lst) = blockToTEI opts $ Para lst
167-- inTagsSimple "textobject" (inTagsSimple "phrase" alt))
167-- inTagsSimple "textobject" (inTagsSimple "phrase" alt))
168blockToTEI opts (Para lst) =
168blockToTEI opts (Para lst) =
169 inTags False "p" [] $ inlinesToTEI opts lst
169 inTags False "p" [] $ inlinesToTEI opts lst
170+blockToTEI opts (LineBlock lns) =
171+ blockToTEI opts $ linesToPara lns
170blockToTEI opts (BlockQuote blocks) =
172blockToTEI opts (BlockQuote blocks) =
171 inTagsIndented "quote" $ blocksToTEI opts blocks
173 inTagsIndented "quote" $ blocksToTEI opts blocks
172blockToTEI _ (CodeBlock (_,classes,_) str) =
174blockToTEI _ (CodeBlock (_,classes,_) str) =
@@ -174,7 +176,7 @@ blockToTEI _ (CodeBlock (_,classes,_) str) =
174 flush (text (escapeStringForXML str) <> cr <> text "</ab>")
176 flush (text (escapeStringForXML str) <> cr <> text "</ab>")
175 where lang = if null langs
177 where lang = if null langs
176 then ""
178 then ""
177− else escapeStringForXML (head langs)
179+ else escapeStringForXML (head langs)
178 isLang l = map toLower l `elem` map (map toLower) languages
180 isLang l = map toLower l `elem` map (map toLower) languages
179 langsFrom s = if isLang s
181 langsFrom s = if isLang s
180 then [s]
182 then [s]
@@ -210,7 +212,7 @@ blockToTEI _ HorizontalRule =
210 selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")]
212 selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")]
211
213
212-- | TEI Tables
214-- | 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
214-- table info in the AST is here lossily discard.
216-- table info in the AST is here lossily discard.
215blockToTEI opts (Table _ _ _ headers rows) =
217blockToTEI opts (Table _ _ _ headers rows) =
216 let
218 let
@@ -219,8 +221,8 @@ blockToTEI opts (Table _ _ _ headers rows) =
219-- then return empty
221-- then return empty
220-- else tableRowToTEI opts headers
222-- else tableRowToTEI opts headers
221 in
223 in
222− inTags True "table" [] $
224+ inTags True "table" [] $
223− vcat $ [headers'] <> map (tableRowToTEI opts) rows
225+ vcat $ [headers'] <> map (tableRowToTEI opts) rows
224
226
225tableRowToTEI :: WriterOptions
227tableRowToTEI :: WriterOptions
226 -> [[Block]]
228 -> [[Block]]
@@ -276,7 +278,7 @@ inlineToTEI _ (Math t str) =
276 text (str)
278 text (str)
277 DisplayMath -> inTags True "figure" [("type","math")] $
279 DisplayMath -> inTags True "figure" [("type","math")] $
278 inTags False "formula" [("notation","TeX")] $ text (str)
280 inTags False "formula" [("notation","TeX")] $ text (str)
279−
281+
280inlineToTEI _ (RawInline f x) | f == "tei" = text x
282inlineToTEI _ (RawInline f x) | f == "tei" = text x
281 | otherwise = empty
283 | otherwise = empty
282inlineToTEI _ LineBreak = selfClosingTag "lb" []
284inlineToTEI _ LineBreak = selfClosingTag "lb" []
@@ -317,4 +319,3 @@ idAndRole (id',cls,_) = ident ++ role
317 role = if null cls
319 role = if null cls
318 then []
320 then []
319 else [("role", unwords cls)]
321 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
145blockToTexinfo (Para lst) =
145blockToTexinfo (Para lst) =
146 inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo
146 inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo
147
147
148+blockToTexinfo (LineBlock lns) =
149+ blockToTexinfo $ linesToPara lns
150+
148blockToTexinfo (BlockQuote lst) = do
151blockToTexinfo (BlockQuote lst) = do
149 contents <- blockListToTexinfo lst
152 contents <- blockListToTexinfo lst
150 return $ text "@quotation" $$
153 return $ text "@quotation" $$
src/Text/Pandoc/Writers/Textile.hs+3
@@ -130,6 +130,9 @@ blockToTextile opts (Para inlines) = do
130 then "<p>" ++ contents ++ "</p>"
130 then "<p>" ++ contents ++ "</p>"
131 else contents ++ if null listLevel then "\n" else ""
131 else contents ++ if null listLevel then "\n" else ""
132
132
133+blockToTextile opts (LineBlock lns) =
134+ blockToTextile opts $ linesToPara lns
135+
133blockToTextile _ (RawBlock f str)
136blockToTextile _ (RawBlock f str)
134 | f == Format "html" || f == Format "textile" = return str
137 | f == Format "html" || f == Format "textile" = return str
135 | otherwise = return ""
138 | otherwise = return ""
src/Text/Pandoc/Writers/ZimWiki.hs+5−1
@@ -33,7 +33,8 @@ http://zim-wiki.org/manual/Help/Wiki_Syntax.html
33module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
33module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
34import Text.Pandoc.Definition
34import Text.Pandoc.Definition
35import Text.Pandoc.Options ( WriterOptions(writerTableOfContents, writerStandalone, writerTemplate, writerWrapText), WrapOption(..) )
35import 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 )
37import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
38import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
38import Text.Pandoc.ImageSize
39import Text.Pandoc.ImageSize
39import Text.Pandoc.Templates ( renderTemplate' )
40import Text.Pandoc.Templates ( renderTemplate' )
@@ -111,6 +112,9 @@ blockToZimWiki opts (Para inlines) = do
111 contents <- inlineListToZimWiki opts inlines
112 contents <- inlineListToZimWiki opts inlines
112 return $ contents ++ if null indent then "\n" else ""
113 return $ contents ++ if null indent then "\n" else ""
113
114
115+blockToZimWiki opts (LineBlock lns) = do
116+ blockToZimWiki opts $ linesToPara lns
117+
114blockToZimWiki opts (RawBlock f str)
118blockToZimWiki opts (RawBlock f str)
115 | f == Format "zimwiki" = return str
119 | f == Format "zimwiki" = return str
116 | f == Format "html" = do cont <- indentFromHTML opts str; return cont
120 | f == Format "html" = do cont <- indentFromHTML opts str; return cont
tests/Tests/Readers/Org.hs+7−10
@@ -1490,14 +1490,11 @@ tests =
1490 mconcat
1490 mconcat
1491 [ para $ spcSep [ "The", "first", "lines", "of"
1491 [ para $ spcSep [ "The", "first", "lines", "of"
1492 , "Goethe's", emph "Faust" <> ":"]
1492 , "Goethe's", emph "Faust" <> ":"]
1493− , para $ mconcat
1493+ , lineBlock
1494− [ spcSep [ "Habe", "nun,", "ach!", "Philosophie," ]
1494+ [ "Habe nun, ach! Philosophie,"
1495− , linebreak
1496− , spcSep [ "Juristerei", "und", "Medizin," ]
1495+ , "Juristerei und Medizin,"
1497− , linebreak
1498− , spcSep [ "Und", "leider", "auch", "Theologie!" ]
1496+ , "Und leider auch Theologie!"
1499− , linebreak
1500− , spcSep [ "Durchaus", "studiert,", "mit", "heißem", "Bemühn." ]
1497+ , "Durchaus studiert, mit heißem Bemühn."
1501 ]
1498 ]
1502 ]
1499 ]
1503
1500
@@ -1508,7 +1505,7 @@ tests =
1508 , "bar"
1505 , "bar"
1509 , "#+END_VERSE"
1506 , "#+END_VERSE"
1510 ] =?>
1507 ] =?>
1511− para ("foo" <> linebreak <> linebreak <> "bar")
1508+ lineBlock [ "foo", mempty, "bar" ]
1512
1509
1513 , "Verse block with varying indentation" =:
1510 , "Verse block with varying indentation" =:
1514 unlines [ "#+BEGIN_VERSE"
1511 unlines [ "#+BEGIN_VERSE"
@@ -1516,7 +1513,7 @@ tests =
1516 , "my old friend"
1513 , "my old friend"
1517 , "#+END_VERSE"
1514 , "#+END_VERSE"
1518 ] =?>
1515 ] =?>
1519− para ("\160\160hello darkness" <> linebreak <> "my old friend")
1516+ lineBlock [ "\160\160hello darkness", "my old friend" ]
1520
1517
1521 , "Raw block LaTeX" =:
1518 , "Raw block LaTeX" =:
1522 unlines [ "#+BEGIN_LaTeX"
1519 unlines [ "#+BEGIN_LaTeX"
tests/Tests/Readers/RST.hs+2−3
@@ -19,8 +19,7 @@ infix 4 =:
19
19
20tests :: [Test]
20tests :: [Test]
21tests = [ "line block with blank line" =:
21tests = [ "line block with blank line" =:
22− "| a\n|\n| b" =?> para (str "a") <>
22+ "| a\n|\n| b" =?> lineBlock [ "a", mempty, "\160b" ]
23− para (str "\160b")
24 , testGroup "field list"
23 , testGroup "field list"
25 [ "general" =: unlines
24 [ "general" =: unlines
26 [ "para"
25 [ "para"
@@ -135,7 +134,7 @@ tests = [ "line block with blank line" =:
135 codeBlock "block quotes\n\ncan go on for many lines" <>
134 codeBlock "block quotes\n\ncan go on for many lines" <>
136 para "but must stop here")
135 para "but must stop here")
137 , "line block with 3 lines" =: "| a\n| b\n| c"
136 , "line block with 3 lines" =: "| a\n| b\n| c"
138− =?> para ("a" <> linebreak <> "b" <> linebreak <> "c")
137+ =?> lineBlock ["a", "b", "c"]
139 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
138 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
140 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
139 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
141 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
140 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
tests/markdown-reader-more.native+8−2
@@ -84,8 +84,14 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",S
84,BlockQuote
84,BlockQuote
85 [Header 2 ("foobar",["baz"],[("key","val")]) [Str "Header",Space,Str "attributes",Space,Str "inside",Space,Str "block",Space,Str "quote"]]
85 [Header 2 ("foobar",["baz"],[("key","val")]) [Str "Header",Space,Str "attributes",Space,Str "inside",Space,Str "block",Space,Str "quote"]]
86,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
86,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
87+,LineBlock
88+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]
89+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]
87−,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
90+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]
91+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
92+ ,[]
88−,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]
93+ ,[Str "Continuation",Space,Str "line"]
94+ ,[Str "\160\160and",Space,Str "another"]]
89,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"]
95,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"]
90,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
96,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
91 [[Plain [Str "col",Space,Str "1"]]
97 [[Plain [Str "col",Space,Str "1"]]
tests/rst-reader.native+8−2
@@ -230,8 +230,14 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
230,Para [Str "Another",Space,Str "paragraph"]
230,Para [Str "Another",Space,Str "paragraph"]
231,Para [Str "A",Space,Str "third",Space,Str "paragraph"]
231,Para [Str "A",Space,Str "third",Space,Str "paragraph"]
232,Header 1 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
232,Header 1 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
233+,LineBlock
234+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]
235+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]
233−,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
236+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]
237+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
238+ ,[]
234−,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]
239+ ,[Str "Continuation",Space,Str "line"]
240+ ,[Str "\160\160and",Space,Str "another"]]
235,Header 1 ("simple-tables",[],[]) [Str "Simple",Space,Str "Tables"]
241,Header 1 ("simple-tables",[],[]) [Str "Simple",Space,Str "Tables"]
236,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
242,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
237 [[Plain [Str "col",Space,Str "1"]]
243 [[Plain [Str "col",Space,Str "1"]]