mirror of
https://codeberg.org/privacy1st/image-width-limit
synced 2024-12-03 22:15:02 +01:00
v1.0.1; update PKGBUILD (license); improve doc
This commit is contained in:
parent
47936cb009
commit
b0d40427a7
3
.idea/image-width-limit.iml
generated
3
.idea/image-width-limit.iml
generated
@ -3,9 +3,8 @@
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/pkg" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (venv-310)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (venv39-2)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (venv-310)" project-jdk-type="Python SDK" />
|
||||
</project>
|
6
PKGBUILD
6
PKGBUILD
@ -3,11 +3,11 @@ _pkgname=image-width-limit
|
||||
_reponame=arch
|
||||
|
||||
pkgname="de-p1st-$_pkgname"
|
||||
pkgver=1.0.0
|
||||
pkgver=1.0.1
|
||||
pkgrel=0
|
||||
pkgdesc="Script to limit HTML image width"
|
||||
pkgdesc="Limit width of HTML images"
|
||||
arch=('any')
|
||||
license=('MIT')
|
||||
license=('CC0')
|
||||
depends=('python3' 'python-beautifulsoup4' 'python-html5lib')
|
||||
source=("${_pkgname}".py)
|
||||
sha256sums=('88b20a75bdfd7f0f0ff6054ff8a6e77783e21488ef3d8ecc5cfadb7fcdf37d6e')
|
||||
|
15
README.md
15
README.md
@ -3,12 +3,13 @@
|
||||
From [image-width-limit.py](image-width-limit.py), function `limit_image_width`:
|
||||
|
||||
> When converting HTML5 to other formats, e.g. PDF, it
|
||||
> may happen that too wide images get cropped of.
|
||||
>
|
||||
may happen that too wide images get cropped of.
|
||||
>
|
||||
> If there are HTML5 image tags which do only contain
|
||||
> the 'src' and 'alt' attribute, then this method adds
|
||||
> a style attribute limiting the image width to each of
|
||||
> those image tags.
|
||||
the 'src' and 'alt' attribute, then this method adds
|
||||
the following style attribute to limit their width:
|
||||
>
|
||||
> max-width:100%;height:auto;
|
||||
|
||||
## Global Installation - Arch Linux
|
||||
|
||||
@ -36,11 +37,11 @@ chmod +x ./image-width-limit.py
|
||||
Global installation:
|
||||
|
||||
```shell
|
||||
de-p1st-image-width-limit example.html modified-example.html
|
||||
de-p1st-image-width-limit example.html example_modified.html
|
||||
```
|
||||
|
||||
Local installation:
|
||||
|
||||
```shell
|
||||
python3 ./image-width-limit.py example.html modified-example.html
|
||||
python3 ./image-width-limit.py example.html example_modified.html
|
||||
```
|
||||
|
@ -42,11 +42,12 @@ def limit_image_width(html_str) -> str:
|
||||
|
||||
If there are HTML5 image tags which do only contain
|
||||
the 'src' and 'alt' attribute, then this method adds
|
||||
a style attribute limiting the image width to each of
|
||||
those image tags.
|
||||
the following style attribute to limit their width:
|
||||
|
||||
:param html_str: HTML5
|
||||
:return: modified HTML5 with max-width attribute added to image tags without size attributes
|
||||
max-width:100%;height:auto;
|
||||
|
||||
:param html_str: source HTML5 string
|
||||
:returns: modified HTML5 with max-width attribute added to all img tags without size attributes
|
||||
"""
|
||||
|
||||
html_parser = 'html5lib'
|
||||
|
Loading…
Reference in New Issue
Block a user