more highlighting tweaks
diff --git a/doc/build/content/caching.txt b/doc/build/content/caching.txt
index ff532e9..7b0e178 100644
--- a/doc/build/content/caching.txt
+++ b/doc/build/content/caching.txt
@@ -25,7 +25,7 @@
 - cache_type - type of caching.  `memory`, `file`, `dbm`, or `memcached`.
 - cache_key - the "key" used to uniquely identify this content in the cache.  it defaults to the name of the function (TODO: support for multiple defs with the same name).  It is an evaluable tag, so you can put a Python expression to calculate the value of the key on the fly.  For example, heres a page that caches any page which inherits from it, based on the filename of the calling template:
     
-        <%page cache="true", cache_key="${self.filename}"/>
+        <%page cache="true" cache_key="${self.filename}"/>
     
         ${next.body()}
     
diff --git a/doc/build/content/syntax.txt b/doc/build/content/syntax.txt
index d15a521..56aa691 100644
--- a/doc/build/content/syntax.txt
+++ b/doc/build/content/syntax.txt
@@ -171,6 +171,4 @@
     <%text filter="h">
         heres some fake mako ${syntax}
         <%def name="x()">${x}</%def>
-    < /%text>
-
-(yes, this documentation system can't show you closing tag without the space in it! )
\ No newline at end of file
+    %CLOSETEXT
diff --git a/doc/build/templates/formatting.html b/doc/build/templates/formatting.html
index f187fa0..40afce6 100644
--- a/doc/build/templates/formatting.html
+++ b/doc/build/templates/formatting.html
@@ -1,6 +1,6 @@
 # formatting.myt - Provides section formatting elements, syntax-highlighted code blocks, and other special filters.
 <%!
-    import string, re
+    import string, re, cgi
     from mako import filters
     
     def plainfilter(f):
@@ -23,8 +23,6 @@
     <div class="${subsection and 'subsection' or 'section'}">
     <%
         content = capture(caller.body)
-        re2 = re.compile(r"'''PYESC(.+?)PYESC'''", re.S)
-        content = re2.sub(lambda m: m.group(1), content)
     %>
 
     <h3>${description or item.description}</h3>
@@ -57,15 +55,18 @@
         import pygments
         from pygments.formatters import HtmlFormatter
         from pygments.lexers import PythonLexer, HtmlLexer
-        from mako.ext.pygmentplugin import MakoLexer
-        lexers = {'mako':MakoLexer(), 'python':PythonLexer(), 'html':HtmlLexer()}
+        from mako.ext.pygmentplugin import MakoHtmlLexer
+        lexers = {'mako':MakoHtmlLexer(), 'python':PythonLexer(), 'html':HtmlLexer()}
     %>
     <%
         lexer = lexers.get(syntaxtype, None)
+        # dumb hack to print a </%text> tag inside of a <%text> section
+        content = re.sub(r'%CLOSETEXT', '</%text>', capture(caller.body))
+        
         if lexer is not None:
-            content = pygments.highlight(capture(caller.body) , lexer, HtmlFormatter())
+            content = pygments.highlight(content, lexer, HtmlFormatter())
         else:
-            content = "<pre>" + capture(caller.body) + "</pre>"
+            content = "<pre>" + content + "</pre>"
     %>
 
     <div class="${ use_sliders and "sliding_code" or "code" }">
diff --git a/lib/mako/ext/pygmentplugin.py b/lib/mako/ext/pygmentplugin.py
index 20ff558..4526092 100644
--- a/lib/mako/ext/pygmentplugin.py
+++ b/lib/mako/ext/pygmentplugin.py
@@ -24,8 +24,10 @@
              bygroups(Text, Comment.Preproc, Keyword, Other)),
             (r'(\s*)(\%)([^\n]*)(\n|\Z)',
              bygroups(Text, Comment.Preproc, using(PythonLexer), Other)),
-            (r'(<%)(def|call)', bygroups(Comment.Preproc, Name.Builtin), 'tag'),
-            (r'(</%)(def|call)(>)', bygroups(Comment.Preproc, Name.Builtin, Comment.Preproc)),
+             (r'(\s*)(#[^\n]*)(\n|\Z)',
+              bygroups(Text, Comment.Preproc, Other)),
+            (r'(<%)(def|call|namespace|text)', bygroups(Comment.Preproc, Name.Builtin), 'tag'),
+            (r'(</%)(def|call|namespace|text)(>)', bygroups(Comment.Preproc, Name.Builtin, Comment.Preproc)),
             (r'<%(?=(include|inherit|namespace|page))', Comment.Preproc, 'ondeftags'),
             (r'(<%(?:!?))(.*?)(%>)(?s)', bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
             (r'(\$\{)(.*?)(\})',
@@ -53,7 +55,6 @@
         'tag': [
             (r'((?:\w+)\s*=)\s*(".*?")',
              bygroups(Name.Attribute, String)),
-            #(r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'attr'),
             (r'/?\s*>', Comment.Preproc, '#pop'),
             (r'\s+', Text),
         ],