From 4f2eac88aa1cd26d096a88450ad3ae929980e7a6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 19 Nov 2021 09:05:19 -0800 Subject: MediaWiki writer: fix code for generating spans for header IDs. We need to generate a span when the header's ID doesn't match the one MediaWiki would generate automatically. But MediaWiki's generation scheme is different from ours (it uses uppercase letters, and `_` instead of `-`, for example). This means that in going from markdown -> mediawiki, we'll now get spans before almost every heading, unless explicit identifiers are used that correspond to the ones MediaWiki auto-generates. This is uglier output but it's necessary for internal links to work properly. See #7697. --- test/command/7697.md | 4 ++-- test/writer.mediawiki | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/command/7697.md b/test/command/7697.md index 28e865c82..eb9c823d0 100644 --- a/test/command/7697.md +++ b/test/command/7697.md @@ -21,7 +21,7 @@ ref to top of this section: [[#refsubpage1|refsubpage1]]. ``` ``` % pandoc -f markdown -t mediawiki -# Heading {#heading} +# My Heading {#My_Heading} ^D -= Heading = += My Heading = ``` diff --git a/test/writer.mediawiki b/test/writer.mediawiki index 79cc1b4e1..23cb78e60 100644 --- a/test/writer.mediawiki +++ b/test/writer.mediawiki @@ -3,24 +3,33 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s ----- + = Headers = + == Level 2 with an [[url|embedded link]] == + === Level 3 with ''emphasis'' === + ==== Level 4 ==== + ===== Level 5 ===== + = Level 1 = + == Level 2 with ''emphasis'' == + === Level 3 === with no blank line + == Level 2 == with no blank line @@ -28,6 +37,7 @@ with no blank line ----- + = Paragraphs = Here’s a regular paragraph. @@ -42,6 +52,7 @@ here. ----- + = Block Quotes = E-mail style: @@ -71,6 +82,7 @@ And a following paragraph. ----- + = Code Blocks = Code: @@ -90,8 +102,10 @@ These should not be escaped: \$ \\ \> \[ \{ ----- + = Lists = + == Unordered == Asterisks tight: @@ -130,6 +144,7 @@ Minuses loose: * Minus 2 * Minus 3 + == Ordered == Tight: @@ -164,6 +179,7 @@ Multiple paragraphs:
  • Item 2.

  • Item 3.

  • + == Nested == * Tab @@ -188,6 +204,7 @@ Same thing but with paragraphs: #* Foe # Third + == Tabs and spaces == * this is a list item indented with tabs @@ -195,6 +212,7 @@ Same thing but with paragraphs: ** this is an example list item indented with tabs ** this is an example list item indented with spaces + == Fancy list markers ==
      @@ -239,6 +257,7 @@ B. Williams ----- + = Definition Lists = Tight using spaces: @@ -307,6 +326,7 @@ Blank line after term, indented marker, alternate markers: ;# sublist ;# sublist + = HTML Blocks = Simple block on one line: @@ -416,6 +436,7 @@ Hr’s: ----- + = Inline Markup = This is ''emphasized'', and so ''is this''. @@ -445,6 +466,7 @@ These should not be superscripts or subscripts, because of the unescaped spaces: ----- + = Smart quotes, ellipses, dashes = “Hello,” said the spider. “‘Shelob’ is my name.” @@ -466,6 +488,7 @@ Ellipses…and…and…. ----- + = LaTeX = * @@ -490,6 +513,7 @@ Here’s a LaTeX table: ----- + = Special Characters = Here is some unicode: @@ -545,8 +569,10 @@ Minus: - ----- + = Links = + == Explicit == Just a [[url/|URL]]. @@ -567,6 +593,7 @@ Just a [[url/|URL]]. [[|Empty]]. + == Reference == Foo [[url/|bar]]. @@ -588,6 +615,7 @@ Foo [[url/|bar]]. Foo [[url/|biz]]. + == With ampersands == Here’s a [http://example.com/?foo=1&bar=2 link with an ampersand in the URL]. @@ -598,6 +626,7 @@ Here’s an [[script?foo=1&bar=2|inline link]]. Here’s an [[script?foo=1&bar=2|inline link in pointy braces]]. + == Autolinks == With an ampersand: http://example.com/?foo=1&bar=2 @@ -616,6 +645,7 @@ Auto-links should not occur here: <http://example.com/> ----- + = Images = From “Voyage dans la Lune” by Georges Melies (1902): @@ -627,6 +657,7 @@ Here is a movie [[File:movie.jpg|movie]] icon. ----- + = Footnotes = Here is a footnote reference,Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document. and another.Here’s the long note. This one contains multiple blocks. -- cgit v1.2.3