diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-05-24 10:17:37 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-05-27 10:38:25 -0700 |
commit | 834da53058069fe50da510fa86e0807a7ff7868f (patch) | |
tree | 791cdc1a5a2e459efac2b68a97285e2a5e737b70 /test | |
parent | 0226d2320f5a57475ec260b9d0ad3ad4260ecf38 (diff) | |
download | pandoc-834da53058069fe50da510fa86e0807a7ff7868f.tar.gz |
Add `rebase_relative_paths` extension.
- Add manual entry for (non-default) extension
`rebase_relative_paths`.
- Add constructor `Ext_rebase_relative_paths` to `Extensions`
in Text.Pandoc.Extensions [API change]. When enabled, this
extension rewrites relative image and link paths by prepending
the (relative) directory of the containing file.
- Make Markdown reader sensitive to the new extension.
- Add tests for #3752.
Closes #3752.
NB. currently the extension applies to markdown and associated
readers but not commonmark/gfm.
Diffstat (limited to 'test')
-rw-r--r-- | test/command/3752.md | 35 | ||||
-rw-r--r-- | test/command/chap1/spider.png | bin | 0 -> 63531 bytes | |||
-rw-r--r-- | test/command/chap1/text.md | 11 | ||||
-rw-r--r-- | test/command/chap2/spider.png | bin | 0 -> 9861 bytes | |||
-rw-r--r-- | test/command/chap2/text.md | 3 |
5 files changed, 49 insertions, 0 deletions
diff --git a/test/command/3752.md b/test/command/3752.md new file mode 100644 index 000000000..76d51989b --- /dev/null +++ b/test/command/3752.md @@ -0,0 +1,35 @@ +``` +% pandoc command/chap1/text.md command/chap2/text.md -f markdown+rebase_relative_paths --verbose -t docx | pandoc -f docx -t plain +^D +[INFO] Loaded command/chap1/spider.png from ./command/chap1/spider.png +[INFO] Loaded command/chap1/../../lalune.jpg from ./command/chap1/../../lalune.jpg +[INFO] Loaded command/chap2/spider.png from ./command/chap2/spider.png +Chapter one + +A spider: [spider] + +The moon: [moon] + +Link to spider picture. + +URL left alone: manual. + +Absolute path left alone: absolute. + +Chapter two + +A spider: [spider] +``` + +``` +% pandoc command/chap1/text.md command/chap2/text.md -f markdown+rebase_relative_paths -t html +^D +<h1 id="chapter-one">Chapter one</h1> +<p>A spider: <img src="command/chap1/spider.png" alt="spider" /></p> +<p>The moon: <img src="command/chap1/../../lalune.jpg" alt="moon" /></p> +<p>Link to <a href="command/chap1/spider.png">spider picture</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> +<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/spider.png b/test/command/chap1/spider.png Binary files differnew file mode 100644 index 000000000..7ee9fe339 --- /dev/null +++ b/test/command/chap1/spider.png diff --git a/test/command/chap1/text.md b/test/command/chap1/text.md new file mode 100644 index 000000000..88b30313d --- /dev/null +++ b/test/command/chap1/text.md @@ -0,0 +1,11 @@ +# Chapter one + +A spider: ![spider](spider.png) + +The moon: ![moon](../../lalune.jpg) + +Link to [spider picture](spider.png). + +URL left alone: [manual](https://pandoc.org/MANUAL.html). + +Absolute path left alone: [absolute](/foo/bar/baz.png). diff --git a/test/command/chap2/spider.png b/test/command/chap2/spider.png Binary files differnew file mode 100644 index 000000000..5377e940b --- /dev/null +++ b/test/command/chap2/spider.png diff --git a/test/command/chap2/text.md b/test/command/chap2/text.md new file mode 100644 index 000000000..435a266d7 --- /dev/null +++ b/test/command/chap2/text.md @@ -0,0 +1,3 @@ +# Chapter two + +A spider: ![spider](spider.png) |