@@ -219,7 +219,6 @@ block = choice [ codeBlock
219 , directive
219 , directive
221 , comment
221 , comment
225 , lineBlock -- must go before definitionList
224 , lineBlock -- must go before definitionList
@@ -460,16 +459,16 @@ tab-width
462+includeDirective :: PandocMonad m
463+ => String -> [(String, String)] -> String
463−include :: PandocMonad m => RSTParser m Blocks
464+ -> RSTParser m Blocks
464−include = try $ do
465+includeDirective top fields body = do
465− string ".. include::"
466+ let f = trim top
466− skipMany spaceChar
467+ guard $ not (null f)
467− f <- trim <$> anyLine
468+ guard $ null (trim body)
468− fields <- many $ rawFieldListItem 3
469 -- options
469 -- options
470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
472− guard $ not (null f)
473 oldPos <- getPosition
472 oldPos <- getPosition
474 oldInput <- getInput
473 oldInput <- getInput
475 containers <- stateContainers <$> getState
474 containers <- stateContainers <$> getState
@@ -501,7 +500,7 @@ include = try $ do
501 Just patt -> drop 1 .
500 Just patt -> drop 1 .
502 dropWhile (not . (patt `isInfixOf`))
501 dropWhile (not . (patt `isInfixOf`))
503 Nothing -> id) $ contentLines'
502 Nothing -> id) $ contentLines'
504− let contents' = unlines contentLines''
503+ let contents' = unlines contentLines'' ++ "\n"
505 case lookup "code" fields of
504 case lookup "code" fields of
506 Just lang -> do
505 Just lang -> do
507 let numberLines = lookup "number-lines" fields
506 let numberLines = lookup "number-lines" fields
@@ -687,6 +686,7 @@ directive' = do
687 $ lookup "height" fields >>=
686 $ lookup "height" fields >>=
688 (lengthToDim . filter (not . isSpace))
687 (lengthToDim . filter (not . isSpace))
689 case label of
688 case label of
689+ "include" -> includeDirective top fields body'
690 "table" -> tableDirective top fields body'
690 "table" -> tableDirective top fields body'
691 "list-table" -> listTableDirective top fields body'
691 "list-table" -> listTableDirective top fields body'
692 "csv-table" -> csvTableDirective top fields body'
692 "csv-table" -> csvTableDirective top fields body'