Mercurial > p > roundup > code
diff test/test_templating.py @ 6277:957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
Make earlier patch to fix mismatch between simplemde formatting
of embedded newlines choosable. New option MARKDOWN_BREAK_ON_NEWLINE
added to config.ini. If set to true all 4 renders: markdown,
markdown2, mistune and simplemde will make a newline into a hard
linebreak using <br> when displayed.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 25 Oct 2020 16:12:15 -0400 |
| parents | bda491248fd8 |
| children | 9ec3a9bc4ea5 |
line wrap: on
line diff
--- a/test/test_templating.py Fri Oct 23 18:38:37 2020 -0400 +++ b/test/test_templating.py Sun Oct 25 16:12:15 2020 -0400 @@ -74,7 +74,7 @@ # add client props for testing anti_csrf_nonce self.client.session_api = MockNull(_sid="1234567890") self.client.db.getuid = lambda : 10 - self.client.db.config = {'WEB_CSRF_TOKEN_LIFETIME': 10 } + self.client.db.config = {'WEB_CSRF_TOKEN_LIFETIME': 10, 'MARKDOWN_BREAK_ON_NEWLINE': False } class HTMLDatabaseTestCase(TemplatingTestCase): def test_HTMLDatabase___getitem__(self): @@ -477,6 +477,16 @@ # 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')) + def test_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() + self.assertEqual(2, m.count('<br')) + self.client.db.config['MARKDOWN_BREAK_ON_NEWLINE'] = False + + m = p.markdown() + self.assertEqual(0, m.count('<br')) + @skip_mistune class MistuneTestCase(TemplatingTestCase, MarkdownTests) :
