diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-05-27 14:16:37 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-05-27 14:16:37 -0700 |
commit | 4b16d181e7219ed161a0e03c0c5ee9dec4b526b4 (patch) | |
tree | 8230559cd15e0966fb29de92798259a41393b0bf | |
parent | 0661ce699fe83c64dd5a5874e8ab17241b19550c (diff) | |
download | pandoc-4b16d181e7219ed161a0e03c0c5ee9dec4b526b4.tar.gz |
rebase_relative_paths: leave empty paths unchanged.
-rw-r--r-- | MANUAL.txt | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 2 | ||||
-rw-r--r-- | test/command/3752.md | 3 | ||||
-rw-r--r-- | test/command/chap1/text.md | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index fb1a76e9a..c234debc9 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -5081,8 +5081,8 @@ Without this extension, you would have to use `![image](chap2/spider.jpg)` in `chap2/text.md`. Links with relative paths will be rewritten in the same way as images. -Absolute paths and URLs are not changed. Neither are paths -consisting entirely of a fragment, e.g. `[section one](#foo)`. +Absolute paths and URLs are not changed. Neither are empty +paths or paths consisting entirely of a fragment, e.g., `#foo`. Note that relative paths in reference links and images will be rewritten relative to the file containing the link diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 74f2668e4..bc5e3e30f 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1924,7 +1924,7 @@ rebasePath :: SourcePos -> Text -> Text rebasePath pos path = do let fp = sourceName pos isFragment = T.take 1 path == "#" - in if isFragment || isAbsolute (T.unpack path) || isURI path + in if T.null path || isFragment || isAbsolute (T.unpack path) || isURI path then path else case takeDirectory fp of diff --git a/test/command/3752.md b/test/command/3752.md index 2765d79ac..df8af0ba1 100644 --- a/test/command/3752.md +++ b/test/command/3752.md @@ -20,6 +20,8 @@ Absolute path left alone: absolute. Link to fragment: chapter two. +Empty path: empty. + Chapter two A spider: [spider] @@ -36,6 +38,7 @@ A spider: [spider] <p>URL left alone: <a href="https://pandoc.org/MANUAL.html">manual</a>.</p> <p>Absolute path left alone: <a href="/foo/bar/baz.png">absolute</a>.</p> <p>Link to fragment: <a href="#chapter-two">chapter two</a>.</p> +<p>Empty path: <a href="">empty</a>.</p> <h1 id="chapter-two">Chapter two</h1> <p>A spider: <img src="command/chap2/spider.png" alt="spider" /></p> ``` diff --git a/test/command/chap1/text.md b/test/command/chap1/text.md index 68a317161..54f0104de 100644 --- a/test/command/chap1/text.md +++ b/test/command/chap1/text.md @@ -13,3 +13,5 @@ URL left alone: [manual](https://pandoc.org/MANUAL.html). Absolute path left alone: [absolute](/foo/bar/baz.png). Link to fragment: [chapter two](#chapter-two). + +Empty path: [empty](). |