@@ -39,7 +39,7 @@ import Text.Pandoc.Options
39import Text.Pandoc.Error
39import Text.Pandoc.Error
40import qualified Text.Pandoc.UTF8 as UTF8
40import qualified Text.Pandoc.UTF8 as UTF8
41import Control.Monad ( when, liftM, guard, mzero )
41import Control.Monad ( when, liftM, guard, mzero )
42−import Data.List ( findIndex, intercalate,
42+import Data.List ( findIndex, intercalate, isInfixOf,
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
44import Data.Maybe (fromMaybe, isJust)
44import Data.Maybe (fromMaybe, isJust)
45import qualified Data.Map as M
45import qualified Data.Map as M
@@ -405,8 +405,6 @@ blockQuote = do
405Unsupported options for include:
405Unsupported options for include:
408−start-after: text to find
409−end-before: text to find
412include :: PandocMonad m => RSTParser m Blocks
410include :: PandocMonad m => RSTParser m Blocks
@@ -441,9 +439,17 @@ include = try $ do
441 Nothing -> numLines + 1
439 Nothing -> numLines + 1
442 Just x | x >= 0 -> x
440 Just x | x >= 0 -> x
443 | otherwise -> numLines + x -- negative from end
441 | otherwise -> numLines + x -- negative from end
444− let contents' = unlines $ drop (startLine' - 1)
442+ let contentLines' = drop (startLine' - 1)
445− $ take (endLine' - 1)
443+ $ take (endLine' - 1)
445+ let contentLines'' = (case trim <$> lookup "end-before" fields of
446+ Just patt -> takeWhile (not . (patt `isInfixOf`))
448+ (case trim <$> lookup "start-after" fields of
449+ Just patt -> drop 1 .
450+ dropWhile (not . (patt `isInfixOf`))
446− $ contentLines
451+ Nothing -> id) $ contentLines'
452+ let contents' = unlines contentLines''
447 case lookup "code" fields of
453 case lookup "code" fields of
448 Just lang -> do
454 Just lang -> do
449 let numberLines = lookup "number-lines" fields
455 let numberLines = lookup "number-lines" fields