Switch to creole syntax for <tt>
authorBernardo Innocenti <bernie@codewiz.org>
Mon, 17 Dec 2007 09:51:28 +0000 (10:51 +0100)
committerBernardo Innocenti <bernie@codewiz.org>
Mon, 17 Dec 2007 09:51:28 +0000 (10:51 +0100)
geekigeeki.py

index 83b6142a0a82d6cd457c53baf76154dccbb1eb89..7193d5520b50af8bb709453f3cb53f721d9c7efd 100755 (executable)
@@ -336,7 +336,7 @@ class PageFormatter:
     def __init__(self, raw):
         self.raw = raw
         self.h_level = 0
-        self.in_pre = self.in_table = self.in_var = self.in_em = self.in_b = False
+        self.in_pre = self.in_table = self.in_tt = self.in_em = self.in_b = False
         self.in_header = True
         self.list_indents = []
         self.tr_cnt = self.h_cnt = 0
@@ -349,6 +349,10 @@ class PageFormatter:
         self.in_em = not self.in_em
         return ['</em>', '<em>'][self.in_em]
 
+    def _tt_repl(self, word):
+        self.in_tt = not self.in_tt
+        return ['</tt>', '<tt>'][self.in_tt]
+
     def _tit_repl(self, word):
         if self.h_level:
             result = '</h%d>' % self.h_level
@@ -432,15 +436,6 @@ class PageFormatter:
             cl = 'notice'
         return '<strong class="highlight ' + cl + '">' + word + '</strong>'
 
-    def _var_repl(self, word):
-        if word == '{{' and not self.in_var:
-            self.in_var = True
-            return '<code>'
-        elif self.in_var:
-            self.in_var = False
-            return '</code>'
-        return ''
-
     def _tr_repl(self, word):
         out = ''
         if not self.in_table:
@@ -502,6 +497,7 @@ class PageFormatter:
             # Formatting
             + r"(?P<b>\*\*|''')"
             + r"|(?P<em>//|'')"
+            + r"|(?P<tt>##|``)"
             + r"|(?P<tit>\={2,6})"
             + r"|(?P<br>\\\\)"
             + r"|(?P<rule>^-{3,})"
@@ -519,7 +515,6 @@ class PageFormatter:
             # Lists, divs, spans
             + r"|(?P<li>^\s+[\*#] +)"
             + r"|(?P<pre>\{\{\{|\s*\}\}\})"
-            + r"|(?P<var>\{\{|\}\})"
 
             # Tables
             + r"|(?P<tr>^\s*\|\|(=|)\s*)"