aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.cabal1
-rw-r--r--src/Text/Pandoc/Readers/RST.hs18
-rw-r--r--test/command/3880.md6
-rw-r--r--test/command/3880.txt1
4 files changed, 17 insertions, 9 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 0907ed82f..2228c7ff5 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -138,6 +138,7 @@ Extra-Source-Files:
test/*.native
test/command/*.md
test/command/3533-rst-csv-tables.csv
+ test/command/3880.txt
test/command/abbrevs
test/command/SVG_logo-without-xml-declaration.svg
test/command/SVG_logo.svg
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 190b065fb..daaeff2f0 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -219,7 +219,6 @@ block = choice [ codeBlock
, directive
, anchor
, comment
- , include
, header
, hrule
, lineBlock -- must go before definitionList
@@ -460,16 +459,16 @@ tab-width
encoding
-}
-include :: PandocMonad m => RSTParser m Blocks
-include = try $ do
- string ".. include::"
- skipMany spaceChar
- f <- trim <$> anyLine
- fields <- many $ rawFieldListItem 3
+includeDirective :: PandocMonad m
+ => String -> [(String, String)] -> String
+ -> RSTParser m Blocks
+includeDirective top fields body = do
+ let f = trim top
+ guard $ not (null f)
+ guard $ null (trim body)
-- options
let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
- guard $ not (null f)
oldPos <- getPosition
oldInput <- getInput
containers <- stateContainers <$> getState
@@ -501,7 +500,7 @@ include = try $ do
Just patt -> drop 1 .
dropWhile (not . (patt `isInfixOf`))
Nothing -> id) $ contentLines'
- let contents' = unlines contentLines''
+ let contents' = unlines contentLines'' ++ "\n"
case lookup "code" fields of
Just lang -> do
let numberLines = lookup "number-lines" fields
@@ -687,6 +686,7 @@ directive' = do
$ lookup "height" fields >>=
(lengthToDim . filter (not . isSpace))
case label of
+ "include" -> includeDirective top fields body'
"table" -> tableDirective top fields body'
"list-table" -> listTableDirective top fields body'
"csv-table" -> csvTableDirective top fields body'
diff --git a/test/command/3880.md b/test/command/3880.md
new file mode 100644
index 000000000..b8edaf08f
--- /dev/null
+++ b/test/command/3880.md
@@ -0,0 +1,6 @@
+```
+pandoc -f rst -t native
+.. include:: command/3880.txt
+^D
+[Para [Str "hi"]]
+```
diff --git a/test/command/3880.txt b/test/command/3880.txt
new file mode 100644
index 000000000..45b983be3
--- /dev/null
+++ b/test/command/3880.txt
@@ -0,0 +1 @@
+hi