Ejemplo n.º 1
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     return mark_safe(article_markdown(content, self))
Ejemplo n.º 2
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     return mark_safe(article_markdown(content, self))
Ejemplo n.º 3
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     extensions = plugin_registry.get_markdown_extensions()
     extensions += settings.MARKDOWN_EXTENSIONS
     return mark_safe(article_markdown(content, self, extensions=extensions))
Ejemplo n.º 4
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     extensions = plugin_registry.get_markdown_extensions()
     extensions += settings.MARKDOWN_EXTENSIONS
     return mark_safe(article_markdown(content, self, extensions=extensions))
Ejemplo n.º 5
0
 def run(self, lines):
     new_text = []
     previous_line_was_image = False
     image = None
     image_id = None
     alignment = None
     caption_lines = []
     for line in lines:
         m = IMAGE_RE.match(line)
         if m:
             previous_line_was_image = True
             image_id = m.group('id').strip()
             alignment = m.group('align').strip()
             try:
                 image = models.Image.objects.get(
                     article=self.markdown.article,
                     id=image_id,
                     current_revision__deleted=False)
             except models.Image.DoesNotExist:
                 pass
             line = line.replace(m.group(1), "")
         elif previous_line_was_image:
             if line.startswith("    "):
                 caption_lines.append(line[4:])
                 line = None
             else:
                 html = render_to_string(
                     "wiki/plugins/images/render.html",
                     Context({
                         'image':
                         image,
                         'caption':
                         article_markdown(
                             "\n".join(caption_lines),
                             self.markdown.article,
                             extensions=self.markdown.registeredExtensions),
                         'align':
                         alignment
                     }))
                 line = html + line
                 previous_line_was_image = False
         if not line is None:
             new_text.append(line)
     return new_text
Ejemplo n.º 6
0
 def run(self, lines):
     new_text = []
     previous_line_was_image = False
     image = None
     image_id = None
     alignment = None
     caption_lines = []
     for line in lines:
         m = IMAGE_RE.match(line)
         if m:
             previous_line_was_image = True
             image_id = m.group('id').strip()
             alignment = m.group('align').strip()
             try:
                 image = models.Image.objects.get(article=self.markdown.article,
                                                 id=image_id,
                                                 current_revision__deleted=False)
             except models.Image.DoesNotExist:
                 pass
             line = line.replace(m.group(1), "")
             caption_lines = []
         elif previous_line_was_image:
             if line.startswith("    "):
                 caption_lines.append(line[4:])
                 line = None
             else:
                 html = render_to_string("wiki/plugins/images/render.html",
                                         Context({'image': image, 
                                                  'caption': article_markdown("\n".join(caption_lines),
                                                                              self.markdown.article,
                                                                              extensions=self.markdown.registeredExtensions), 
                                                  'align': alignment}))
                 line = html + line
                 previous_line_was_image = False
         if not line is None:
             new_text.append(line)
     return new_text