]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
mdwn: Restore historical behaviour
authorSimon McVittie <smcv@debian.org>
Tue, 23 Jan 2018 09:39:05 +0000 (09:39 +0000)
committerSimon McVittie <smcv@debian.org>
Mon, 29 Jan 2018 22:35:29 +0000 (22:35 +0000)
The Discount package in Debian historically enabled fenced code blocks,
PHP Markdown Extra-style definition lists, and an expanded character
set for tag names. Since Discount 2.2.0 those are runtime settings, so
enable them. Unfortunately Text::Markdown::Discount doesn't yet expose
the necessary constants:
https://rt.cpan.org/Public/Bug/Display.html?id=124188

The IDANCHOR option was historically also enabled in Debian, but is not
enabled here because ikiwiki does not enable the TOC option, and
IDANCHOR does nothing without TOC.

Closes: #888055
CHANGELOG
IkiWiki/Plugin/mdwn.pm

index 0ffbd4579bb6b0ed8c9351d4eee5de9b5364f083..de06bcefce716591b9d4fd46bf18ff9b5cf35b72 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 ikiwiki (3.20180106) UNRELEASED; urgency=medium
 
   * core: Don't send relative redirect URLs when behind a reverse proxy
+  * mdwn: Enable fenced code blocks, PHP Markdown Extra-style definition
+    lists and GitHub-style extensions to HTML tag syntax when used with
+    Discount >= 2.2.0 (Closes: #888055)
 
  -- Simon McVittie <smcv@debian.org>  Mon, 08 Jan 2018 10:51:10 +0000
 
index 9f06c03f2ec05678e0426a723a352eab7475313c..66116ae014f7a94cd8bda230514258bbb75acf42 100644 (file)
@@ -125,6 +125,31 @@ sub htmlize (@) {
                                                $flags |= 0x00400000;
                                        }
 
+                                       # Enable fenced code blocks in libmarkdown >= 2.2.0
+                                       # https://bugs.debian.org/888055
+                                       if (Text::Markdown::Discount->can("MKD_FENCEDCODE")) {
+                                               $flags |= Text::Markdown::Discount::MKD_FENCEDCODE();
+                                       }
+                                       else {
+                                               $flags |= 0x02000000;
+                                       }
+
+                                       # PHP Markdown Extra-style term\n: definition -> <dl>
+                                       if (Text::Markdown::Discount->can("MKD_DLEXTRA")) {
+                                               $flags |= Text::Markdown::Discount::MKD_DLEXTRA();
+                                       }
+                                       else {
+                                               $flags |= 0x01000000;
+                                       }
+
+                                       # Allow dashes and underscores in tag names
+                                       if (Text::Markdown::Discount->can("MKD_GITHUBTAGS")) {
+                                               $flags |= Text::Markdown::Discount::MKD_GITHUBTAGS();
+                                       }
+                                       else {
+                                               $flags |= 0x08000000;
+                                       }
+
                                        return Text::Markdown::Discount::markdown($t, $flags);
                                }
                        }