1

Let me lay out the scenario so far. I've just got to working on setting up a PMWiki install. So far, so good, right?

So I add pagetoc.php as described in PMWiki Cookbook for Pagetoc. Next, I wanted to add Markdown support. So a Google search brought me to the Cookbook for Markdown. It also indicated MarkdownMarkupExtension Cookbook as something to check out. Both are installed. I'm not sure if it's conflicting with both, but nothing seems to be throwing up... aside from the below error.

Pagetoc.php works just fine. What doesn't is markdown.php. The error that's generated is as follows:

ERROR: pat=/\(:markdown:\)(.*?)[ ]?\(:markdownend:\)/se preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

Now... here's the relevant code in markdown.php.

Obviously, the fix is to use preg_replace_callback() function. I'm looking at this and it looks like a mass of noodles to me. I'm not sure what the right step forward is in order to resolve this issue. I'm not familiar enough with PHP to be able to use the function as suggested.

<?php if (!defined('PmWiki')) exit();
#
# Markdown  -  
#
# Copyright (c) 2006 Benjamin C. Wilson
# <http://www.dausha.net/Markdown/Recipe>
#

#$EnableMarkdownInline = 0;

include_once("$FarmC/pagetoc.php");
include_once("$FarmD/scripts/diag.php");
SDV($EnableMarkdown,0); # Off by default.
SDV($MarkdownSectionLevel, '!!'); # Creates <h2> for === sections.
SDV($MarkdownSubSectionLevel, '!!!'); # Creates <h3> for --- sections.
SDV($MarkdownSubSubSectionLevel, '!!!!'); # Creates <h4> for --- sections.
if ($EnableMarkdown) {
    $EnableStdMarkup = 0; # Turn off PmWiki's markup behavior.
    SDV($MarkdownTabWidth, 4);
    SDV($MarkdownTabLessOne, $MarkdownTabWidth - 1);
    SDV($EnableMarkdownInline, 1);
    SDV($EnableMarkdownLinks, 1);
    SDV($EnableMarkdownBlock, 1);
    SDV($EnableMarkdownPrecode, 1);
    SDV($EnableMarkdownLists, 1);
    SDV($EnableMarkdownBlockquotes, 1);
    include_once("markdown/pmwiki-directives.php");
    include_once("markdown/pmwiki-links.php");
    include_once("markdown/pmwiki-advtables.php");
    include_once("markdown/pmwiki-block.php");
    include_once("markdown/pmwiki-inline.php"); # Added 2006-05-07 BCWI
    $HTMLVSpace = '';
}
if ($EnableMarkdownInline) include_once("markdown/markdown-inline.php");
if ($EnableMarkdownLinks)  include_once("markdown/markdown-links.php");
if ($EnableMarkdownBlock)  include_once("markdown/markdown-block.php");
if ($EnableMarkdownPrecode)  include_once("markdown/markdown-precode.php");
if ($EnableMarkdownLists)  include_once("markdown/markdown-lists-0.2.php");
if ($EnableMarkdownBlockquotes)  include_once("markdown/markdown-blockquotes.php");

/*
#Markup("prebullet", "<bullet", "/^(\s+)\\*\s/e", "deindent('$1','*');");
#Markup("preordered", "<orderedlists", "/^(\s+)(\\#|[0-9]+\.)\s/e", "deindent('$1','#');");
function deindent($stuff,$type) {
    $level = (int) strlen($stuff) / 3;
    return str_pad('',$level,$type);
}
## bullet lists
Markup('bullets','block','/^(\\*+)\\s?(\\s*)/','<:ul,$1,$0>$2');
Markup('orderedlists','<bullets','/^(#+)\\s?(\\s*)/','<:ol,$1,$0>$2');
*/
Keiro
  • 125
  • 1
  • 1
  • 12

2 Answers2

2

Have a read of PmWiki / CustomMarkup which describes the Markup_e() function, which wraps up most of the work for you. You need to find the instances of regular expressions with /e at the end, ideally already in calls to Markup(), and edit them as so:

Before:

Markup('mkatxheading','<preordered', '/(#{1,6})\s*(\w.*?)#+/e', "MarkdownAtxHeading('$1','$2');");

After:

Markup_e('mkatxheading','<preordered', '/(#{1,6})\s*(\w.*?)#+/', "MarkdownAtxHeading(\$m[1],\$m[2]);");

Note that the recipe you're using is quite old (May 2006) so there may be further issues. Be sure to contribute the fixes back to the recipe page too.

Maxim Zhao
  • 51
  • 3
0

These recipes seem quite old and haven't been patched to be PHP55 compliant (as stated on pmwiki.org).

If you don't feel comfortable at patching yourself the recipe code, the PmWiki Users mailing list is usually the best place to reach recipe authors and ask them advices.

Dfaure
  • 564
  • 7
  • 26