git.iko.soy/typeable/pandoc
on master help sign in
RST reader: Consolidated rawBlock into directive.
b07ea7aJohn MacFarlane
src/Text/Pandoc/Readers/RST.hs+1−15
@@ -132,7 +132,6 @@ parseBlocks = mconcat <$> manyTill block eof
132
132
133block :: RSTParser Blocks
133block :: RSTParser Blocks
134block = choice [ codeBlock
134block = choice [ codeBlock
135− , rawBlock
136 , blockQuote
135 , blockQuote
137 , fieldList
136 , fieldList
138 , directive
137 , directive
@@ -353,18 +352,6 @@ lhsCodeBlock = try $ do
353birdTrackLine :: Parser [Char] st [Char]
352birdTrackLine :: Parser [Char] st [Char]
354birdTrackLine = char '>' >> manyTill anyChar newline
353birdTrackLine = char '>' >> manyTill anyChar newline
355
354
356−--
357−-- raw html/latex/etc
358−--
359−
360−rawBlock :: Parser [Char] st Blocks
361−rawBlock = try $ do
362− string ".. raw:: "
363− lang <- many1 (letter <|> digit)
364− blanklines
365− result <- indentedBlock
366− return $ B.rawBlock lang result
367−
368--
355--
369-- block quotes
356-- block quotes
370--
357--
@@ -501,10 +488,8 @@ directive = try $ do
501 directive'
488 directive'
502
489
503-- TODO: line-block, parsed-literal, table, csv-table, list-table
490-- TODO: line-block, parsed-literal, table, csv-table, list-table
504−-- replace, unicode
505-- date
491-- date
506-- include
492-- include
507−-- raw (consolidate)
508-- class
493-- class
509-- title
494-- title
510directive' :: RSTParser Blocks
495directive' :: RSTParser Blocks
@@ -523,6 +508,7 @@ directive' = do
523 optional blanklines
508 optional blanklines
524 let body' = body ++ "\n\n"
509 let body' = body ++ "\n\n"
525 case label of
510 case label of
511+ "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
526 "container" -> parseFromString parseBlocks body'
512 "container" -> parseFromString parseBlocks body'
527 "replace" -> B.para <$> -- consumed by substKey
513 "replace" -> B.para <$> -- consumed by substKey
528 parseFromString (trimInlines . mconcat <$> many inline)
514 parseFromString (trimInlines . mconcat <$> many inline)
tests/rst-reader.native+3−3
@@ -175,11 +175,11 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
175 [[Para [Str "123-4567"]]])]
175 [[Para [Str "123-4567"]]])]
176,Header 1 [Str "HTML",Space,Str "Blocks"]
176,Header 1 [Str "HTML",Space,Str "Blocks"]
177,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
177,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
178−,RawBlock "html" "<div>foo</div>\n"
178+,RawBlock "html" "<div>foo</div>"
179,Para [Str "Now,",Space,Str "nested:"]
179,Para [Str "Now,",Space,Str "nested:"]
180−,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>\n"
180+,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>"
181,Header 1 [Str "LaTeX",Space,Str "Block"]
181,Header 1 [Str "LaTeX",Space,Str "Block"]
182−,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}\n"
182+,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
183,Header 1 [Str "Inline",Space,Str "Markup"]
183,Header 1 [Str "Inline",Space,Str "Markup"]
184,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
184,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
185,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
185,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]