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
python -m build
Project details
Release history Release notifications | RSS feed
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.2.tar.gz
(15.9 kB
view hashes)
Built Distribution
Close
Hashes for py_style_flattener-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6befd50348810d3536c398ce28b71c7eb6e5363f12aa6453b1b969f82fbe9d81 |
|
MD5 | 83e7d57fa5497e96c4fdb856616b3b72 |
|
BLAKE2b-256 | fb5ccb360f2e6f6480e2b4fc9dad0431c22903b5419dbaa4c4f3f54a2c2cd89f |