From ca6d4bfa490349e7a4dfeee05119427a1c5ace6c Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 15 Dec 2022 21:19:48 +0100 Subject: 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 --- test/command/wikilinks_title_after_pipe.md | 73 +++++++++++++++++++++++++ test/command/wikilinks_title_before_pipe.md | 84 +++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 test/command/wikilinks_title_after_pipe.md create mode 100644 test/command/wikilinks_title_before_pipe.md (limited to 'test/command') 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 +

https://example.org

+

title

+

name of page

+

title

+``` + +## Writer + +``` +% pandoc -t commonmark_x+wikilinks_title_after_pipe -f html +

https://example.org

+

title

+

Home

+

Title

+^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 +

https://example.org

+

title

+

name of page

+

title

+``` + +## Writer + +``` +% pandoc -t markdown+wikilinks_title_after_pipe -f html +

https://example.org

+

title

+

Home

+

Title

+^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 +

https://example.org

+

title

+

Name of page

+

Title

+``` + +## Writer + +``` +% pandoc -t commonmark_x+wikilinks_title_before_pipe -f html +

https://example.org

+

title

+

Home

+

Title

+^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 +

Title

+``` + +# 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 +

https://example.org

+

title

+

Name of page

+

Title

+``` + +## Writer + +``` +% pandoc -t markdown+wikilinks_title_before_pipe -f html +

https://example.org

+

title

+

Home

+

Title

+^D +[[https://example.org]] + +[[title|https://example.org]] + +[[Home]] + +[[Title|Name%20of%20page]] +``` -- cgit v1.2.3