GithubHelp home page GithubHelp logo

Comments (6)

mxdubois avatar mxdubois commented on June 27, 2024

Looks like this could be related to #15

Did that pull request get unmerged somehow?

from premailer.

peterbe avatar peterbe commented on June 27, 2024

Hi @mxdubois !

Yeah, premailer isn't as smart as the css parser in a web browser for example.
What do you think the right thing is to do here? It could recognize it with a simple regex and then do a urllib.urlopen(url).read() and include that.

from premailer.

peterbe avatar peterbe commented on June 27, 2024

Regarding #15 I think that got merged. It's here: https://github.com/peterbe/premailer/blob/master/premailer/premailer.py#L129

from premailer.

mxdubois avatar mxdubois commented on June 27, 2024

Well @SimonSapin recommended using tinycss:

Consider using an actual CSS parser like tinycss. With tinycss you can test if some_rule.at_keyword is None: … to only pick style rules (as opposed to at-rules such as @import.)

He didn't seem to approve of using regex to parse CSS. He linked me to this and said it applies to CSS as well.

I was thinking it'd be good just to ignore the @import so that it doesn't break cssselect. But if you want to take on the challenge of importing it, that could be neat. I'm not sure if you'd be able to inline an @font-face definition though.

from premailer.

peterbe avatar peterbe commented on June 27, 2024

I'll be honest... @SimonSapin is right. Doing a regex is cheating that will eventually fail. But I feel like there's lots more things that can go wrong if you expect premailer to be as smart as a web browser.

I don't think I will set aside time to work on a solution that uses tinycss or urllib.urlopen to import those external dependencies.

But if there's a nice patch with tests I'd be very eager to look at it. :)

from premailer.

guneysus avatar guneysus commented on June 27, 2024

And giving <style type="text/css" media="all"> only strip classes but not generates inline styles.
Removing media="all" works as expected. <style type="text/css" >

from premailer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.