From 8cb0d98daa28e652a0f73a488dee486f7c5aeb5f Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Mon, 14 Mar 2016 17:19:17 +0100
Subject: [PATCH] [ui] Revert previous function use validator in common/utils
 instead

---
 beat/web/ui/templatetags/markup.py | 59 ------------------------------
 1 file changed, 59 deletions(-)

diff --git a/beat/web/ui/templatetags/markup.py b/beat/web/ui/templatetags/markup.py
index aefaa3e58..de62becf2 100644
--- a/beat/web/ui/templatetags/markup.py
+++ b/beat/web/ui/templatetags/markup.py
@@ -95,64 +95,6 @@ def markdown(value, arg=''):
                     ))
 
 
-def get_rst_errors(s, config):
-    """Catch errors and syntax warnings and returns them
-    """
-
-    import docutils.utils
-    import docutils.parsers
-    import docutils.frontend
-
-    class SilentReporter(docutils.utils.Reporter):
-      """
-      Silent reporter
-
-      All warnings and errors will be stored and can be used subsequently
-      through the reporter instance
-      """
-
-      def __init__(self, *args, **kwargs):
-          self.messages = []
-          docutils.utils.Reporter.__init__(self, *args, **kwargs)
-
-      def system_message(self, level, message, *children, **kwargs):
-          self.messages.append((level, message, children, kwargs))
-
-    parser = docutils.parsers.rst.Parser()
-
-    defaults = docutils.frontend.OptionParser().get_default_values()
-    for key, val in config.items(): setattr(defaults, key, val)
-    defaults.tab_width = 4
-    defaults.pep_references = None
-    defaults.rfc_references = None
-    defaults.report_level = 1 #info
-    defaults.halt_level = 4 #severe
-    defaults.debug = 0 #don't debug
-
-    reporter = SilentReporter(
-        None,
-        defaults.report_level, #info
-        defaults.halt_level, #severe
-        stream=defaults.warning_stream,
-        debug=defaults.debug, #no debug
-        encoding=defaults.error_encoding,
-        error_handler=defaults.error_encoding_error_handler,
-    )
-
-    document = docutils.utils.new_document(None, defaults)
-    document.reporter = reporter
-
-    try:
-        parser.parse(s, document)
-    except AttributeError:
-        pass
-    except TypeError:
-        # Catch ``TypeError`` to avoid problems with local roles
-        # NOTE: Is this still necessary ?
-        pass
-    return reporter.messages
-
-
 @register.filter(is_safe=True)
 @stringfilter
 def restructuredtext(value, full=False):
@@ -165,7 +107,6 @@ def restructuredtext(value, full=False):
     else:
         docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
         parts = publish_parts(source=force_bytes(value), writer_name="html4css1", settings_overrides=docutils_settings)
-        #errors = get_rst_errors(value, docutils_settings)
         if full:
             return mark_safe(force_text(parts["html_body"])) #with h1 title
         else:
-- 
GitLab