From dab3330a585a55721821a8526a56510011a1145e Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 22 Apr 2018 12:18:45 -0700 Subject: [PATCH] RST reader: allow < 3 spaces indent under directives. Closes #4579. --- src/Text/Pandoc/Readers/RST.hs | 10 +++++++--- test/command/4579.md | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 test/command/4579.md diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 566f9b959..1577908a3 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -651,11 +651,15 @@ directive' = do skipMany spaceChar top <- many $ satisfy (/='\n') <|> try (char '\n' <* - notFollowedBy' (rawFieldListItem 3) <* - count 3 (char ' ') <* + notFollowedBy' (rawFieldListItem 1) <* + many1 (char ' ') <* notFollowedBy blankline) newline - fields <- many $ rawFieldListItem 3 + fields <- do + fieldIndent <- length <$> lookAhead (many (char ' ')) + if fieldIndent == 0 + then return [] + else many $ rawFieldListItem fieldIndent body <- option "" $ try $ blanklines >> indentedBlock optional blanklines let body' = body ++ "\n\n" diff --git a/test/command/4579.md b/test/command/4579.md new file mode 100644 index 000000000..80f0f58c2 --- /dev/null +++ b/test/command/4579.md @@ -0,0 +1,16 @@ +``` +% pandoc -f rst -t native +.. list-table:: + :header-rows: 1 + + * - Foo + - Bar + * - spam + - ham +^D +[Table [] [AlignDefault,AlignDefault] [0.0,0.0] + [[Plain [Str "Foo"]] + ,[Plain [Str "Bar"]]] + [[[Plain [Str "spam"]] + ,[Plain [Str "ham"]]]]] +```