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
This commit is contained in:
fiddlosopher 2007-10-11 05:50:28 +00:00
parent 175ddc3f6e
commit ad9603231f
3 changed files with 13 additions and 14 deletions

4
debian/changelog vendored
View file

@ -27,6 +27,10 @@ pandoc (0.45) unstable; urgency=low
* Markdown reader: Require space before title in links and references.
This fixes a bug in parsing URLs like http://silly/url(withparen).
* RST reader: Fixed bug in parsing of code blocks. Previously a
full tab indent was required, but RST allows code to be indented
any amount. Resolves Issue #27.
* HTML writer: Don't produce HTML for table of contents if there are
no headers. (This would be an empty list, which is invalid XHTML.)

View file

@ -281,15 +281,11 @@ indentedLine indents = try $ do
return $ result ++ "\n"
-- two or more indented lines, possibly separated by blank lines.
-- if variable = True, then any indent will work, but it must be
-- consistent through the block.
-- if variable = False, indent should be one tab or equivalent in spaces.
indentedBlock variable = try $ do
-- any amount of indentation will work.
indentedBlock = try $ do
state <- getState
let tabStop = stateTabStop state
indents <- if variable
then many1 (oneOf " \t")
else oneOfStrings ["\t", (replicate tabStop ' ')]
indents <- many1 (oneOf " \t")
firstline <- manyTill anyChar newline
rest <- many (choice [ indentedLine indents,
try (do b <- blanklines
@ -300,8 +296,7 @@ indentedBlock variable = try $ do
codeBlock = try $ do
codeBlockStart
result <- indentedBlock False
-- the False means we want one tab stop indent on each line
result <- indentedBlock
return $ CodeBlock $ stripTrailingNewlines result
--
@ -309,7 +304,7 @@ codeBlock = try $ do
--
rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >>
indentedBlock True >>= return . RawHtml
indentedBlock >>= return . RawHtml
--
-- raw latex
@ -318,7 +313,7 @@ rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >>
rawLaTeXBlock = try $ do
string ".. raw:: latex"
blanklines
result <- indentedBlock True
result <- indentedBlock
return $ Para [(TeX result)]
--
@ -326,7 +321,7 @@ rawLaTeXBlock = try $ do
--
blockQuote = do
raw <- indentedBlock True
raw <- indentedBlock
-- parse the extracted block, which may contain various block elements:
contents <- parseFromString parseBlocks $ raw ++ "\n\n"
return $ BlockQuote contents
@ -339,7 +334,7 @@ list = choice [ bulletList, orderedList, definitionList ] <?> "list"
definitionListItem = try $ do
term <- many1Till inline endline
raw <- indentedBlock True
raw <- indentedBlock
-- parse the extracted block, which may contain various block elements:
contents <- parseFromString parseBlocks $ raw ++ "\n\n"
return (normalizeSpaces term, contents)

View file

@ -41,7 +41,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str
, CodeBlock "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}"
, CodeBlock "this code block is indented by one tab"
, Para [Str "And",Str ":"]
, CodeBlock " this block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
, CodeBlock "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
, Header 1 [Str "Lists"]
, Header 2 [Str "Unordered"]
, Para [Str "Asterisks",Space,Str "tight",Str ":"]