Formats given exception as an html text.

        :param \*args: Arguments.
        :type \*args: \*
        :return: Exception html text.
        :rtype: unicode

def format_html_exception(*args):
        """
        Formats given exception as an html text.

        :param \*args: Arguments.
        :type \*args: \*
        :return: Exception html text.
        :rtype: unicode
        """

        escape = lambda x: foundations.strings.replace(x,
                                                       OrderedDict([("&", "&amp;"), ("<", "&lt;"), (">", "&gt;")]))
        format = lambda x: foundations.strings.replace(x.expandtabs(8),
                                                       OrderedDict(
                                                           [("\n\n", "\n \n"), ("\n\n", "\n \n"), (" ", "&nbsp;"),
                                                            ("\n", "<br/>\n")]))

        verbose = 10
        cls, instance, trcback = args
        stack = foundations.exceptions.extract_stack(foundations.exceptions.get_inner_most_frame(trcback), verbose)

        python = "Python {0}: {1}".format(sys.version.split()[0], sys.executable)
        date = time.ctime(time.time())

        html = []
        html.append(
            "<div class=\"header\"><span class=\"floatRight textAlignRight\"><h4>{0}<br/>{1}</h4></span><h2>{2}</h2></div>".format(
                python, date, escape(foundations.strings.to_string(cls))))

        html.append("<div class=\"traceback\">")
        for line in foundations.exceptions.format_exception(cls, instance, trcback):
            html.append("{0}<br/>".format(format(escape(line))))
        html.append("</div>")

        html.append("<div class=\"content\">")
        html.append("<p>An unhandled exception occured in <b>{0} {1}</b>! \
                Sequence of calls leading up to the exception, in their occurring order:</p>".format(
            Constants.application_name, Constants.version))
        html.append("<br/>")
        html.append("<div class=\"stack\">")
        for frame, file_name, line_number, name, context, index in stack:
            location = "<b>{0}{1}</b>".format(escape(name) if name != "<module>" else "",
                                              inspect.formatargvalues(*inspect.getargvalues(frame)))
            html.append(
                "<div class=\"location\">File <a href=file://{0}>\"{0}\"</a>, line <b>{1}</b>, in {2}</div><br>".format(
                    file_name, line_number, location))
            html.append("<div class=\"context\">")
            for i, line in enumerate(context):
                if i == index:
                    html.append("<span class=\"highlight\">{0}&nbsp;{1}</span>".format(
                        line_number - index + i, format(line)))
                else:
                    html.append("{0}&nbsp;{1}".format(line_number - index + i, format(line)))
            html.append("</div>")
            html.append("<br/>")
        html.append("</div>")
        html.append("</div>")
        html.append("<div class=\"exception\">")
        for line in traceback.format_exception_only(cls, instance):
            html.append("<b>{0}</b>".format(format(line)))
        html.append("</div>")

        html.append("<div class=\"debug\">")
        html.append("<p>Frames locals by stack ordering, innermost last:</p>")
        for frame, locals in foundations.exceptions.extract_locals(trcback):
            name, file_name, line_number = frame
            html.append(
                "<div class=\"frame\">Frame \"{0}\" in <a href=file://{1}>\"{1}\"</a> file, line <b>{2}</b>:</div>".format(
                    escape(name), file_name, line_number))
            html.append("<br/>")
            html.append("<div class=\"locals\">")
            arguments, nameless_args, keyword_args, locals = locals
            has_arguments, has_locals = any((arguments, nameless_args, keyword_args)), any(locals)
            has_arguments and html.append("<div class=\"cls\"><b>{0}</b></div><ul>".format("Arguments:"))
            for key, value in arguments.iteritems():
                html.append("<li><b>{0}</b> = {1}</li>".format(key, escape(value)))
            for value in nameless_args:
                html.append("<li><b>{0}</b></li>".format(escape(value)))
            for key, value in sorted(keyword_args.iteritems()):
                html.append("<li><b>{0}</b> = {1}</li>".format(key, escape(value)))
            has_arguments and html.append("</ul>")
            has_locals and html.append("<div class=\"cls\"><b>{0}</b></div><ul>".format("Locals:"))
            for key, value in sorted(locals.iteritems()):
                html.append("<li><b>{0}</b> = {1}</li>".format(key, escape(value)))
            has_locals and html.append("</ul>")
            html.append("</div>")
            html.append("<br/>")
        html.append("</div>")

        return "".join(html)