summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/RST.hs
diff options
context:
space:
mode:
authorAndrew Dunning <adunning@users.noreply.github.com>2017-09-08 07:06:50 +0100
committerGitHub <noreply@github.com>2017-09-08 07:06:50 +0100
commit51bb7453e41e5e7e28a60cb22cb4f4d082b7fbdf (patch)
treebbcd5f299fa513065e3bcb3f274f1b895a899301 /src/Text/Pandoc/Readers/RST.hs
parent3654c4373a2f4db8d4ab771937ad318a6921ac37 (diff)
parent732005456e2b28150943a5a4e11bca6e1566f309 (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'src/Text/Pandoc/Readers/RST.hs')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs18
1 files changed, 9 insertions, 9 deletions
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'