aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-12-04 22:55:57 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:40 +0100
commit223dff4d2927a90c62fc657a473020314e11a0f4 (patch)
tree403e752894a9518241f7f8c9584de44430d2efb5
parentad3ff342dd48e3c0699dd179250bfc049b2c22e9 (diff)
downloadpandoc-223dff4d2927a90c62fc657a473020314e11a0f4.tar.gz
RST reader: support start-line and end-line in include.
Just skip other options for now.
-rw-r--r--src/Text/Pandoc/Readers/RST.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 9b94cbdd7..571d1b75f 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -434,7 +434,10 @@ include = try $ do
string ".. include::"
skipMany spaceChar
f <- trim <$> anyLine
- -- TODO options
+ fields <- many $ rawFieldListItem 3
+ -- options
+ let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
+ let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
guard $ not (null f)
oldPos <- getPosition
oldInput <- getInput
@@ -448,8 +451,11 @@ include = try $ do
Left _e -> do
lift $ warning $ "Could not read include file " ++ f ++ "."
return ""
+ let contents' = unlines $ maybe id (drop . (\x -> x - 1)) startLine
+ $ maybe id (take . (\x -> x - 1)) endLine
+ $ lines contents
setPosition $ newPos f 1 1
- setInput contents
+ setInput contents'
bs <- optional blanklines >> (mconcat <$> many block)
setInput oldInput
setPosition oldPos