[pmwiki-users] Pre-alpha rich text WYSIWTF editor

Peter Bowers pbowers at pobox.com
Tue Mar 29 12:26:31 CDT 2011

On Tue, Mar 29, 2011 at 3:04 PM, Petko Yotov <5ko at 5ko.fr> wrote:
> It is exactly the opposite: there are just too many possibilities in wiki
> markup that produce HTML that can never be reverted back to its source wiki
> markup. For example dynamic PageLists, WikiTrails, PageVariables, Includes,
> picture galleries... :-)

Ah, yes, of course...

> The only way I can think of combinig the strength of the PmWiki markups and
> the ease of use for newcomers is to only RichEdit sections of the page that
> will not contain any wiki markup. But yes, in this case, it would be possible
> to convert the HTML of the section to wiki markup. :-)

What would happen if you tapped into the list of markup rules and got
rid of (i.e., "HTMLKeep()" them) all markup that wasn't round-trip
formatable.  So any formatting that WTF handles (bold, italics,
tables, bullets, etc.) would be removed from the array of rules.  The
remaining rules would be processed to remove them from MarkupToHTML()
consideration until the very last step, thus leaving the markup in
place that WTF can't handle.

This isn't coming out very clearly.  Maybe some pseudo-code would help:

function HTMLKeep($arg)
  Keep the text in a special name-space

function HTMLUnKeep()
  Replace all Keep's in that special name-space with your special
<pre>block</pre> syntax or whatever

Before MarkupToHTML() run a function like this:

function ProtectMarkup($text)
   global $MarkupRules; // I haven't looked up how this is stored,
bear with the pseudo-code
   global $UnprotectedRules; // this will hold a list of any rules
that you *want* to be used prior to WTF editing to make HTML
   foreach ($MarkupRules as $rulename->$pat) {
      if (!in_array($rulename, $UnprotectedRules))
         $text = preg_replace($pat.'e',
   return $text;

Then at the very end (when converting the HTML back to markup) as the
final step in HTMLToMarkup() (from ConvertHTML recipe?) you would just
get rid of the <markup_pre>...</markup_pre> leaving only what was in

The idea is to store pure markup and still allow people to
?action=edit a page if they know markup.  If they don't know markup
then they could ?action=wysiwtf the page and they would see any
non-translatable markup using the same pre-blocks you have now.  The
advantage is theoretically "expert" users and "novice" users could
both comfortably edit the same page...

I've obviously glossed over some of the difficulties in the
pseudo-code, but as a concept does it seem to work?


More information about the pmwiki-users mailing list