Mercurial > p > roundup > code
changeset 6279:9ec3a9bc4ea5
issue2551097 - fix call to markdown2 - fix fenced code blocks.
The invocation of fenced codeblock support in markdown2 was wrong.
With this fixed the code that was used to test markdown processor
exception handling no longer works. Fixed test case to make it pass.
Added new test with invalid markdown that tests markdown exception
handling.
Also renamed test to include markdown. Makes using -k option in
run_tests easier.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 29 Oct 2020 17:08:44 -0400 |
| parents | f21ec1414591 |
| children | 6ed5152a92d0 |
| files | CHANGES.txt roundup/cgi/templating.py test/test_templating.py |
| diffstat | 3 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Mon Oct 26 20:27:23 2020 -0400 +++ b/CHANGES.txt Thu Oct 29 17:08:44 2020 -0400 @@ -37,11 +37,14 @@ - issue2551093 - return plain text if markdown formatter throws exception (reported by Cedric Krier, fix by John Rouillard) - issue2551094 - make simplemde handle line breaks the same as the - backend markdown formmatters. (report: Cedric Krier, patch: Christof + backend markdown formatters. (report: Cedric Krier, patch: Christof Meerwald) - issue2551092 - fix crash bug by aligning roundup.anypy.email_.decode_header with stdlib email.header and - convert string to bytes for python 3. (Cedrick Krier) + convert string to bytes for python 3. +- issue2551097 - fix underlying bug in use of fenced codeblocks with + markdown2. Fix for issue2551093 to prevent exception trigger. + (patch: Cedric Krier) Features: - issue2550522 - Add 'filter' command to command-line
--- a/roundup/cgi/templating.py Mon Oct 26 20:27:23 2020 -0400 +++ b/roundup/cgi/templating.py Thu Oct 29 17:08:44 2020 -0400 @@ -70,7 +70,7 @@ _safe_protocols = re.compile('(?!' + ':|'.join([re.escape(s) for s in _disable_url_schemes]) + ':)', re.IGNORECASE) def _extras(config): - extras = { 'fenced-code-blocks' : True } + extras = { 'fenced-code-blocks' : {} } if config['MARKDOWN_BREAK_ON_NEWLINE']: extras['break-on-newline'] = True return extras
--- a/test/test_templating.py Mon Oct 26 20:27:23 2020 -0400 +++ b/test/test_templating.py Thu Oct 29 17:08:44 2020 -0400 @@ -473,11 +473,17 @@ self.assertEqual(m.replace('\n\n','\n'), '<p>embedded code block <pre></p>\n<pre><code class="lang-python">line 1\nline 2\n</code></pre>\n<p>new </pre> paragraph</p>') elif type(self) == MarkdownTestCase: self.assertEqual(m.replace('\n\n','\n'), '<p>embedded code block <pre></p>\n<pre><code class="language-python">line 1\nline 2\n</code></pre>\n<p>new </pre> paragraph</p>') - else: # markdown2 doesn't handle attributes with code blocks - # so processing it returns original text - self.assertEqual(m.replace('\n\n', '\n'), u2s(u'embedded code block <pre>\n``` python\nline 1\nline 2\n```\nnew </pre> paragraph')) + else: + self.assertEqual(m.replace('\n\n', '\n'), '<p>embedded code block <pre></p>\n<div class="codehilite"><pre><span></span><code><span class="n">line</span> <span class="mi">1</span>\n<span class="n">line</span> <span class="mi">2</span>\n</code></pre></div>\n<p>new </pre> paragraph</p>') - def test_break_on_newline(self): + def test_markdown_return_text_on_exception(self): + ''' string is invalid markdown. missing end of fenced code block ''' + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'embedded code block <pre>\n\n``` python\nline 1\nline 2\n\n\nnew </pre> paragraph')) + m = p.markdown().strip() + print(m) + self.assertEqual(m.replace('\n\n','\n'), '<p>embedded code block <pre></p>\n<p>``` python\nline 1\nline 2</p>\n<p>new </pre> paragraph</p>') + + def test_markdown_break_on_newline(self): self.client.db.config['MARKDOWN_BREAK_ON_NEWLINE'] = True p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with\nline break\ntwice.')) m = p.markdown()
