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 = ( - '

String Theory

\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].

\n' - '

References

\n' - '
\n' - '
\n' - '
[1]' - '
A. Mann,' - " What Is String Theory?" - " Mar. 20, 2019. [Online]." - ' Available: ' - "https://www.livescience.com/" - "65033-what-is-string-theory.html." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[2]
' - '
' - "C. Wood, What Is String Theory?." - " Reference article:" - " A simplified explanation and brief history of string" - " theory,” Jul. 11, 2019." - ' [Online]. Available: ' - "https://www.space.com/17594-string-theory.html." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[3]' - '
' - 'A. Z. Jones, The Basics of String' - " Theory,” Mar. 02, 2019. [Online]. Available:" - ' ' - "https://www.thoughtco.com/what-is-string-theory-2699363." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[4]' - '
' - "E. Siegel, Why String Theory Is Not A Scientific" - " Theory,” Dec. 23, 2015. [Online]. Available:" - " https://www.forbes.com/' - "sites/startswithabang/2015/12/23/" - "why-string-theory-is-not-science/." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[5]' - '
' - 'D. Castelvecchi, ' - "Feuding physicists turn" - " to philosophy for help. String theory is at the" - " heart of a debate over the integrity of the scientific" - " method itself,” Jan. 05, 2016. [Online]. Available:" - ' ' - "https://www.nature.com/news/" - "feuding-physicists-turn-to-philosophy-for-help-1.19076." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[6]
' - '
' - 'R. A. Batista and J. Primack, ' - "Is String theory falsifiable?. Can a theory that isn’t" - " completely testable still be useful to physics?”" - " [Online]." - ' Available: ' - "https://metafact.io/factchecks/" - "30-is-string-theory-falsifiable." - " [Accessed: Nov. 12, 2020]
\n" - "
\n" - '
\n' - '
[7]' - '
' - 'M. R. Francis, Falsifiability and' - " physics. Can a theory that isn’t completely testable" - " still be useful to physics?” Apr. 23, 2019." - " [Online]. Available:" - ' ' - "https://www.scientificamerican.com/article/is-" - "string-theory-science/. [Accessed: Nov. 12, 2020]
\n" - "
\n" - "
" +HTML_WITH_CITATIONS = "\n".join( + [ + '

String Theory

', + ( + "

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].

" + ), + '

References

', + '
', + '
', + ( + '
[1]
' + "A. Mann, " + "What Is String Theory? Mar. 20, 2019. " + "Available: " + '' + "https://www.livescience.com/65033-what-is-string-theory.html. " + "[Accessed: Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[2]
' + "C. Wood, What Is String Theory?. Reference article: " + "A simplified explanation and brief history of string theory,” " + 'Jul. 11, 2019. Available: https://www.space.com/17594-string-theory.html. ' + "[Accessed: Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[3]
' + 'A. Z. Jones, The Basics of String Theory' + "," + '” Mar. 02, 2019. Available: https://www.thoughtco.com/' + "what-is-string-theory-2699363. [Accessed: Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[4]
' + "E. Siegel, " + "Why String Theory Is Not A Scientific Theory,” " + "Dec. " + '23, 2015. Available: https://www.forbes.com' + "/sites/" + "startswithabang/2015/12/23/why-string-theory-is-not-science/. " + "[Accessed: " + "Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[5]
D. ' + 'Castelvecchi, Feuding physicists turn to ' + "philosophy " + "for help. String theory is at the heart of a debate over the " + "integrity of " + "the scientific method itself,” Jan. 05, 2016. Available: " + 'https://www.nature.com/news/feuding-physicists-turn-to-' + "philosophy-" + "for-help-1.19076. [Accessed: Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[6]
R. ' + 'A. Batista and J. Primack, Is String theory ' + "falsifiable?. Can a theory that isn’t completely testable still be " + "useful " + 'to physics?” Available: https://metafact.io/factchecks/30-is-string-' + "theory-" + "falsifiable. [Accessed: Nov. 12, 2020]
" + ), + "
", + '
', + ( + '
[7]
' + "M. R. " + 'Francis, Falsifiability and physics. ' + "Can a theory that isn’t completely testable still be useful to physics?”" + " " + 'Apr. 23, 2019. Available: https://www.scientificamerican.com/article/' + "is-string-" + "theory-science/. [Accessed: Nov. 12, 2020]
" + ), + "
", + "
", + ] ) HTML_CITATION_TOC = ( diff --git a/pyproject.toml b/pyproject.toml index 6da3eff..2b06aa5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ "Issue Tracker" = "https://github.com/pelican-plugins/pandoc-reader/issues" [tool.poetry.dependencies] -python = ">=3.6.2,<4.0" +python = ">=3.8.1,<4.0" pelican = ">=4.5" markdown = {version = "<=3.3.4", optional = true} markdown-word-count = "^0.0.1" @@ -37,11 +37,11 @@ beautifulsoup4 = "^4.9.3" "ruamel.yaml" = "^0.17.21" [tool.poetry.dev-dependencies] -black = {version = "*", allow-prereleases = true} +black = "^23" flake8 = "^4.0.1" flake8-black = "^0.2.0" -invoke = "^1.3" -isort = "^5.4" +invoke = "^2.0" +isort = "^5.12.0" livereload = "^2.6" markdown = "<=3.3.4" pytest = "^6.0" @@ -56,7 +56,7 @@ markdown = ["markdown"] [tool.autopub] project-name = "Pandoc Reader" git-username = "botpub" -git-email = "botpub@autopub.rocks" +git-email = "52496925+botpub@users.noreply.github.com" append-github-contributor = true [tool.isort]