Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

py-style-flattener

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

py-style-flattener

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

  • 0.0.3
  • Source
  • PyPI
  • Socket score

Maintainers
1

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc