Implement <<macro>> syntax.
authorBernie Innocenti <bernie@codewiz.org>
Mon, 2 Jun 2008 10:07:14 +0000 (12:07 +0200)
committerBernie Innocenti <bernie@codewiz.org>
Mon, 2 Jun 2008 10:07:14 +0000 (12:07 +0200)
geekigeeki.css
geekigeeki.py

index f862a3f9aaec88e75b71f56740baaf8be839d2e8..8971f4bcb9eb73d3c9cf6401e428071b8e0397e3 100755 (executable)
@@ -139,6 +139,10 @@ strong.FIXME {
        background-color: #ee2222;
 }
 
+strong.error {
+       color: red;
+}
+
 div {
        margin-left: 10px;
        margin-right: 10px;
@@ -184,7 +188,7 @@ div.nav {
 
 .nav .login {
        font-size: small;
-       text-color: red;
+       color: red;
 }
 
 #footer div {
index bee5e34693139ce0f7f022a2ad3d815802fa10fa..be262f9e77b2400ae5b84a78bcf6b482f8339d7c 100755 (executable)
@@ -385,8 +385,22 @@ class PageFormatter:
         else:
             return '<a href="%s" rel="nofollow" class="external">%s</a>' % (word, word)
 
+    def _macro_repl(self, word):
+        m = re.compile("<<([^\s\|]+)(?:\s*\|\s*([^\]]+)|)>>").match(word)
+        name = m.group(1)
+        param = m.group(2) or None
+
+        macro = globals().get('_macro_' + name)
+        if macro:
+            return macro(name, param)
+        else:
+            param_str = ''
+            if param:
+                param_str = param + ' '
+            return '<strong class="error">' + name + param_str + '</strong>'
+
     def _hurl_repl(self, word):
-        m = re.compile("\[\[([^ \t\n\r\f\v\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
+        m = re.compile("\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
         name = m.group(1)
         descr = m.group(2) or name
 
@@ -499,21 +513,26 @@ class PageFormatter:
             + r"|(?P<tit>\={2,6})"
             + r"|(?P<br>\\\\)"
             + r"|(?P<rule>^-{3,})"
+
+            # Links
+            + r"|(?P<macro><<([^\s\|]+)(?:\s*\|\s*([^\]]+)|)>>)"
+            + r"|(?P<hurl>\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])"
+
+            # Inline HTML
             + r"|(?P<html><(/|)(div|span|iframe)[^<>]*>)"
             + r"|(?P<ent>[<>&])"
             + r"|(?P<hi>\b(FIXME|TODO|DONE)\b)"
 
             # Links
-            + 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<hurl>\[\[([^ \s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])"
-            + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)"
-            + r"|(?P<email>[-\w._+]+\@[\w.-]+)"
+            + r"|(?P<img>\b[a-zA-Z0-9_-]+\.(png|gif|jpg|jpeg|bmp))" # LEGACY
+            + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)" # LEGACY
+            + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)" # LEGACY
+            + r"|(?P<email>[-\w._+]+\@[\w.-]+)" # LEGACY
 
             # Lists, divs, spans
             + r"|(?P<li>^\s+[\*#] +)"
             + r"|(?P<pre>\{\{\{|\s*\}\}\})"
-            + r"|(?P<hurl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})"
+            + r"|(?P<inl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})" #TODO
 
             # Tables
             + r"|(?P<tr>^\s*\|\|(=|)\s*)"