git.iko.soy/typeable/pandoc
on master help sign in
RST reader: Consolidated rawBlock into directive.
commitb07ea7a02d94de042003a2287e5f5216a41e4e4e authorJohn MacFarlane <jgm@berkeley.edu> dateSun 30 Sep 2012, 09:59 (14 years ago) parente5740a1
2 files changed+4−18
src/Text/Pandoc/Readers/RST.hs+1−15 tests/rst-reader.native+3−3
src/Text/Pandoc/Readers/RST.hs+1−15
@@ -132,7 +132,6 @@ parseBlocks = mconcat <$> manyTill block eof
132132
133133block :: RSTParser Blocks
134134block = choice [ codeBlock
135− , rawBlock
136135 , blockQuote
137136 , fieldList
138137 , directive
@@ -353,18 +352,6 @@ lhsCodeBlock = try $ do
353352birdTrackLine :: Parser [Char] st [Char]
354353birdTrackLine = char '>' >> manyTill anyChar newline
355354
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−
368355--
369356-- block quotes
370357--
@@ -501,10 +488,8 @@ directive = try $ do
501488 directive'
502489
503490-- TODO: line-block, parsed-literal, table, csv-table, list-table
504−-- replace, unicode
505491-- date
506492-- include
507−-- raw (consolidate)
508493-- class
509494-- title
510495directive' :: RSTParser Blocks
@@ -523,6 +508,7 @@ directive' = do
523508 optional blanklines
524509 let body' = body ++ "\n\n"
525510 case label of
511+ "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
526512 "container" -> parseFromString parseBlocks body'
527513 "replace" -> B.para <$> -- consumed by substKey
528514 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 ":
175175 [[Para [Str "123-4567"]]])]
176176,Header 1 [Str "HTML",Space,Str "Blocks"]
177177,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>"
179179,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>"
181181,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}"
183183,Header 1 [Str "Inline",Space,Str "Markup"]
184184,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
185185,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 "."]