@@ -2,6 +2,7 @@
2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4 Copyright (C) 2018 Yan Pashkovsky <yanp.bugz@gmail.com>
4 Copyright (C) 2018 Yan Pashkovsky <yanp.bugz@gmail.com>
6This program is free software; you can redistribute it and/or modify
7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8it under the terms of the GNU General Public License as published by
@@ -37,6 +38,7 @@ module Text.Pandoc.Readers.Man (readMan) where
37import Prelude
38import Prelude
38import Control.Monad (liftM, void, mzero, guard)
39import Control.Monad (liftM, void, mzero, guard)
39import Control.Monad.Except (throwError)
40import Control.Monad.Except (throwError)
41+import Text.Pandoc.Class (getResourcePath, readFileFromDirs)
40import Data.Char (isHexDigit, chr, ord)
42import Data.Char (isHexDigit, chr, ord)
41import Data.Default (Default)
43import Data.Default (Default)
42import Data.Maybe (catMaybes)
44import Data.Maybe (catMaybes)
@@ -278,10 +280,25 @@ lexMacro = do
278 "\\#" -> return mempty
280 "\\#" -> return mempty
279 "de" -> lexMacroDef args
281 "de" -> lexMacroDef args
280 "sp" -> return $ singleTok MEmptyLine
282 "sp" -> return $ singleTok MEmptyLine
283+ "so" -> lexIncludeFile args
281 _ -> resolveMacro macroName args
284 _ -> resolveMacro macroName args
288+ lexIncludeFile :: PandocMonad m => [Arg] -> ManLexer m ManTokens
289+ lexIncludeFile args = do
293+ let fp = linePartsToString f
294+ dirs <- getResourcePath
295+ result <- readFileFromDirs dirs fp
297+ Nothing -> report $ CouldNotLoadIncludeFile fp pos
298+ Just s -> getInput >>= setInput . (s ++)
285 resolveMacro :: PandocMonad m
302 resolveMacro :: PandocMonad m
286 => String -> [Arg] -> ManLexer m ManTokens
303 => String -> [Arg] -> ManLexer m ManTokens
287 resolveMacro macroName args = do
304 resolveMacro macroName args = do