rebase_relative_paths: leave empty paths unchanged.
This commit is contained in:
parent
0661ce699f
commit
4b16d181e7
4 changed files with 8 additions and 3 deletions
|
@ -5081,8 +5081,8 @@ Without this extension, you would have to use
|
||||||
`![image](chap2/spider.jpg)` in `chap2/text.md`. Links with
|
`![image](chap2/spider.jpg)` in `chap2/text.md`. Links with
|
||||||
relative paths will be rewritten in the same way as images.
|
relative paths will be rewritten in the same way as images.
|
||||||
|
|
||||||
Absolute paths and URLs are not changed. Neither are paths
|
Absolute paths and URLs are not changed. Neither are empty
|
||||||
consisting entirely of a fragment, e.g. `[section one](#foo)`.
|
paths or paths consisting entirely of a fragment, e.g., `#foo`.
|
||||||
|
|
||||||
Note that relative paths in reference links and images will
|
Note that relative paths in reference links and images will
|
||||||
be rewritten relative to the file containing the link
|
be rewritten relative to the file containing the link
|
||||||
|
|
|
@ -1924,7 +1924,7 @@ rebasePath :: SourcePos -> Text -> Text
|
||||||
rebasePath pos path = do
|
rebasePath pos path = do
|
||||||
let fp = sourceName pos
|
let fp = sourceName pos
|
||||||
isFragment = T.take 1 path == "#"
|
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
|
then path
|
||||||
else
|
else
|
||||||
case takeDirectory fp of
|
case takeDirectory fp of
|
||||||
|
|
|
@ -20,6 +20,8 @@ Absolute path left alone: absolute.
|
||||||
|
|
||||||
Link to fragment: chapter two.
|
Link to fragment: chapter two.
|
||||||
|
|
||||||
|
Empty path: empty.
|
||||||
|
|
||||||
Chapter two
|
Chapter two
|
||||||
|
|
||||||
A spider: [spider]
|
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>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>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>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>
|
<h1 id="chapter-two">Chapter two</h1>
|
||||||
<p>A spider: <img src="command/chap2/spider.png" alt="spider" /></p>
|
<p>A spider: <img src="command/chap2/spider.png" alt="spider" /></p>
|
||||||
```
|
```
|
||||||
|
|
|
@ -13,3 +13,5 @@ URL left alone: [manual](https://pandoc.org/MANUAL.html).
|
||||||
Absolute path left alone: [absolute](/foo/bar/baz.png).
|
Absolute path left alone: [absolute](/foo/bar/baz.png).
|
||||||
|
|
||||||
Link to fragment: [chapter two](#chapter-two).
|
Link to fragment: [chapter two](#chapter-two).
|
||||||
|
|
||||||
|
Empty path: [empty]().
|
||||||
|
|
Loading…
Reference in a new issue