aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-05-09 18:42:42 -0600
committerJohn MacFarlane <jgm@berkeley.edu>2021-05-09 19:11:35 -0600
commitb2398cd74744ce34fa10cc34f4051555f21feb2c (patch)
tree197dc4853fdf86e4da2a1d8855f7b24de3387c7c /src/Text/Pandoc
parentf69f1101e6689745cf5dea8276ba11d723b43ccf (diff)
downloadpandoc-b2398cd74744ce34fa10cc34f4051555f21feb2c.tar.gz
Org reader: Resolve org includes relative to ...
...the directory containing the file containing the INCLUDE directive. Closes #5501.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs6
-rw-r--r--src/Text/Pandoc/Readers/Org/Parsing.hs1
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