python-textile icon indicating copy to clipboard operation
python-textile copied to clipboard

images with classes and alt-tags don't work

Open betterthanads opened this issue 16 years ago • 1 comments

looks like the classid regex's forward-looking condition doesn't like the alt tag in parentheses on images.

Example: !(myclass)/assets/photo.png(cool stuff)!

betterthanads avatar Dec 03 '09 18:12 betterthanads

Here's a simple patch that creates an image-classid regex that removes the forward-looking condition:

--- textile.py.orig     2009-12-03 13:25:19.000000000 -0500
+++ textile.py  2009-12-03 13:26:32.000000000 -0500
@@ -285,6 +285,15 @@
                     )                               #
                     (?![^\s]*(?:\([\w#]+\)))        # must happen once
                  ''',
+
+    # Class and/or id (for images)
+    'iclassid':  r'''(                               #
+                        (?:\(\#[\w]+\))             # (#id)
+                        |                           #
+                        (?:\((?:[\w]+(?:\s[\w]+)*)  #
+                            (?:\#[\w]+)?\))         # (class1 class2 ... classn#id) or (class1 class2 ... classn)
+                    )                               #
+                 ''',

     # Language.
     'lang':     r'''(?:\[[\w-]+\])                  # [lang]
@@ -412,7 +421,7 @@
                      |                                      #
                      (?: [\-\^~]+                           # vertical alignment tags
                          (?![^\s]*(?:[\-\^~])))             #     (must happen once)
-                     | %(classid)s                          # class and/or id
+                     | %(iclassid)s                         # class and/or id
                      | %(padding)s                          # padding tags
                      | %(style)s                            # {style}
                      )+                                     #

betterthanads avatar Dec 03 '09 18:12 betterthanads