aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-05-28 13:58:44 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-05-28 13:58:44 -0700
commitb6b2331fdcee37f1bfb3fcc21816d73d6d56cfae (patch)
treeb4bd568a3ecd22039fd8df9853c2d3b0bc52ae10
parente72d2dd962f2c3073eb4b7a461c3c717f6a61e1a (diff)
downloadpandoc-b6b2331fdcee37f1bfb3fcc21816d73d6d56cfae.tar.gz
Support `rebase_relative_paths` for commonmark based formats.
(Including `gfm`.)
-rw-r--r--src/Text/Pandoc/Extensions.hs1
-rw-r--r--src/Text/Pandoc/Readers/CommonMark.hs4
-rw-r--r--test/command/3752.md16
3 files changed, 20 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs
index c4d54c06e..9c55d0a7a 100644
--- a/src/Text/Pandoc/Extensions.hs
+++ b/src/Text/Pandoc/Extensions.hs
@@ -517,6 +517,7 @@ getAllExtensions f = universalExtensions <> getAll f
, Ext_attributes
, Ext_sourcepos
, Ext_yaml_metadata_block
+ , Ext_rebase_relative_paths
]
getAll "commonmark_x" = getAll "commonmark"
getAll "org" = autoIdExtensions <>
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
index b099a9b50..228e65312 100644
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -112,5 +112,7 @@ specFor opts = foldr ($) defaultSyntaxSpec exts
| isEnabled Ext_implicit_header_references opts ] ++
[ (footnoteSpec <>) | isEnabled Ext_footnotes opts ] ++
[ (definitionListSpec <>) | isEnabled Ext_definition_lists opts ] ++
- [ (taskListSpec <>) | isEnabled Ext_task_lists opts ]
+ [ (taskListSpec <>) | isEnabled Ext_task_lists opts ] ++
+ [ (rebaseRelativePathsSpec <>)
+ | isEnabled Ext_rebase_relative_paths opts ]
diff --git a/test/command/3752.md b/test/command/3752.md
index df8af0ba1..2e96b531e 100644
--- a/test/command/3752.md
+++ b/test/command/3752.md
@@ -42,3 +42,19 @@ A spider: [spider]
<h1 id="chapter-two">Chapter two</h1>
<p>A spider: <img src="command/chap2/spider.png" alt="spider" /></p>
```
+
+```
+% pandoc command/chap1/text.md command/chap2/text.md -f commonmark+rebase_relative_paths -t html
+^D
+<h1>Chapter one</h1>
+<p>A spider: <img src="command/chap1/spider.png" alt="spider" /></p>
+<p>Another spider: <img src="command/chap2/spider.png" alt="another 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>
+<p>Link to fragment: <a href="#chapter-two">chapter two</a>.</p>
+<p>Empty path: <a href="">empty</a>.</p>
+<h1>Chapter two</h1>
+<p>A spider: <img src="command/chap2/spider.png" alt="spider" /></p>
+```