git.iko.soy/typeable/pandoc
on master help sign in
RST reader: support start-line and end-line in include.

Just skip other options for now.

commit223dff4d2927a90c62fc657a473020314e11a0f4 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 4 Dec 2016, 22:55 (10 years ago) parentad3ff34
1 file changed+8−2
src/Text/Pandoc/Readers/RST.hs+8−2
src/Text/Pandoc/Readers/RST.hs+8−2
@@ -434,7 +434,10 @@ include = try $ do
434434 string ".. include::"
435435 skipMany spaceChar
436436 f <- trim <$> anyLine
437− -- TODO options
437+ fields <- many $ rawFieldListItem 3
438+ -- options
439+ let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
440+ let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
438441 guard $ not (null f)
439442 oldPos <- getPosition
440443 oldInput <- getInput
@@ -448,8 +451,11 @@ include = try $ do
448451 Left _e -> do
449452 lift $ warning $ "Could not read include file " ++ f ++ "."
450453 return ""
454+ let contents' = unlines $ maybe id (drop . (\x -> x - 1)) startLine
455+ $ maybe id (take . (\x -> x - 1)) endLine
456+ $ lines contents
451457 setPosition $ newPos f 1 1
452− setInput contents
458+ setInput contents'
453459 bs <- optional blanklines >> (mconcat <$> many block)
454460 setInput oldInput
455461 setPosition oldPos