53acdea3cf0a

bundled/markdown2: hack together an 'imgless' extra

Because I'd rather not have people posting porn on the demo site.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 18 Jun 2010 23:04:40 -0400
parents 24f0d81f3aa5
children 4a5b97071a4d
branches/tags (none)
files bundled/markdown2/lib/markdown2.py

Changes

--- a/bundled/markdown2/lib/markdown2.py	Fri Jun 18 22:36:26 2010 -0400
+++ b/bundled/markdown2/lib/markdown2.py	Fri Jun 18 23:04:40 2010 -0400
@@ -962,10 +962,16 @@
                     else:
                         title_str = ''
                     if is_img:
-                        result = '<img src="%s" alt="%s"%s%s' \
-                            % (url.replace('"', '&quot;'),
-                               link_text.replace('"', '&quot;'),
-                               title_str, self.empty_element_suffix)
+                        if 'imgless' in self.extras:
+                            result = '[Image: <a href="%s" alt="a link to an image">%s</a> (%s)]' \
+                                % (url.replace('"', '&quot;'),
+                                   title,
+                                   link_text.replace('"', '&quot;'))
+                        else:
+                            result = '<img src="%s" alt="%s"%s%s' \
+                                % (url.replace('"', '&quot;'),
+                                   link_text.replace('"', '&quot;'),
+                                   title_str, self.empty_element_suffix)
                         curr_pos = start_idx + len(result)
                         text = text[:start_idx] + result + text[match.end():]
                     elif start_idx >= anchor_allowed_pos:
@@ -1006,10 +1012,16 @@
                         else:
                             title_str = ''
                         if is_img:
-                            result = '<img src="%s" alt="%s"%s%s' \
-                                % (url.replace('"', '&quot;'),
-                                   link_text.replace('"', '&quot;'),
-                                   title_str, self.empty_element_suffix)
+                            if 'imgless' in self.extras:
+                                result = '[Image: <a href="%s" alt="a link to an image">%s</a> (%s)]' \
+                                    % (url.replace('"', '&quot;'),
+                                       title,
+                                       link_text.replace('"', '&quot;'))
+                            else:
+                                result = '<img src="%s" alt="%s"%s%s' \
+                                    % (url.replace('"', '&quot;'),
+                                       link_text.replace('"', '&quot;'),
+                                       title_str, self.empty_element_suffix)
                             curr_pos = start_idx + len(result)
                             text = text[:start_idx] + result + text[match.end():]
                         elif start_idx >= anchor_allowed_pos: