Skip to content

Commit

Permalink
Merge branch 'release/1.0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
chdemko committed Aug 4, 2024
2 parents 6f4c2cd + 8476299 commit 6ff65bc
Show file tree
Hide file tree
Showing 12 changed files with 858 additions and 667 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
poetry-version: [1.7.1]
pandoc-version: [3.1.11.1]
poetry-version: [1.8.3]
pandoc-version: ['3.3']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -41,8 +41,8 @@ jobs:
strategy:
matrix:
python-version: ['3.12']
poetry-version: [1.2.2, 1.3.2, 1.4.2, 1.5.1, 1.6.1, 1.7.1]
pandoc-version: [3.1.11.1]
poetry-version: [1.2.2, 1.3.2, 1.4.2, 1.5.1, 1.6.1, 1.7.1, 1.8.3]
pandoc-version: ['3.3']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -67,8 +67,8 @@ jobs:
strategy:
matrix:
python-version: ['3.12']
poetry-version: [1.7.1]
pandoc-version: [2.11.4, '2.12', '2.13', 2.14.2, '2.15', 2.16.2, 2.17.1.1, '2.18', 2.19.2, 3.0.1, 3.1.11.1]
poetry-version: [1.8.3]
pandoc-version: [2.11.4, '2.12', '2.13', 2.14.2, '2.15', 2.16.2, 2.17.1.1, '2.18', 2.19.2, 3.0.1, 3.1.13, 3.2.1, '3.3']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.7.1
poetry-version: 1.8.3
- name: Install dependencies
run: |
poetry install
Expand All @@ -119,11 +119,11 @@ jobs:
- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.7.1
poetry-version: 1.8.3
- name: Install dependencies
run: |
wget https://github.com/jgm/pandoc/releases/download/3.1.11.1/pandoc-3.1.11.1-1-amd64.deb
sudo dpkg -i ./pandoc-3.1.11.1-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-1-amd64.deb
sudo dpkg -i ./pandoc-3.3-1-amd64.deb
poetry install
- name: Test
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.7.1
poetry-version: 1.8.3
- name: Set up poetry-dynamic-versioning
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
Expand Down
35 changes: 20 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -11,7 +11,7 @@ repos:
- id: check-poetry

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.10.0
rev: v2.14.0
hooks:
- id: pretty-format-toml
exclude: ^poetry.lock$
Expand All @@ -25,14 +25,14 @@ repos:
- id: tox-ini-fmt

- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.17.0
rev: v0.19.0
hooks:
- id: slotscheck
language: system
exclude: ^(?!pandoc_latex_newpage.py)
exclude: ^(?!pandoc_latex_newpage/)

- repo: https://github.com/dosisod/refurb
rev: v1.20.0
rev: v2.0.0
hooks:
- id: refurb

Expand All @@ -42,41 +42,46 @@ repos:
- id: teyit

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.5.6
hooks:
- id: ruff
language: system
exclude: ^(?!pandoc_latex_newpage.py)
exclude: ^(?!pandoc_latex_newpage/)

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.8.0
hooks:
- id: black-jupyter
args: [--config=pyproject.toml, pandoc_latex_newpage.py, tests]
args: [--config=pyproject.toml, pandoc_latex_newpage/, tests]

- repo: https://github.com/PyCQA/doc8/
rev: v1.1.1
hooks:
- id: doc8
args: [docs]
args: [docs, README.md, -e, .rst, -e, .md]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.11.1
hooks:
- id: mypy
language: system
exclude: ^(?!pandoc_latex_newpage.py)
exclude: ^(?!pandoc_latex_newpage/)

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.1.0
hooks:
- id: flake8
language: system
exclude: ^(?!pandoc_latex_newpage.py)
exclude: ^(?!pandoc_latex_newpage/)

- repo: https://github.com/pre-commit/mirrors-pylint
rev: v3.0.0a5
hooks:
- id: pylint
language: system
exclude: ^(?!pandoc_latex_newpage.py)
exclude: ^(?!pandoc_latex_newpage/)

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ build:
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- poetry install --with docs
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs

# Build documentation in the "docs/" directory with Sphinx
sphinx:
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ Installation
[![Code Size](https://img.shields.io/github/languages/code-size/chdemko/pandoc-latex-newpage.svg?logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gVXBsb2FkZWQgdG86IFNWRyBSZXBvLCB3d3cuc3ZncmVwby5jb20sIEdlbmV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c+Cg==)](http://pandoc-latex-newpage.readthedocs.io/en/latest/)
[![Source Rank](https://img.shields.io/librariesio/sourcerank/pypi/pandoc-latex-newpage.svg?logo=libraries.io&logoColor=white)](https://libraries.io/pypi/pandoc-latex-newpage)

*pandoc-latex-newpage* is a [pandoc] filter for converting horizontal rule to new page in *LaTeX*.
*pandoc-latex-newpage* is a [pandoc] filter for converting horizontal
rule to new page in *LaTeX*.

[pandoc]: http://pandoc.org/

Instructions
------------

*pandoc-latex-newpage* requires [python], a programming language that comes pre-installed on linux and Mac OS X, and which is easily installed [on Windows]
*pandoc-latex-newpage* requires [python], a programming language that comes
pre-installed on linux and Mac OS X, and which is easily installed
[on Windows]

Install *pandoc-latex-newpage* using the bash command

Expand All @@ -45,7 +48,9 @@ To upgrade to the most recent release, use
$ pipx upgrade pandoc-latex-newpage
~~~

`pipx` is a script to install and run python applications in isolated environments from the Python Package Index, [PyPI]. It can be installed using instructions given [here](https://pipx.pypa.io/stable/).
`pipx` is a script to install and run python applications in isolated
environments from the Python Package Index, [PyPI]. It can be installed
using instructions given [here](https://pipx.pypa.io/stable/).

[python]: https://www.python.org
[on Windows]: https://www.python.org/downloads/windows
Expand All @@ -55,7 +60,8 @@ $ pipx upgrade pandoc-latex-newpage
Getting Help
------------

If you have any difficulties with *pandoc-latex-newpage*, please feel welcome to [file an issue] on github so that we can help.
If you have any difficulties with *pandoc-latex-newpage*, please feel
welcome to [file an issue] on github so that we can help.

[file an issue]: https://github.com/chdemko/pandoc-latex-newpage/issues

Expand Down
3 changes: 2 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ All horizontal rules will be replaced by a new page
Example
-------

Demonstration: Using [pandoc-latex-newpage-sample.txt] as input gives output file in [pdf].
Demonstration: Using [pandoc-latex-newpage-sample.txt] as input gives output
file in [pdf].

[pandoc-latex-newpage-sample.txt]: https://raw.githubusercontent.com/chdemko/pandoc-latex-newpage/develop/docs/images/pandoc-latex-newpage-sample.txt
[pdf]: https://raw.githubusercontent.com/chdemko/pandoc-latex-newpage/develop/docs/images/pandoc-latex-newpage-sample.pdf
10 changes: 10 additions & 0 deletions pandoc_latex_newpage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
pandoc_latex_newpage package.
"""

from ._main import main

__all__ = ("main",)

if __name__ == "__main__":
main()
11 changes: 8 additions & 3 deletions pandoc_latex_newpage.py → pandoc_latex_newpage/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"""
Pandoc filter for converting horizontal rule to new page in LaTeX.
"""
from __future__ import annotations

from panflute import (
Doc,
Element,
HorizontalRule,
MetaBool,
MetaMap,
Expand All @@ -13,7 +16,7 @@
)


def newpage(elem, doc):
def newpage(elem: Element, doc: Doc) -> RawBlock | None:
r"""
Replace HorizontalRule by a \clearpage or a \cleardoublepage.
Expand All @@ -26,6 +29,7 @@ def newpage(elem, doc):
Returns
-------
RawBlock | None
A RawBlock or None.
"""
# Is it in the right format and is it an HorizontalRule?
Expand All @@ -36,7 +40,7 @@ def newpage(elem, doc):
return None


def prepare(doc):
def prepare(doc: Doc) -> None:
"""
Prepare document.
Expand All @@ -56,7 +60,7 @@ def prepare(doc):
doc.double = doc.metadata.content["pandoc-latex-newpage"]["double"].boolean


def main(doc=None):
def main(doc: Doc | None = None) -> Doc:
"""
Convert the pandoc document.
Expand All @@ -67,6 +71,7 @@ def main(doc=None):
Returns
-------
Doc
The modified document.
"""
return run_filter(newpage, prepare=prepare, doc=doc)
Expand Down
Loading

0 comments on commit 6ff65bc

Please sign in to comment.