From: Vladimír Vondruš Date: Fri, 29 Mar 2019 10:35:31 +0000 (+0100) Subject: m.htmlsanity: graceful docutils error handling in the render_rst filter. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=543261843706be1d7af35ed0e9e979b87e43538c;p=blog.git m.htmlsanity: graceful docutils error handling in the render_rst filter. Like I did for Pelican 4. --- diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py index 38deabd5..85d68e06 100644 --- a/pelican-plugins/m/htmlsanity.py +++ b/pelican-plugins/m/htmlsanity.py @@ -656,7 +656,8 @@ def render_rst(value): 'syntax_highlight': 'short', 'input_encoding': 'utf-8', 'language_code': settings['DEFAULT_LANG'], - 'exit_status_level': 2, + 'halt_level': 2, + 'traceback': True, 'embed_stylesheet': False} if settings['DOCUTILS_SETTINGS']: extra_params.update(settings['DOCUTILS_SETTINGS']) diff --git a/pelican-plugins/m/test/htmlsanity_parse_error/page.rst b/pelican-plugins/m/test/htmlsanity_parse_error/page.rst new file mode 100644 index 00000000..34bfa2d5 --- /dev/null +++ b/pelican-plugins/m/test/htmlsanity_parse_error/page.rst @@ -0,0 +1,2 @@ +Hello +##### diff --git a/pelican-plugins/m/test/test_htmlsanity.py b/pelican-plugins/m/test/test_htmlsanity.py index ea8c989c..90efe87c 100644 --- a/pelican-plugins/m/test/test_htmlsanity.py +++ b/pelican-plugins/m/test/test_htmlsanity.py @@ -109,3 +109,20 @@ class TypographyGlobalLang(PluginTestCase): # The lang element should be set correctly and the ­ should # be at proper places and not where it shouldn't be. self.assertEqual(*self.actual_expected_contents('page.html')) + +class RenderRst(PluginTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'parse_error', *args, **kwargs) + + def test_parse_error(self): + # Verify that the parse error in M_FINE_PRINT raises an Exception, not + # nothing and not SystemExit or some such + with self.assertRaisesRegex(Exception, "underline too short"): + self.run_pelican({ + 'PLUGINS': ['m.htmlsanity'], + 'M_FINE_PRINT': """ +Page with a parse error +############# + +The underline is too short. +"""})