@@ -405,28 +405,25 @@ blockQuote = do
405405From RST docs:
406406The following options are recognized:
407407
408−start-line : integer
409−Only the content starting from this line will be included. (As usual in Python, the first line has index 0 and negative values count from the end.)
410−end-line : integer
411−Only the content up to (but excluding) this line will be included.
412−start-after : text to find in the external data file
413−Only the content after the first occurrence of the specified text will be included.
414−end-before : text to find in the external data file
415−Only the content before the first occurrence of the specified text (but after any after text) will be included.
416−literal : flag (empty)
417−The entire included text is inserted into the document as a single literal block.
418−code : formal language (optional)
419−The argument and the content of the included file are passed to the code directive (useful for program listings). (New in Docutils 0.9)
420−number-lines : [start line number]
421−Precede every code line with a line number. The optional argument is the number of the first line (defaut 1). Works only with code or literal. (New in Docutils 0.9)
422−encoding : name of text encoding
408+[x] start-line : integer
409+[x] end-line : integer
410+[ ] start-after : text to find in the external data file
411+ Only the content after the first occurrence of the specified text will be included.
412+[ ] end-before : text to find in the external data file
413+ Only the content before the first occurrence of the specified text (but after any after text) will be included.
414+ Combining start/end-line and start-after/end-before is possible. The text markers will be searched in the specified lines (further limiting the included content).
415+[ ] literal : flag (empty)
416+ The entire included text is inserted into the document as a single literal block.
417+[ ] code : formal language (optional)
418+ The argument and the content of the included file are passed to the code directive (useful for program listings). (New in Docutils 0.9)
419+[ ] number-lines : [start line number]
420+ Precede every code line with a line number. The optional argument is the number of the first line (defaut 1). Works only with code or literal. (New in Docutils 0.9)
421+[ ] encoding : name of text encoding
423422The text encoding of the external data file. Defaults to the document's input_encoding.
424−tab-width : integer
423+[ ] tab-width : integer
425424Number of spaces for hard tab expansion. A negative value prevents expansion of hard tabs. Defaults to the tab_width configuration setting.
426−With code or literal the common options :class: and :name: are recognized as well.
427−
428−Combining start/end-line and start-after/end-before is possible. The text markers will be searched in the specified lines (further limiting the included content).
429−
425+[ ] class (common option) - with code or literal
426+[ ] name (common option) - with code or literal
430427-}
431428
432429include :: PandocMonad m => RSTParser m Blocks
@@ -451,9 +448,19 @@ include = try $ do
451448 Left _e -> do
452449 lift $ warning $ "Could not read include file " ++ f ++ "."
453450 return ""
454− let contents' = unlines $ maybe id (drop . (\x -> x - 1)) startLine
455− $ maybe id (take . (\x -> x - 1)) endLine
456− $ lines contents
451+ let contentLines = lines contents
452+ let numLines = length contentLines
453+ let startLine' = case startLine of
454+ Nothing -> 1
455+ Just x | x >= 0 -> x
456+ | otherwise -> numLines + x -- negative from end
457+ let endLine' = case endLine of
458+ Nothing -> numLines + 1
459+ Just x | x >= 0 -> x
460+ | otherwise -> numLines + x -- negative from end
461+ let contents' = unlines $ drop (startLine' - 1)
462+ $ take (endLine' - 1)
463+ $ contentLines
457464 setPosition $ newPos f 1 1
458465 setInput contents'
459466 bs <- optional blanklines >> (mconcat <$> many block)