Simplewiki  1.1
Simplewiki Markup Parser and HTML generator.
SimpleWiki is a wiki markup parser and HTML emitter. Go to website.

Version
1.1
Date
October 22, 2012
Software roots:
Modelled after creole.py and creole2html.py at http://wiki.sheep.art.pl/Wiki%20Creole%20Parser%20in%20Python
  • author of creole.py and creole2html.py: Radomir Dopieralski
  • many of the regular expressions were based on creole.py
The notions for decorator and block declaration markup were derived in part from the wikistyle and directive markup developed for PmWiki (pmwiki.org) by its author, Patrick Michaud.
Two steps:
  1. build document tree (parser)
  2. use document tree to generate html (emitter)
Creole markup:
creole markup is used for basic markup, generally based on
http://www.wikicreole.org/wiki/Creole1.0
http://www.wikicreole.org/wiki/CheatSheet
http://www.wikicreole.org/wiki/CreoleAdditions
extensions and modifications to creole:
  • raw url is minimally recognized separately from link for performance reasons
  • table markup requires closing (trailing righmost) "|"
  • link format => [[url or SymbolicLink:Selector, or #anchor
    | caption (default = url or SymbolicLink)
    | title]]
  • target anchor written as [[#anchor]]
  • image format =>
    {{url or SymbolicLink:Selector
    | caption (default = url or SymbolicLink)
    | title}}
  • symbolic links can be registered by client software
  • link and image captions are parsed
  • heading text is parsed
  • macros can be registered by client software
  • no link to wikipage [[WikiPage]], use symbolic links instead, or register rawlink handler
  • no alternate link syntax
  • no monospace, use inline span decoration instead (%s mono%...%%)
  • for indented paragraphs, use dl markup (:), or blockquote or dl block declarations or instead
  • no plugin extension per se, though class methods, symlinks, events, and macros can be registered by client software
  • superscipts, subscripts, underline, overline, and strikeout are provided with span decorator
Markup extensions:
Arguments can be associated with most document objects through decorators and declarations
  • identifier=value ("=" separator) means attribute,
    • value can be delimited with double or single quotes
  • identifier:value (":" separator) means css style rule
    • value can be delimited with double or single quotes
  • value on its own means class or command (eg. zebrastripes) referred to as 'class method'
  • callouts for classes can be registered with SimpleWiki by client software
  • element selectors of callouts can vary interpretation of arguments
decorators must be left-abutted to the objects they decorate
Generally, elipsis (...) in the following means arguments:
inline decorators => %selector ...% (selector = l,i,s,c)
  • selectors = l (lower case 'L') for list, i for image, s for span, c for code.
  • if l, i or c are not immediately followed by their respective objects, deocrators are returned as text
  • s creates a span
  • %% = (empty inline decorator) is optional close for span decorator
block decorators => |:selector ...:| (selector = h,p,ul,ol,li,table,tr,th,td,b,pre)
  • "b" is block divider and creates an empty div
block declaration => (:selector[\d]* ...:)<text>(:selector[\d]*end:)
  • block declarations, both opening and closing tags, must be the first non-space characters of a line
  • opening tags can be followed by text on same line to prevent generation of paragraph markup
  • can be nested based on id number [\d]*
  • native selectors:
    div, blockquote, # blocks
    table, thead, tbody, tr, td, th, tfoot, caption, #tables
    ul, ol, li, dl, dt, dd, #lists
    dlmodule, dlobject, dlsettings #dlml (see dlml.org)
macro => <<macroname ...|text>> as (generally) specified in extended creole
  • can be inline, or act as block on its own line
Usage:
$wiki = new SimpleWiki($raw_text);
$html = $wiki->get_html();
Or for iterative usage:
$wiki = new SimpleWiki(); //once
$wiki->prepare($raw_text);
$html = $wiki->get_html();
or:
$wiki = new SimpleWiki();
$html = $wiki->get_html($raw_text);
For auto_quicktoc, register the prepared event before getting html:
$wiki = new SimpleWiki($markup);
$wiki->register_events(array('onemit' => array($wiki,'auto_quicktoc')));
$html = $wiki->get_html();