diff options
| author | John MacFarlane <[email protected]> | 2021-05-09 18:42:42 -0600 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2021-05-09 18:44:30 -0600 |
| commit | eb474bf71744502a2ff24fe2982a52ab676e427c (patch) | |
| tree | 63922b0ae493c4c8c7c56d32e3bda5cc872bcf0b | |
| parent | bad3985a4e0e2c8db376c9024b2530991b875815 (diff) | |
Org reader: Resolve org includes relative to ...sources
...the directory containing the file containing the
INCLUDE directive. Closes #5501.
| -rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 6 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Org/Parsing.hs | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 5e15c2c36..f18d2f9a7 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -40,7 +40,7 @@ import Data.List (foldl', intersperse) import Data.Maybe (fromMaybe, isJust, isNothing) import Data.Text (Text) import Data.List.NonEmpty (nonEmpty) - +import System.FilePath import qualified Data.Text as T import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.Walk as Walk @@ -528,7 +528,9 @@ include = try $ do _ -> nullAttr return $ pure . B.codeBlockWith attr <$> parseRaw _ -> return $ return . B.fromList . blockFilter params <$> blockList - insertIncludedFile blocksParser toSources ["."] filename Nothing Nothing + currentDir <- takeDirectory . sourceName <$> getPosition + insertIncludedFile blocksParser toSources + [currentDir] filename Nothing Nothing where includeTarget :: PandocMonad m => OrgParser m FilePath includeTarget = do diff --git a/src/Text/Pandoc/Readers/Org/Parsing.hs b/src/Text/Pandoc/Readers/Org/Parsing.hs index 701bf3398..f0949e205 100644 --- a/src/Text/Pandoc/Readers/Org/Parsing.hs +++ b/src/Text/Pandoc/Readers/Org/Parsing.hs @@ -99,6 +99,7 @@ module Text.Pandoc.Readers.Org.Parsing , getState , updateState , SourcePos + , sourceName , getPosition ) where |
