From b0d40427a7f337b5a858446899ee80b9441377a7 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Tue, 8 Mar 2022 12:43:55 +0100 Subject: [PATCH] v1.0.1; update PKGBUILD (license); improve doc --- .idea/image-width-limit.iml | 3 +-- .idea/misc.xml | 2 +- PKGBUILD | 6 +++--- README.md | 15 ++++++++------- image-width-limit.py | 9 +++++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.idea/image-width-limit.iml b/.idea/image-width-limit.iml index 849a2f3..ddff999 100644 --- a/.idea/image-width-limit.iml +++ b/.idea/image-width-limit.iml @@ -3,9 +3,8 @@ - - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 14fc843..7174e2d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/PKGBUILD b/PKGBUILD index 2cab21b..bdf0d14 100644 --- a/PKGBUILD +++ b/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') diff --git a/README.md b/README.md index 9fb85b3..c255765 100644 --- a/README.md +++ b/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 ``` diff --git a/image-width-limit.py b/image-width-limit.py index 529393d..47b8031 100644 --- a/image-width-limit.py +++ b/image-width-limit.py @@ -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'