- print "<div class='wiki'><p>"
-
- # For each line, we scan through looking for magic
- # strings, outputting verbatim any intervening text
- scan_re = re.compile(
- r"(?:"
- + r"(?P<emph>'{2,3})"
- + r"|(?P<tit>\={2,6})"
- + r"|(?P<ent>[<>&])"
- + r"|(?P<img>\b[a-zA-Z0-9_-]+\.(png|gif|jpg|jpeg|bmp))"
- + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)"
- + r"|(?P<rule>^-{3,})"
- + r"|(?P<hurl>\[\[\S+\s+.+\]\])"
- + r"|(?P<url>(http|ftp|nntp|news|mailto)\:[^\s'\"]+\S)"
- + r"|(?P<email>[-\w._+]+\@[\w.-]+)"
- + r"|(?P<li>^\s+\*)"
- + r"|(?P<pre>(\{\{\{|\s*\}\}\}))"
- + r"|(?P<var>(\{\{|\}\}))"
- + r"|(?P<macro>\[\[(TitleSearch|FullSearch|WordIndex|TitleIndex)\]\])"
- + r")")
- pre_re = re.compile(
- r"(?:"
- + r"(?P<pre>\s*\}\}\})"
- + r")")
- blank_re = re.compile("^\s*$")
- indent_re = re.compile("^\s*")
- eol_re = re.compile(r'\r?\n')
- raw = string.expandtabs(self.raw)
- for line in eol_re.split(raw):
- # Skip ACLs
+ print('<div class="wiki"><p>')
+
+ scan_re = re.compile(r"""(?:
+ # Styles and formatting ("--" must cling to a word to disambiguate it from the dash)
+ (?P<b> \*\* | // | \#\# | __ | --\b | \b-- | \^\^ | ,, | ''' | '' | `` )
+ | (?P<tit> \={2,6})
+ | (?P<br> \\\\)
+ | (?P<rule> ^-{3,})
+ | (?P<hi> \b( FIXME | TODO | DONE )\b )
+ | (?P<glyph> --)
+
+ # Links
+ | (?P<macro> \<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>)
+ | (?P<hurl> \[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])
+
+ # Inline HTML
+ | (?P<html> <(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])\b )
+ | (?P<htmle> ( /\s*> | </(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])> ) )
+ | (?P<ent> [<>&] )
+
+ # Auto links (LEGACY)
+ | (?P<img> \b[a-zA-Z0-9_/-]+\.(""" + image_ext + "|" + video_ext + r"""))
+ | (?P<word> \b(?:[A-Z][a-z]+){2,}\b)
+ | (?P<url> (http|https|ftp|mailto)\:[^\s'\"]+\S)
+ | (?P<email> [-\w._+]+\@[\w.-]+)
+
+ # Lists, divs, spans and inline objects
+ | (?P<li> ^\s+[\*\#]\s+)
+ | (?P<pre> \{\{\{|\s*\}\}\})
+ | (?P<inl> \{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})
+
+ # Tables
+ | (?P<tr> ^\s*\|\|(=|)\s*)
+ | (?P<tre> \s*\|\|(=|)\s*$)
+ | (?P<td> \s*\|\|(=|)\s*)
+
+ # TODO: highlight search words (look at referrer)
+ )""", re.VERBOSE)
+ pre_re = re.compile("""(?:
+ (?P<pre>\s*\}\}\})
+ | (?P<ent>[<>&])"
+ )""", re.VERBOSE)
+ blank_re = re.compile(r"^\s*$")
+ indent_re = re.compile(r"^\s*")
+ tr_re = re.compile(r"^\s*\|\|")
+ eol_re = re.compile(r"\r?\n")
+ # For each line, we scan through looking for magic strings, outputting verbatim any intervening text
+ #3.0: for self.line in eol_re.split(str(self.raw.expandtabs(), 'utf-8')):
+ for self.line in eol_re.split(str(self.raw.expandtabs())):
+ # Skip pragmas