Recent Changes - Search:

PmWiki

pmwiki.org

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

WTF2


I'm putting this page here because I couldn't figure out how to upload to the WTF group... This is from WTF2:

This version of WTF is a total mess, but it almost-successfully roundtrips from markup to the whizzy editor and back to markup. (There are still some issues with vspaces and newlines and stuff that will take fine-tuning and I've only tested it on a sample of about 5 or 10 types of markup.)

The basic idea is that we divide all Markup rules into 1 of 2 sets: (1) those that are editable (boldface, tables, etc. - whizzy will deal with them without problems) and (2) all the rest (whizzy doesn't know how to deal with these). We build a markup rule table with all the rules from (2) but instead of doing their usual replacement we replace them with <pre class=pmwikimarkup>THE MARKUP ITSELF</pre> and then go ahead and Keep() the whole thing. With this markup table we run MarkupToHTML?() and save the result. Then we unset that markup table and create a new markup table with those in (1), but with the normal replacement this time. We run MarkupToHTML?() on the text that already had the Keep() done it above.

The resulting text has the <pre ...>...</pre> around all the non-editable sections of markup. We put this into the textbox and let whizzy do its thing.

When we save we make sure that ROEPatterns? are processed (this happens by default) and we make sure that ConvertHTML? has been installed. This recipe has a bunch of ROEPattern? rules which convert all the HTML back into markup and then it gets saved on the page.

Rather than using ?action=edit to edit via whizzy I've used ?action=whiz. This lets expert authors ?action=edit the page and continue with markup while novice authors can ?action=whiz a page and wysiwyg it.

It's not done, but here's Δ a copy... (Note that the code is about as messy as it can be, brutishly copied from everybody all over the place -- purely a prototype... no, not even a prototype, a proof-of-concept is what it is)

OOPS! Scratch that. Apparently I can't upload to this group. Neither do I know how to make a link here... Go over to WTF2 and you should find the appropriate stuff.

If it doesn't work for some reason it may be that I modified pmwiki.php or ConvertHTML?() or something -- let me know what errors you're getting... —Peter Bowers April 03, 2011, at 05:36 PM

UPDATE:

  • I now have it doing a "round-trip" pretty exactly on a minimized set of markup.
    • Supported markup:
      • Advanced tables (simple tables get converted to advanced table)
      • Bold, italics (double-single-quotes and triple-single-quotes)
      • Headers
    • Exceptions:
      • Headers with an empty line after them in source will be replaced with headers with no empty line after them.
        • Has to do with the !vspace rule -- when I disable that rule this problem goes away but all sorts of other problems appear in MarkupToHTML?()
      • Table cells will all receive the attribute valign="top" if they did not have some valign previously
  • Non-supported markup gets surrounded with the <pre ...>...</pre>.
    • Tested markup:
      • Links
      • (:pagelist ...:)
  • See Attach:wtf2.txt and Attach:convert-html2.txt
    • Place both files (renamed to php extensions) in your cookbook directory and include_once("..<yada-yada>../wtf2.php"); in your config.php

The following source will survive a perfect round-trip through the whizzywig editor and back into this exact source:

[[{$FullName}?action=whiz|whiz it!]]

!! My 2nd-level header
!! header2
!!! contiguous header3
!! continuous header2
(:table border='1':)
(:cellnr valign='top':)cell1
(:cell valign='top':)cell2
(:cellnr valign='top':)row2col1
(:cell valign='top':)cell2
(:tableend:)

(:pagelist group=Test:)

'''this is bold''' and ''this is italics''

Hello, '''this''' is a ''test''!

Just added this to a site for SandBox? testing. Remember to keep it within the markup I specified above... Use ?action=whiz to edit with whizzywig, ?action=edit to edit normally...

Here's the site.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 12:03 PM
 0: 00.00 00.00 config start
 1: 00.00 00.00 config end
 2: 00.05 00.05 MarkupToHTML begin
 3: 00.12 00.11 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 4: 00.13 00.12 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 5: 00.21 00.20 MarkupToHTML end
 6: 00.22 00.21 MarkupToHTML begin
 7: 00.25 00.24 MarkupToHTML end
 8: 00.25 00.24 MarkupToHTML begin
 9: 00.26 00.25 MarkupToHTML end
10: 00.27 00.26 now