[pmwiki-users] disabling page markup

Petko Yotov 5ko at free.fr
Thu Mar 8 05:34:10 CST 2007


On Thursday 08 March 2007 11:19, Seth Cherney wrote:
> Sandy et al.,
>
> I need to disable certain markups since:
> 1)  It is in conflict with other things on the site.
> 2)  It is causing invalid xhtml output, which is causing fatal errors in
> Saxon 3) I have about 500,000 pages equivalent of text, and when this goes
> live, it will be hard to control, so I am trying to button down the
> hatches. 4)  This is really being used as an embedded functionality on a
> site largely focused on academic search functionality - I just want to let
> people clean up the OCR and do a few other tasks, so I am really only using
> a small subset of pmwiki.
>
> These issues are related to the way the inline text markup works.  they are
> using what I think are too common characters, so that in a large corpus,
> they come up elsewhere as purely coincidental patterns (cfr '-...-' for
> small - better using ~ etc whenever possible, or not using ''...'' for
> italics, but maybe ||...||).  I  know this gets complicated, but it causes
> conflict otherwise.


Hi Seth,

All this is very easy as PmWiki is designed to be highly customizable.

This page will give you information:

http://www.pmwiki.org/wiki/PmWiki/CustomMarkup

The standard markup rules are defined in your wiki installation in the 
file "scripts/stdmarkup.php". You can see which rule does what, and to 
disable it, just do in your config.php:

DisableMarkup("''"); // disable '' for italics


To change the special markup characters, you copy the rule from stdmarkup.php 
to config.php and change it:

// Markup("''",'inline',"/''(.*?)''/",'<em>$1</em>'); // in stdmarkup.php

Markup("''",'inline',"/\\|\\|(.*?)\\|\\|/",'<em>$1</em>'); // changing to ||

The above command will replace the '' markup with || so you can write 
in ||italics||. (No need to disable it first, as you use the same entry "''".)

Note that this one is a *bad* choice as || is used for simple tables, so you 
should pick another special string.

Also note that these are regular expressions, and some characters need to be 
escaped with \\ : |[](){}.*+\/^$ as I did in my example.

More about PHP's regular expressions:
http://fr.php.net/manual/en/reference.pcre.pattern.syntax.php

>
> In terms of the invalid xhtml, it would be nice to simply disregard an
> opening tag of any sort if it does not close before a tag it should be
> nested in does, so that there would never be anything like: 
> <tag1>...<tag2>...</tag1>...</tag2>.  Thats a big no-go.
>

PmWiki usually does this one correctly, except when an editor (you) 
deliberately enters incorrect markups, as in:

   This is '''a bold text ''and some italic''' only italic''.  (will output:)
   This is <strong>a bold text <em>and some italic</strong> only italic</em>.

So, don't do it and tell your editors not to.

Good luck,

Petko



More information about the pmwiki-users mailing list