aboutsummaryrefslogtreecommitdiff
path: root/test/command
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-12-15 21:19:48 +0100
committerJohn MacFarlane <[email protected]>2023-01-15 10:46:55 -0800
commitca6d4bfa490349e7a4dfeee05119427a1c5ace6c (patch)
tree462ab8e861e5447cb72f68b4d186780514c90f2c /test/command
parentc71d476fa6126a6fe9095c67838e452956249df4 (diff)
Markdown, CommonMark: add support for wiki links. [API change]
Adds the Markdown/CommonMark extensions `wikilinks_title_after_pipe` and `wikilinks_title_before_pipe`. The former enables links of style `[[Name of page|Title]]` and the latter `[[Title|Name of page]]`. Titles are optional in both variants, so this works for both: `[[https://example.org]]`, `[[Name of page]]`. The writer is modified to render links with title `wikilink` as a wikilink if a respective extension is enabled. Pandoc will use `wikilinks_title_after_pipe` if both extensions are enabled. Closes: #2923
Diffstat (limited to 'test/command')
-rw-r--r--test/command/wikilinks_title_after_pipe.md73
-rw-r--r--test/command/wikilinks_title_before_pipe.md84
2 files changed, 157 insertions, 0 deletions
diff --git a/test/command/wikilinks_title_after_pipe.md b/test/command/wikilinks_title_after_pipe.md
new file mode 100644
index 000000000..201e5ee1a
--- /dev/null
+++ b/test/command/wikilinks_title_after_pipe.md
@@ -0,0 +1,73 @@
+# CommonMark
+
+## Reader
+```
+% pandoc --from commonmark_x+wikilinks_title_after_pipe -t html --columns 90
+[[https://example.org]]
+
+[[https://example.org|title]]
+
+[[name of page]]
+
+[[name of page|title]]
+^D
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="name of page" title="wikilink">name of page</a></p>
+<p><a href="name of page" title="wikilink">title</a></p>
+```
+
+## Writer
+
+```
+% pandoc -t commonmark_x+wikilinks_title_after_pipe -f html
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Home" title="wikilink">Home</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+^D
+[[https://example.org]]
+
+[[https://example.org|title]]
+
+[[Home]]
+
+[[Name%20of%20page|Title]]
+```
+
+# Markdown
+## Reader
+
+```
+% pandoc --from markdown+wikilinks_title_after_pipe -t html --columns 90
+[[https://example.org]]
+
+[[https://example.org|title]]
+
+[[name of page]]
+
+[[name of page|title]]
+^D
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="name of page" title="wikilink">name of page</a></p>
+<p><a href="name of page" title="wikilink">title</a></p>
+```
+
+## Writer
+
+```
+% pandoc -t markdown+wikilinks_title_after_pipe -f html
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Home" title="wikilink">Home</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+^D
+[[https://example.org]]
+
+[[https://example.org|title]]
+
+[[Home]]
+
+[[Name%20of%20page|Title]]
+```
diff --git a/test/command/wikilinks_title_before_pipe.md b/test/command/wikilinks_title_before_pipe.md
new file mode 100644
index 000000000..51bb009bf
--- /dev/null
+++ b/test/command/wikilinks_title_before_pipe.md
@@ -0,0 +1,84 @@
+# CommonMark
+
+## Reader
+
+```
+% pandoc -f commonmark+wikilinks_title_before_pipe -t html --columns 90
+[[https://example.org]]
+
+[[title|https://example.org]]
+
+[[Name of page]]
+
+[[Title|Name of page]]
+^D
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Name of page" title="wikilink">Name of page</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+```
+
+## Writer
+
+```
+% pandoc -t commonmark_x+wikilinks_title_before_pipe -f html
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Home" title="wikilink">Home</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+^D
+[[https://example.org]]
+
+[[title|https://example.org]]
+
+[[Home]]
+
+[[Title|Name%20of%20page]]
+```
+
+## Regular links should still work
+
+```
+% pandoc -f commonmark+wikilinks_title_before_pipe -t html
+[Title](Name%20of%20page)
+^D
+<p><a href="Name%20of%20page">Title</a></p>
+```
+
+# Markdown
+
+## Reader
+
+```
+% pandoc -f markdown+wikilinks_title_before_pipe -t html --columns 90
+[[https://example.org]]
+
+[[title|https://example.org]]
+
+[[Name of page]]
+
+[[Title|Name of page]]
+^D
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Name of page" title="wikilink">Name of page</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+```
+
+## Writer
+
+```
+% pandoc -t markdown+wikilinks_title_before_pipe -f html
+<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
+<p><a href="https://example.org" title="wikilink">title</a></p>
+<p><a href="Home" title="wikilink">Home</a></p>
+<p><a href="Name of page" title="wikilink">Title</a></p>
+^D
+[[https://example.org]]
+
+[[title|https://example.org]]
+
+[[Home]]
+
+[[Title|Name%20of%20page]]
+```