diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-05-27 11:26:38 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-05-27 11:26:38 -0700 |
commit | 6972a7dc9158c1d56b2dc9a06f596386f6b30860 (patch) | |
tree | 35c18ea6d50182a62374a49cd6246b89247c003a /src | |
parent | cbe16b2866abd8d0e4c15f027562b4b2bed3f01e (diff) | |
download | pandoc-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')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 |
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 |