Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noscript tag stop working in html on adding MarkRequestMiddleware class in django #113

Open
Ajeetlakhani opened this issue May 16, 2017 · 5 comments
Labels

Comments

@Ajeetlakhani
Copy link

I want to use style tag inside noscript tag to add a fallback message but style tag inside noscript tag gets minified and rendered as string.

@jlariza
Copy link

jlariza commented Jul 11, 2017

I am getting the same issue; and it is very problematic when trying to use amp because the "<style amp-boilerplate>" is required but is not rendered properly.

It may be related with html5lib/html5lib-python#104 But I am not sure.

Thank you,

@thornycrackers
Copy link

thornycrackers commented Feb 5, 2018

@jlariza You are correct, the issue is with html5lib. To circumvent this issue I just changed the parser inside of django-htmlmin/blob/master/htmlmin/minify.py (Line 52)

def html_minify(html_code, ignore_comments=True, parser="html5lib"):
    html_code = force_text(html_code)
    # soup = bs4.BeautifulSoup(html_code, 'html.parser')
    soup = bs4.BeautifulSoup(html_code, parser) 
    mini_soup = space_minify(soup, ignore_comments)

The comment is my changed line. I changed it to mirror the Quickstart documentation from BeautifulSoup:

https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.html

after that my issues went away.

@ryanbagwell
Copy link

There's an undocumented html5 parser setting that you can use to specify the parser. So just add the following to your django settings:

    HTML_MIN_PARSER = 'html.parser'

@benzkji
Copy link

benzkji commented Nov 20, 2018

as far as I know, there are other issues when not using html5lib? any experiences? maybe @andrewsmedina has some insights to share?

I am using html.parser for now, and it seems to work well...

@benzkji
Copy link

benzkji commented Nov 20, 2018

and....html5lib==1.0.1 solves this problem for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants