"""
Middleware for injecting the live-reload script.
"""
from bs4 import BeautifulSoup

from django.utils.encoding import smart_str


class LiveReloadScript(object):
    """
    Inject the live-reload script into your webpages.
    """

    def process_response(self, request, response):
        if response.status_code != 200:
            return response

        content_type = response.get(
            'Content-Type', '').split(';')[0].strip().lower()
        if content_type not in ['text/html', 'application/xhtml+xml']:
            return response

        soup = BeautifulSoup(
            smart_str(response.content), 'html.parser')

        if not getattr(soup, 'head', None):
            return response

        script = soup.new_tag(
            'script', src='http://localhost:35729/livereload.js')
        soup.head.append(script)

        response.content = str(soup)

        return response

@@ -97,39 +97,328 @@
 ngo.
-utils.encoding import smart_str
+conf import settings%0Afrom django.utils.encoding import smart_str%0A%0Atry:%0A    import html5lib  # noqa%0A    html5lib_is_installed = True%0Aexcept ImportError:%0A    html5lib_is_installed = False%0A%0A%0AIS_HTML5 = getattr(settings, 'LIVERELOAD_HTML5', html5lib_is_installed)%0A%0APARSER = 'html.parser'%0Aif IS_HTML5:%0A    PARSER = 'html5lib'
 %0A%0A%0Ac
@@ -909,29 +909,22 @@
 ntent), 
-'html.parser'
+PARSER
 )%0A%0A     

Handle html5 parsing