diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee7bc07..73ee0a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 @@ -40,10 +40,10 @@ jobs: run: | poetry run pip install --upgrade pip poetry install - - name: Install supported pandoc 2.19 + - name: Install supported pandoc 3.14 run: | - wget https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb - sudo dpkg -i pandoc-2.19.2-1-amd64.deb + wget https://github.com/jgm/pandoc/releases/download/3.1.4/pandoc-3.1.4-1-amd64.deb + sudo dpkg -i pandoc-3.1.4-1-amd64.deb - name: Install unsupported pandoc 2.10 run: | wget https://github.com/jgm/pandoc/releases/download/2.10.1/pandoc-2.10.1-linux-amd64.tar.gz @@ -63,51 +63,54 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Validate links in Markdown files uses: JustinBeckwith/linkinator-action@v1 with: retry: true + - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: "3.9" + - name: Set Poetry cache uses: actions/cache@v2 id: poetry-cache with: path: ~/.cache/pypoetry/virtualenvs key: poetry-${{ hashFiles('**/poetry.lock') }} - - name: Upgrade Pip - run: python -m pip install --upgrade pip + - name: Install Poetry run: python -m pip install poetry + - name: Install dependencies - run: | - poetry run pip install --upgrade pip - poetry install - - name: Run linters - run: poetry run invoke lint + run: poetry install --no-interaction + - name: Run linters + run: poetry run invoke lint --diff deploy: name: Deploy needs: [test, lint] runs-on: ubuntu-latest - if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }} + if: github.ref=='refs/heads/main' && github.event_name!='pull_request' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: "3.9" + - name: Check release id: check_release run: | python -m pip install --upgrade pip - python -m pip install poetry githubrelease httpx==0.16.1 autopub - echo "##[set-output name=release;]$(autopub check)" + python -m pip install poetry githubrelease httpx==0.18.2 autopub + echo "release=$(autopub check)" >> $GITHUB_OUTPUT - name: Publish if: ${{ steps.check_release.outputs.release=='' }} env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 753aec9..d62c83b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,7 @@ --- +ci: + autoupdate_schedule: quarterly + # See https://pre-commit.com/hooks.html for info on hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -7,6 +10,7 @@ repos: - id: check-added-large-files - id: check-ast - id: check-case-conflict + - id: check-docstring-first - id: check-merge-conflict - id: check-toml - id: check-yaml @@ -26,9 +30,20 @@ repos: hooks: - id: flake8 args: [--max-line-length=88] - language_version: python3 - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort + + - repo: https://github.com/asottile/pyupgrade + rev: v3.8.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + + - repo: https://github.com/hakancelikdev/unimport + rev: 0.16.0 + hooks: + - id: unimport + args: [--remove, --include-star-import] diff --git a/README.md b/README.md index 3175968..985cb82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Pandoc Reader: A Plugin for Pelican =================================== -[![Build Status](https://img.shields.io/github/workflow/status/pelican-plugins/pandoc-reader/build)](https://github.com/pelican-plugins/pandoc-reader/actions) +[![Build Status](https://img.shields.io/github/actions/workflow/status/pelican-plugins/pandoc-reader/main.yml?branch=main)](https://github.com/pelican-plugins/pandoc-reader/actions) [![PyPI Version](https://img.shields.io/pypi/v/pelican-pandoc-reader)](https://pypi.org/project/pelican-pandoc-reader/) ![License](https://img.shields.io/pypi/l/pelican-pandoc-reader?color=blue) diff --git a/pelican/plugins/pandoc_reader/pandoc_reader.py b/pelican/plugins/pandoc_reader/pandoc_reader.py index 877c48f..61f90f0 100644 --- a/pelican/plugins/pandoc_reader/pandoc_reader.py +++ b/pelican/plugins/pandoc_reader/pandoc_reader.py @@ -110,7 +110,7 @@ def _create_html(self, source_path, content, pandoc_executable): # Find and add bibliography if citations are specified if citations: for bib_file in self._find_bibs(source_path): - pandoc_cmd.append("--bibliography={0}".format(bib_file)) + pandoc_cmd.append(f"--bibliography={bib_file}") # Create HTML content using pandoc-reader-default.html template output = self._run_pandoc(pandoc_cmd, content) @@ -166,7 +166,7 @@ def _check_defaults(self, defaults_files): # Get the data in all defaults files as a string defaults_data = "" for defaults_file in defaults_files: - with open(defaults_file, "r") as file_handle: + with open(defaults_file) as file_handle: for line in file_handle.readlines(): defaults_data += line @@ -216,7 +216,7 @@ def _calculate_reading_time(self, content): reading_time = math.ceil(float(wordcount) / float(reading_speed)) if reading_time == 1: time_unit = "minute" - reading_time = "{} {}".format(str(reading_time), time_unit) + reading_time = f"{str(reading_time)} {time_unit}" except ValueError as words_per_minute_nan: raise ValueError( "READING_SPEED setting must be a number." @@ -307,7 +307,7 @@ def _construct_pandoc_command( pandoc_cmd.extend(arguments) else: for defaults_file in defaults_files: - pandoc_cmd.append("--defaults={0}".format(defaults_file)) + pandoc_cmd.append(f"--defaults={defaults_file}") return pandoc_cmd @staticmethod @@ -398,7 +398,7 @@ def _check_arguments(arguments): """Check to see that only supported arguments have been passed.""" for arg in arguments: if arg in UNSUPPORTED_ARGUMENTS: - raise ValueError("Argument {0} is not supported.".format(arg)) + raise ValueError(f"Argument {arg} is not supported.") @staticmethod def _check_if_unsupported_settings(defaults): @@ -406,7 +406,7 @@ def _check_if_unsupported_settings(defaults): for arg in UNSUPPORTED_ARGUMENTS: arg = arg[2:] if defaults.get(arg, ""): - raise ValueError("The default {} should be set to false.".format(arg)) + raise ValueError(f"The default {arg} should be set to false.") @staticmethod def _check_input_format(defaults): @@ -422,10 +422,8 @@ def _check_input_format(defaults): # Case where both reader and from are specified which is not supported if reader_input and from_input: raise ValueError( - ( - "Specifying both from and reader is not supported." - " Please specify just one." - ) + "Specifying both from and reader is not supported." + " Please specify just one." ) if reader_input or from_input: @@ -450,10 +448,8 @@ def _check_output_format(defaults): # Case where both writer and to are specified which is not supported if writer_output and to_output: raise ValueError( - ( - "Specifying both to and writer is not supported." - " Please specify just one." - ) + "Specifying both to and writer is not supported." + " Please specify just one." ) # Case where neither writer nor to value is set to html @@ -462,9 +458,7 @@ def _check_output_format(defaults): and to_output not in VALID_OUTPUT_FORMATS ): output_formats = " or ".join(VALID_OUTPUT_FORMATS) - raise ValueError( - "Output format type must be either {}.".format(output_formats) - ) + raise ValueError(f"Output format type must be either {output_formats}.") def add_reader(readers): diff --git a/pelican/plugins/pandoc_reader/test/html/expected_html.py b/pelican/plugins/pandoc_reader/test/html/expected_html.py index 160b33f..6120469 100644 --- a/pelican/plugins/pandoc_reader/test/html/expected_html.py +++ b/pelican/plugins/pandoc_reader/test/html/expected_html.py @@ -1,117 +1,115 @@ """Expected HTML output for various types of text.""" -HTML_WITH_CITATIONS = ( - '
But this foundational principle of science has" - " now been called into question by" - ' String Theory,' - " which is a relative newcomer to theoretical physics, but one" - " that has captured the common imagination, judging by" - " the popular explanations that abound on the Web" - ' [1]–[3].' - " And whether string theory is or is not science, Popper" - " notwithstanding, is an issue that is still up for debate" - " [4]–[7].
\n' - 'But this foundational principle of science has now " + "been called into question by " + '' + "String Theory, " + "which is a relative newcomer to theoretical physics, but one that has " + "captured the common imagination, judging by the popular explanations " + "that abound on the Web " + '[1]–[3]' + ". And whether string theory is or is not science, Popper " + "notwithstanding, is an issue that is still up for debate " + '' + "[4]–[7].
" + ), + '