git.iko.soy/typeable/pandoc
on master help sign in
Org reader: Resolve org includes relative to ...

...the directory containing the file containing the INCLUDE directive. Closes #5501.

commitb2398cd74744ce34fa10cc34f4051555f21feb2c authorJohn MacFarlane <jgm@berkeley.edu> dateSun 9 May 2021, 18:42 (5 years ago) parentf69f110
2 files changed+5−2
src/Text/Pandoc/Readers/Org/Blocks.hs+4−2 src/Text/Pandoc/Readers/Org/Parsing.hs+1
src/Text/Pandoc/Readers/Org/Blocks.hs+4−2
@@ -40,7 +40,7 @@ import Data.List (foldl', intersperse)
4040import Data.Maybe (fromMaybe, isJust, isNothing)
4141import Data.Text (Text)
4242import Data.List.NonEmpty (nonEmpty)
43−
43+import System.FilePath
4444import qualified Data.Text as T
4545import qualified Text.Pandoc.Builder as B
4646import qualified Text.Pandoc.Walk as Walk
@@ -528,7 +528,9 @@ include = try $ do
528528 _ -> nullAttr
529529 return $ pure . B.codeBlockWith attr <$> parseRaw
530530 _ -> return $ return . B.fromList . blockFilter params <$> blockList
531− insertIncludedFile blocksParser toSources ["."] filename Nothing Nothing
531+ currentDir <- takeDirectory . sourceName <$> getPosition
532+ insertIncludedFile blocksParser toSources
533+ [currentDir] filename Nothing Nothing
532534 where
533535 includeTarget :: PandocMonad m => OrgParser m FilePath
534536 includeTarget = do
src/Text/Pandoc/Readers/Org/Parsing.hs+1
@@ -99,6 +99,7 @@ module Text.Pandoc.Readers.Org.Parsing
9999 , getState
100100 , updateState
101101 , SourcePos
102+ , sourceName
102103 , getPosition
103104 ) where
104105