@@ -219,7 +219,6 @@ block = choice [ codeBlock
219219 , directive
220220 , anchor
221221 , comment
222− , include
223222 , header
224223 , hrule
225224 , lineBlock -- must go before definitionList
@@ -460,16 +459,16 @@ tab-width
460459encoding
461460-}
462461
463−include :: PandocMonad m => RSTParser m Blocks
464−include = try $ do
465− string ".. include::"
466− skipMany spaceChar
467− f <- trim <$> anyLine
468− fields <- many $ rawFieldListItem 3
462+includeDirective :: PandocMonad m
463+ => String -> [(String, String)] -> String
464+ -> RSTParser m Blocks
465+includeDirective top fields body = do
466+ let f = trim top
467+ guard $ not (null f)
468+ guard $ null (trim body)
469469 -- options
470470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
471471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
472− guard $ not (null f)
473472 oldPos <- getPosition
474473 oldInput <- getInput
475474 containers <- stateContainers <$> getState
@@ -501,7 +500,7 @@ include = try $ do
501500 Just patt -> drop 1 .
502501 dropWhile (not . (patt `isInfixOf`))
503502 Nothing -> id) $ contentLines'
504− let contents' = unlines contentLines''
503+ let contents' = unlines contentLines'' ++ "\n"
505504 case lookup "code" fields of
506505 Just lang -> do
507506 let numberLines = lookup "number-lines" fields
@@ -687,6 +686,7 @@ directive' = do
687686 $ lookup "height" fields >>=
688687 (lengthToDim . filter (not . isSpace))
689688 case label of
689+ "include" -> includeDirective top fields body'
690690 "table" -> tableDirective top fields body'
691691 "list-table" -> listTableDirective top fields body'
692692 "csv-table" -> csvTableDirective top fields body'