git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in RST reader: previously, code blocks had to be

indented a full tabstop, but RST allows any amount of indentation. Resolves Issue #27. + removed 'variable' parameter from indentedBlock function in RST reader, as it is no longer needed + updated test suite + updated changelog git-svn-id: https://pandoc.googlecode.com/svn/trunk@1046 788f1e2b-df1e-0410-8736-df70ead52e1b

commitad9603231f5fec1ccfb8111c3080d61f375189b9 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 11 Oct 2007, 05:50 (19 years ago) parent175ddc3
3 files changed+13−14
debian/changelog+4 src/Text/Pandoc/Readers/RST.hs+8−13 tests/rst-reader.native+1−1
debian/changelog+4
@@ -27,6 +27,10 @@ pandoc (0.45) unstable; urgency=low
2727 * Markdown reader: Require space before title in links and references.
2828 This fixes a bug in parsing URLs like http://silly/url(withparen).
2929
30+ * RST reader: Fixed bug in parsing of code blocks. Previously a
31+ full tab indent was required, but RST allows code to be indented
32+ any amount. Resolves Issue #27.
33+
3034 * HTML writer: Don't produce HTML for table of contents if there are
3135 no headers. (This would be an empty list, which is invalid XHTML.)
3236
src/Text/Pandoc/Readers/RST.hs+8−13
@@ -281,15 +281,11 @@ indentedLine indents = try $ do
281281 return $ result ++ "\n"
282282
283283-- two or more indented lines, possibly separated by blank lines.
284−-- if variable = True, then any indent will work, but it must be
285−-- consistent through the block.
286−-- if variable = False, indent should be one tab or equivalent in spaces.
287−indentedBlock variable = try $ do
284+-- any amount of indentation will work.
285+indentedBlock = try $ do
288286 state <- getState
289287 let tabStop = stateTabStop state
290− indents <- if variable
291− then many1 (oneOf " \t")
292− else oneOfStrings ["\t", (replicate tabStop ' ')]
288+ indents <- many1 (oneOf " \t")
293289 firstline <- manyTill anyChar newline
294290 rest <- many (choice [ indentedLine indents,
295291 try (do b <- blanklines
@@ -300,8 +296,7 @@ indentedBlock variable = try $ do
300296
301297codeBlock = try $ do
302298 codeBlockStart
303− result <- indentedBlock False
304− -- the False means we want one tab stop indent on each line
299+ result <- indentedBlock
305300 return $ CodeBlock $ stripTrailingNewlines result
306301
307302--
@@ -309,7 +304,7 @@ codeBlock = try $ do
309304--
310305
311306rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >>
312− indentedBlock True >>= return . RawHtml
307+ indentedBlock >>= return . RawHtml
313308
314309--
315310-- raw latex
@@ -318,7 +313,7 @@ rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >>
318313rawLaTeXBlock = try $ do
319314 string ".. raw:: latex"
320315 blanklines
321− result <- indentedBlock True
316+ result <- indentedBlock
322317 return $ Para [(TeX result)]
323318
324319--
@@ -326,7 +321,7 @@ rawLaTeXBlock = try $ do
326321--
327322
328323blockQuote = do
329− raw <- indentedBlock True
324+ raw <- indentedBlock
330325 -- parse the extracted block, which may contain various block elements:
331326 contents <- parseFromString parseBlocks $ raw ++ "\n\n"
332327 return $ BlockQuote contents
@@ -339,7 +334,7 @@ list = choice [ bulletList, orderedList, definitionList ] <?> "list"
339334
340335definitionListItem = try $ do
341336 term <- many1Till inline endline
342− raw <- indentedBlock True
337+ raw <- indentedBlock
343338 -- parse the extracted block, which may contain various block elements:
344339 contents <- parseFromString parseBlocks $ raw ++ "\n\n"
345340 return (normalizeSpaces term, contents)
tests/rst-reader.native+1−1
@@ -41,7 +41,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
4141, CodeBlock "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}"
4242, CodeBlock "this code block is indented by one tab"
4343, Para [Str "And",Str ":"]
44−, CodeBlock " this block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
44+, CodeBlock "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
4545, Header 1 [Str "Lists"]
4646, Header 2 [Str "Unordered"]
4747, Para [Str "Asterisks",Space,Str "tight",Str ":"]