diff --git a/.cruft.json b/.cruft.json index 76d0e2f..02a2df8 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/getpelican/cookiecutter-pelican-plugin", - "commit": "94970ab900aed538f451686a2eb51188dbfd1a28", + "commit": "d683335f82b19e1ed2c92abf4aa6d07678e5d273", "checkout": null, "context": { "cookiecutter": { @@ -18,9 +18,10 @@ "repo_url": "https://github.com/pelican-plugins/minify", "dev_status": "5 - Production/Stable", "tests_exist": true, - "python_version": ">=3.8.1,<4.0", + "python_version": ">=3.10", "pelican_version": ">=4.5", - "_template": "https://github.com/getpelican/cookiecutter-pelican-plugin" + "_template": "https://github.com/getpelican/cookiecutter-pelican-plugin", + "_commit": "d683335f82b19e1ed2c92abf4aa6d07678e5d273" } }, "directory": null diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9a2dc0..a387288 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,10 +14,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} & PDM uses: pdm-project/setup-pdm@v4 @@ -37,7 +39,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 + with: + persist-credentials: false - name: Validate links in Markdown files uses: JustinBeckwith/linkinator-action@v1 @@ -48,7 +52,7 @@ jobs: - name: Set up Python & PDM uses: pdm-project/setup-pdm@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Install dependencies run: pdm install @@ -68,18 +72,17 @@ jobs: id-token: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: "3.10" + python-version: "3.11" - name: Check release id: check_release run: | - python -m pip install autopub httpx - python -m pip install https://github.com/scikit-build/github-release/archive/master.zip + python -m pip install autopub[github] autopub check - name: Publish diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f1400a..06b0305 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: # See https://pre-commit.com/hooks.html for info on hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-ast @@ -21,8 +21,8 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.1 + rev: v0.14.2 hooks: - - id: ruff + - id: ruff-check - id: ruff-format args: ["--check"] diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..de996da --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,4 @@ +Release type: patch + +- Fix compatibility with minify-html 0.17.1 and newer +- Add Python 3.13 & 3.14 and drop Python 3.8 & 3.9 diff --git a/pelican/plugins/minify/minify.py b/pelican/plugins/minify/minify.py index ee21312..8b8b25d 100644 --- a/pelican/plugins/minify/minify.py +++ b/pelican/plugins/minify/minify.py @@ -1,5 +1,5 @@ from fnmatch import fnmatch -from functools import lru_cache +from functools import cache import logging import os @@ -58,8 +58,6 @@ def __init__(self, pelican): def minify(self, content, minify_css, minify_js): return minify_html.minify( content, - do_not_minify_doctype=True, - keep_spaces_between_attributes=True, minify_css=minify_css, minify_js=minify_js, ) @@ -88,7 +86,7 @@ def write_to_file(path_file, callback): ) from e -@lru_cache(maxsize=None) +@cache def minify_method(method, content): """Wrap the minify method with a cached version. diff --git a/pyproject.toml b/pyproject.toml index 89ece17..ab10166 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ authors = [ {name = "Alexander Herrmann", email = "106409+dArignac@users.noreply.github.com"}, {name = "Justin Mayer", email = "entroP@gmail.com"}, {name = "Ysard", email = "ysard@users.noreply.github.com"}, + {name = "Paolo Melchiorre", email = "paolo@melchiorre.org"}, ] keywords = [ "pelican", @@ -27,36 +28,36 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules", ] -requires-python = ">=3.8.1,<4.0" +requires-python = ">=3.10" dependencies = [ "pelican>=4.5", - "minify_html>=0.10.8", + "minify_html>=0.17.1", ] [project.urls] -Homepage = "https://github.com/pelican-plugins/minify" +"Homepage" = "https://github.com/pelican-plugins/minify" "Issue Tracker" = "https://github.com/pelican-plugins/minify/issues" -Funding = "https://donate.getpelican.com/" +"Changelog" = "https://github.com/pelican-plugins/minify/blob/main/CHANGELOG.md" +"Funding" = "https://donate.getpelican.com/" [project.optional-dependencies] markdown = ["markdown>=3.4"] -[tool.pdm] - -[tool.pdm.dev-dependencies] +[dependency-groups] lint = [ "invoke>=2.2", - "ruff>=0.6.0,<0.7.0", + "ruff>=0.14.2,<1.0.0", ] test = [ + "invoke>=2.2", "markdown>=3.4", "pytest>=7.0", "pytest-cov>=4.0", diff --git a/tasks.py b/tasks.py index e4e3790..8dc99af 100644 --- a/tasks.py +++ b/tasks.py @@ -7,6 +7,11 @@ from invoke import task logger = logging.getLogger(__name__) +level = logging.INFO +logger.setLevel(level) +console_handler = logging.StreamHandler() +console_handler.setLevel(level) +logger.addHandler(console_handler) PKG_NAME = "minify" PKG_PATH = Path(f"pelican/plugins/{PKG_NAME}") @@ -47,20 +52,22 @@ def format(c, check=False, diff=False): @task -def ruff(c, fix=False, diff=False): +def ruff(c, concise=False, fix=False, diff=False): """Run Ruff to ensure code meets project standards.""" - diff_flag, fix_flag = "", "" + concise_flag, fix_flag, diff_flag = "", "", "" + if concise: + concise_flag = "--output-format=concise" if fix: fix_flag = "--fix" if diff: diff_flag = "--diff" - c.run(f"{CMD_PREFIX}ruff check {diff_flag} {fix_flag} .", pty=PTY) + c.run(f"{CMD_PREFIX}ruff check {concise_flag} {diff_flag} {fix_flag} .", pty=PTY) @task -def lint(c, fix=False, diff=False): +def lint(c, concise=False, fix=False, diff=False): """Check code style via linting tools.""" - ruff(c, fix=fix, diff=diff) + ruff(c, concise=concise, fix=fix, diff=diff) format(c, check=(not fix), diff=diff)