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">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/pkg" />
|
<excludeFolder url="file://$MODULE_DIR$/pkg" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/src" />
|
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.10 (venv-310)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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>
|
</project>
|
6
PKGBUILD
6
PKGBUILD
@ -3,11 +3,11 @@ _pkgname=image-width-limit
|
|||||||
_reponame=arch
|
_reponame=arch
|
||||||
|
|
||||||
pkgname="de-p1st-$_pkgname"
|
pkgname="de-p1st-$_pkgname"
|
||||||
pkgver=1.0.0
|
pkgver=1.0.1
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc="Script to limit HTML image width"
|
pkgdesc="Limit width of HTML images"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
license=('MIT')
|
license=('CC0')
|
||||||
depends=('python3' 'python-beautifulsoup4' 'python-html5lib')
|
depends=('python3' 'python-beautifulsoup4' 'python-html5lib')
|
||||||
source=("${_pkgname}".py)
|
source=("${_pkgname}".py)
|
||||||
sha256sums=('88b20a75bdfd7f0f0ff6054ff8a6e77783e21488ef3d8ecc5cfadb7fcdf37d6e')
|
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`:
|
From [image-width-limit.py](image-width-limit.py), function `limit_image_width`:
|
||||||
|
|
||||||
> When converting HTML5 to other formats, e.g. PDF, it
|
> 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
|
> If there are HTML5 image tags which do only contain
|
||||||
> the 'src' and 'alt' attribute, then this method adds
|
the 'src' and 'alt' attribute, then this method adds
|
||||||
> a style attribute limiting the image width to each of
|
the following style attribute to limit their width:
|
||||||
> those image tags.
|
>
|
||||||
|
> max-width:100%;height:auto;
|
||||||
|
|
||||||
## Global Installation - Arch Linux
|
## Global Installation - Arch Linux
|
||||||
|
|
||||||
@ -36,11 +37,11 @@ chmod +x ./image-width-limit.py
|
|||||||
Global installation:
|
Global installation:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
de-p1st-image-width-limit example.html modified-example.html
|
de-p1st-image-width-limit example.html example_modified.html
|
||||||
```
|
```
|
||||||
|
|
||||||
Local installation:
|
Local installation:
|
||||||
|
|
||||||
```shell
|
```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
|
If there are HTML5 image tags which do only contain
|
||||||
the 'src' and 'alt' attribute, then this method adds
|
the 'src' and 'alt' attribute, then this method adds
|
||||||
a style attribute limiting the image width to each of
|
the following style attribute to limit their width:
|
||||||
those image tags.
|
|
||||||
|
|
||||||
:param html_str: HTML5
|
max-width:100%;height:auto;
|
||||||
:return: modified HTML5 with max-width attribute added to image tags without size attributes
|
|
||||||
|
:param html_str: source HTML5 string
|
||||||
|
:returns: modified HTML5 with max-width attribute added to all img tags without size attributes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
html_parser = 'html5lib'
|
html_parser = 'html5lib'
|
||||||
|
Loading…
Reference in New Issue
Block a user