# HG changeset patch
# User Steve Losh <steve@stevelosh.com>
# Date 1276916680 14400
# Node ID 53acdea3cf0a381d4cf7d17a3e41b037c1429a4f
# Parent  24f0d81f3aa54c88fae3b2b3fd7b3d3458ca2425
bundled/markdown2: hack together an 'imgless' extra

Because I'd rather not have people posting porn on the demo site.

diff -r 24f0d81f3aa5 -r 53acdea3cf0a bundled/markdown2/lib/markdown2.py
--- 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: