Skip to main content

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

Metadata

Release files for py-style-flattener 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-style-flattener 0.0.3
File Size Uploaded
py_style_flattener-0.0.3.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-style-flattener 0.0.3
File Interpreter ABI Platform
py_style_flattener-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.7 kB

Release files / py_style_flattener-0.0.3.tar.gz

Download URL py_style_flattener-0.0.3.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e92994d5c11c0dc217f96c95d71cfacaa3ef1119ead39c3fae918074d90f46d7
BLAKE2b-256 checksum
How to use checksums
e9b0c323856d57c6e0a31e033089cca4198deb8e81829b65bf3b72633070ca36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.11

Release files / py_style_flattener-0.0.3-py3-none-any.whl

Download URL py_style_flattener-0.0.3-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a88aa1df6f27c6dd8eb0bbefc97b8dad082a53297d24d361de1d770b5c62a50
BLAKE2b-256 checksum
How to use checksums
883ce0121e7b3eaf4885ca11f796a9bb5c1609359697c449e422dc793c7d15e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.11

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page