current https://trac-hacks.org/wiki/IncludeMacro does not run under Trac 1.6
due to genshi imports

see the attached patch to make it functional

-- 
ales horak

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/trac-users/25183efb-9d0d-4e7c-a6dd-6b68feb09f5bn%40googlegroups.com.
--- macros.orig.py	2025-09-13 12:32:03.342878939 +0200
+++ macros.py	2025-09-13 12:32:23.145049545 +0200
@@ -18,8 +18,9 @@
 import re
 
 
-from genshi.filters.html import HTMLSanitizer
-from genshi.input import HTMLParser, ParseError
+#from genshi.filters.html import HTMLSanitizer
+#from genshi.input import HTMLParser, ParseError
+from html.parser import HTMLParser
 from trac.core import TracError, implements
 from trac.mimeview.api import Mimeview, get_mimetype
 from trac.perm import IPermissionRequestor
@@ -28,7 +29,7 @@
 from trac.util import as_bool, as_int
 from trac.util.html import escape
 from trac.util.text import to_unicode
-from trac.util.translation import _
+from trac.util.translation import _, cleandoc_
 from trac.versioncontrol.api import NoSuchChangeset, NoSuchNode, \
     RepositoryManager
 from trac.web.chrome import web_context
@@ -45,10 +46,12 @@
 
 
 class IncludeMacro(WikiMacroBase):
+    _domain = 'messages'
+    _description = cleandoc_(
     """A macro to include other resources in wiki pages.
 
     More documentation to follow.
-    """
+    """)
 
     implements(IPermissionRequestor)
 
@@ -60,6 +63,8 @@
     # IWikiMacroProvider methods
 
     def expand_macro(self, formatter, name, content):
+        self.env.log.debug("hello from IncludeMacro")
+
         largs, kwargs = parse_args(content)
         if len(largs) == 1:
             largs.append(None)
@@ -206,8 +211,9 @@
         if not self.config.getbool('wiki', 'render_unsafe_content', False):
             out = to_unicode(out)
             try:
-                out = HTMLParser(StringIO(out)).parse() | HTMLSanitizer()
-            except ParseError:
+                out = HTMLParser(StringIO(out)).parse() | TracHTMLSanitizer()
+            #except ParseError: no ParseError in HTMLParser now
+            except:
                 out = escape(out)
 
         return out
@@ -289,11 +295,11 @@
         return out, ctxt, dest_format, annotations
 
     def _extract_section(self, text, section):
-        m1 = re.search("(^\s*(?P<heading>={1,6})\s(.*?)(\#%s)\s*$)" % section,
+        m1 = re.search(r"(^\s*(?P<heading>={1,6})\s(.*?)(\#%s)\s*$)" % section,
                        text, re.MULTILINE)
         if m1:
             stext = text[m1.end(0):]
-            m2 = re.search("(^\s*%s\s(.*?)(\#%s)?\s*$)"
+            m2 = re.search(r"(^\s*%s\s(.*?)(\#%s)?\s*$)"
                            % (m1.group('heading'), WikiParser.XML_NAME),
                            stext, re.MULTILINE)
             if m2:

Reply via email to