chiark / gitweb /
m.htmlsanity: graceful docutils error handling in the render_rst filter.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 29 Mar 2019 10:35:31 +0000 (11:35 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Fri, 29 Mar 2019 12:44:31 +0000 (13:44 +0100)
Like I did for Pelican 4.

pelican-plugins/m/htmlsanity.py
pelican-plugins/m/test/htmlsanity_parse_error/page.rst [new file with mode: 0644]
pelican-plugins/m/test/test_htmlsanity.py

index 38deabd506d309f758605425c45cc0f60556320e..85d68e06cec77f1af5e395640a0dc1b4a3bd4a5a 100644 (file)
@@ -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 (file)
index 0000000..34bfa2d
--- /dev/null
@@ -0,0 +1,2 @@
+Hello
+#####
index ea8c989c9d5ca5a94e6bb15d3f31c8a0a520cbe3..90efe87ca21c39a431f0425d477b81e88dbeb9da 100644 (file)
@@ -109,3 +109,20 @@ class TypographyGlobalLang(PluginTestCase):
         # The <html> lang element should be set correctly and the &shy; 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.
+"""})