aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-05-27 11:26:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-05-27 11:26:38 -0700
commit6972a7dc9158c1d56b2dc9a06f596386f6b30860 (patch)
tree35c18ea6d50182a62374a49cd6246b89247c003a /src/Text/Pandoc/Readers
parentcbe16b2866abd8d0e4c15f027562b4b2bed3f01e (diff)
downloadpandoc-6972a7dc9158c1d56b2dc9a06f596386f6b30860.tar.gz
Modify rebase_reference_links treatment of reference links/images.
The directory is based on the file containing the link reference, not the file containing the link, if these differ.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 968c6c165..e5cbadc94 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -336,7 +336,9 @@ referenceKey = try $ do
notFollowedBy' (() <$ reference)
many1Char $ notFollowedBy space >> litChar
let betweenAngles = try $ char '<' >> manyTillChar litChar (char '>')
- src <- try betweenAngles <|> sourceURL
+ rebase <- option False (True <$ guardEnabled Ext_rebase_relative_paths)
+ src <- (if rebase then rebasePath pos else id) <$>
+ (try betweenAngles <|> sourceURL)
tit <- option "" referenceTitle
attr <- option nullAttr $ try $
do guardEnabled Ext_link_attributes
@@ -1857,8 +1859,6 @@ referenceLink constructor (lab, raw) = do
return (mempty, "")))
<|>
try ((guardDisabled Ext_spaced_reference_links <|> spnl) >> reference)
- rebase <- option False (True <$ guardEnabled Ext_rebase_relative_paths)
- pos <- getPosition
when (raw' == "") $ guardEnabled Ext_shortcut_reference_links
let labIsRef = raw' == "" || raw' == "[]"
let key = toKey $ if labIsRef then raw else raw'
@@ -1884,8 +1884,7 @@ referenceLink constructor (lab, raw) = do
Nothing -> makeFallback
else makeFallback
Just ((src,tit), attr) ->
- let src' = if rebase then rebasePath pos src else src
- in constructor attr src' tit <$> lab
+ constructor attr src tit <$> lab
dropBrackets :: Text -> Text
dropBrackets = dropRB . dropLB