@@ -41,7 +41,7 @@ import qualified Text.Pandoc.UTF8 as UTF8
41import Control.Monad ( when, liftM, guard, mzero )
41import Control.Monad ( when, liftM, guard, mzero )
42import Data.List ( findIndex, intercalate,
42import Data.List ( findIndex, intercalate,
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
43 transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
44−import Data.Maybe (fromMaybe)
44+import Data.Maybe (fromMaybe, isJust)
45import qualified Data.Map as M
45import qualified Data.Map as M
46import Text.Printf ( printf )
46import Text.Printf ( printf )
47import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
47import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
@@ -402,28 +402,11 @@ blockQuote = do
402 return $ B.blockQuote contents
402 return $ B.blockQuote contents
405−From RST docs:
405+Unsupported options for include:
406−The following options are recognized:
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
422−The text encoding of the external data file. Defaults to the document's input_encoding.
423−[ ] tab-width : integer
406+tab-width
424−Number of spaces for hard tab expansion. A negative value prevents expansion of hard tabs. Defaults to the tab_width configuration setting.
407+encoding
425−[ ] class (common option) - with code or literal
408+start-after: text to find
426−[ ] name (common option) - with code or literal
409+end-before: text to find
429include :: PandocMonad m => RSTParser m Blocks
412include :: PandocMonad m => RSTParser m Blocks
@@ -461,13 +444,27 @@ include = try $ do
461 let contents' = unlines $ drop (startLine' - 1)
444 let contents' = unlines $ drop (startLine' - 1)
462 $ take (endLine' - 1)
445 $ take (endLine' - 1)
463 $ contentLines
446 $ contentLines
447+ case lookup "code" fields of
449+ let numberLines = lookup "number-lines" fields
450+ let classes = trimr lang : ["numberLines" | isJust numberLines] ++
451+ maybe [] words (lookup "class" fields)
452+ let kvs = maybe [] (\n -> [("startFrom", trimr n)]) numberLines
453+ let ident = maybe "" trimr $ lookup "name" fields
454+ let attribs = (ident, classes, kvs)
455+ return $ B.codeBlockWith attribs contents'
456+ Nothing -> case lookup "literal" fields of
457+ Just _ -> return $ B.rawBlock "rst" contents'
464− setPosition $ newPos f 1 1
459+ setPosition $ newPos f 1 1
465− setInput contents'
460+ setInput contents'
466− bs <- optional blanklines >> (mconcat <$> many block)
461+ bs <- optional blanklines >>
462+ (mconcat <$> many block)
467− setInput oldInput
463+ setInput oldInput
468− setPosition oldPos
464+ setPosition oldPos
469− updateState $ \s -> s{ stateContainers = tail $ stateContainers s }
465+ updateState $ \s -> s{ stateContainers =
466+ tail $ stateContainers s }
470− return bs
467+ return bs
472readFileLazy' :: PandocMonad m => FilePath -> m (Either PandocError String)
469readFileLazy' :: PandocMonad m => FilePath -> m (Either PandocError String)
473readFileLazy' f = catchError ((Right . UTF8.toStringLazy) <$> readFileLazy f) $
470readFileLazy' f = catchError ((Right . UTF8.toStringLazy) <$> readFileLazy f) $