Socket
Socket
Sign inDemoInstall

py-style-flattener

Package Overview
Dependencies
6
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    py-style-flattener

Manipulate HTML by moving <style> to style=".


Maintainers
1

Readme

Py Style Flattener

Introduction

This module is useful to move all the css from style tags to inline style attribute

Makes use of pyquery and regex (due to stdlib's re module not supporting recursion)

Keeps all the @font-face but removes everything else

Installation

pip install py_style_flattener

Usage

It can be used from cli:

$ py-style-flattener INPUT OUTPUT

(note that INPUT and OUTPUT can be either paths or stdin/stdout)

Or as a python module

>>> import py_style_flattener
>>> # using files, you need to open them before.
>>> py_style_flattener.using_files(INPUT, OUTPUT)
>>> # using plain strings
>>> OUTPUT = dpy_style_flattener.using_strings(INPUT)

Current limitations:

  • doesn't fetch remote style
  • cannot set pseudo elements (limitation inherited from cssselect used by pyquery)
  • only takes care of @media screen{} avoiding all other media queries

Contributing

build & release

pip install build twine
python -m build
python -m twine upload --config-file .pypirc dist/*

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc