Commit 46c48575 by benjaoming

Image captions should keep line breaks. Missing image files still keep causing problems

parent 5b49a60a
...@@ -26,7 +26,7 @@ class ImagePreprocessor(markdown.preprocessors.Preprocessor): ...@@ -26,7 +26,7 @@ class ImagePreprocessor(markdown.preprocessors.Preprocessor):
image = None image = None
image_id = None image_id = None
alignment = None alignment = None
caption = "" caption_lines = []
for line in lines: for line in lines:
m = IMAGE_RE.match(line) m = IMAGE_RE.match(line)
if m: if m:
...@@ -42,12 +42,13 @@ class ImagePreprocessor(markdown.preprocessors.Preprocessor): ...@@ -42,12 +42,13 @@ class ImagePreprocessor(markdown.preprocessors.Preprocessor):
line = line.replace(m.group(1), "") line = line.replace(m.group(1), "")
elif previous_line_was_image: elif previous_line_was_image:
if line.startswith(" "): if line.startswith(" "):
caption += line[3:] caption_lines.append(line[4:])
line = None line = None
else: else:
html = render_to_string("wiki/plugins/images/render.html", html = render_to_string("wiki/plugins/images/render.html",
Context({'image': image, Context({'image': image,
'caption': article_markdown(caption, self.markdown.article, 'caption': article_markdown("\n".join(caption_lines),
self.markdown.article,
extensions=self.markdown.registeredExtensions), extensions=self.markdown.registeredExtensions),
'align': alignment})) 'align': alignment}))
line = html + line line = html + line
......
...@@ -84,8 +84,6 @@ class ImageRevision(RevisionPluginRevision): ...@@ -84,8 +84,6 @@ class ImageRevision(RevisionPluginRevision):
self.height = predecessor.height self.height = predecessor.height
except IOError: except IOError:
self.image = None self.image = None
self.width = None
self.height = None
class Meta: class Meta:
verbose_name = _(u'image revision') verbose_name = _(u'image revision')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment