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
def test_render_markdown_from_file_sanitizes_links(self): """Testing render_markdown_from_file sanitizes XSS in links""" self._test_clean_markdown_links_xss( lambda content: render_markdown_from_file( io.BytesIO(content.encode('utf-8'))))