Example #1
0
    def render_change_entry_html(self, info):
        old_value = ''
        new_value = ''

        if 'old' in info:
            old_value = info['old'][0] or ''

        if 'new' in info:
            new_value = info['new'][0] or ''

        old_value = render_markdown(old_value)
        new_value = render_markdown(new_value)
        old_lines = list(iter_markdown_lines(old_value))
        new_lines = list(iter_markdown_lines(new_value))

        differ = MyersDiffer(old_lines, new_lines)

        return ('<table class="diffed-text-area">%s</table>' % ''.join(
            self._render_all_change_lines(differ, old_lines, new_lines)))
Example #2
0
    def render_change_entry_html(self, info):
        old_value = ''
        new_value = ''

        if 'old' in info:
            old_value = info['old'][0] or ''

        if 'new' in info:
            new_value = info['new'][0] or ''

        old_value = render_markdown(old_value)
        new_value = render_markdown(new_value)
        old_lines = list(iter_markdown_lines(old_value))
        new_lines = list(iter_markdown_lines(new_value))

        differ = MyersDiffer(old_lines, new_lines)

        return ('<table class="diffed-text-area">%s</table>'
                % ''.join(self._render_all_change_lines(differ, old_lines,
                                                        new_lines)))
Example #3
0
    def generate_render(self):
        with self.obj.file as f:
            f.open()
            rendered = render_markdown_from_file(f)

        try:
            for line in iter_markdown_lines(rendered):
                yield line
        except Exception as e:
            logging.error('Failed to parse resulting Markdown XHTML for '
                          'file attachment %d: %s' % (self.obj.pk, e))
            yield _('Error while rendering Markdown content: %s') % e