Skip to main content

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

Project description

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/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_style_flattener-0.0.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_style_flattener-0.0.3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file py_style_flattener-0.0.3.tar.gz.

File metadata

  • Download URL: py_style_flattener-0.0.3.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.11

File hashes

Hashes for py_style_flattener-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e92994d5c11c0dc217f96c95d71cfacaa3ef1119ead39c3fae918074d90f46d7
MD5 04a4a26f5bc0b2309f37aab9ef5292a0
BLAKE2b-256 e9b0c323856d57c6e0a31e033089cca4198deb8e81829b65bf3b72633070ca36

See more details on using hashes here.

File details

Details for the file py_style_flattener-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for py_style_flattener-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a88aa1df6f27c6dd8eb0bbefc97b8dad082a53297d24d361de1d770b5c62a50
MD5 7bed95ce55005e6938c964243a909693
BLAKE2b-256 883ce0121e7b3eaf4885ca11f796a9bb5c1609359697c449e422dc793c7d15e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page