@@ -39,7 +39,7 @@ import Text.Pandoc.Options
3939import Text.Pandoc.Error
4040import qualified Text.Pandoc.UTF8 as UTF8
4141import Control.Monad ( when, liftM, guard, mzero )
42−import Data.List ( findIndex, intercalate,
42+import Data.List ( findIndex, intercalate, isInfixOf,
4343 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
4444import Data.Maybe (fromMaybe, isJust)
4545import qualified Data.Map as M
@@ -405,8 +405,6 @@ blockQuote = do
405405Unsupported options for include:
406406tab-width
407407encoding
408−start-after: text to find
409−end-before: text to find
410408-}
411409
412410include :: PandocMonad m => RSTParser m Blocks
@@ -441,9 +439,17 @@ include = try $ do
441439 Nothing -> numLines + 1
442440 Just x | x >= 0 -> x
443441 | otherwise -> numLines + x -- negative from end
444− let contents' = unlines $ drop (startLine' - 1)
445− $ take (endLine' - 1)
446− $ contentLines
442+ let contentLines' = drop (startLine' - 1)
443+ $ take (endLine' - 1)
444+ $ contentLines
445+ let contentLines'' = (case trim <$> lookup "end-before" fields of
446+ Just patt -> takeWhile (not . (patt `isInfixOf`))
447+ Nothing -> id) .
448+ (case trim <$> lookup "start-after" fields of
449+ Just patt -> drop 1 .
450+ dropWhile (not . (patt `isInfixOf`))
451+ Nothing -> id) $ contentLines'
452+ let contents' = unlines contentLines''
447453 case lookup "code" fields of
448454 Just lang -> do
449455 let numberLines = lookup "number-lines" fields