Skip to content

Commit 384bbc6

Browse files
authored
Upgrade to latest (#135)
* Delete deprecated travis-ci * Modernize and bringing it back to life
1 parent 5eeb34f commit 384bbc6

File tree

13 files changed

+404
-261
lines changed

13 files changed

+404
-261
lines changed

.github/workflows/main.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the master branch
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
code-quality:
16+
runs-on: ubuntu-latest
17+
18+
name: "Linting"
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: setup python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.13'
28+
29+
- name: Install dependencies
30+
run: make install
31+
32+
- name: Linting
33+
run: make lint
34+
35+
test:
36+
# The type of runner that the job will run on
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
name: "Python ${{ matrix.python-version }}"
44+
45+
steps:
46+
- name: Check out code
47+
uses: actions/checkout@v4
48+
49+
- name: Set up Python ${{ matrix.python-version }}
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
54+
- name: Install dependencies
55+
run: make install
56+
57+
- name: Run tests
58+
run: make coverage
59+
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v5
62+
with:
63+
flags: unittests-${{ matrix.python-version }}
64+
fail_ci_if_error: true # default = false
65+
verbose: true # default = false

.github/workflows/pypi.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
environment:
11+
name: pypi
12+
url: https://pypi.org/project/django-markwhat
13+
permissions:
14+
id-token: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.13'
23+
24+
- name: Build
25+
run: |
26+
python -m pip install build
27+
python -m build
28+
29+
- name: Publish package distributions to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
verbose: true
33+
print-hash: true

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# IDE specific
22
.idea/
33
.ropeproject/
4+
.vscode/
45
# file
56
manage.py
67
dump.json
@@ -37,6 +38,7 @@ var/
3738
*.egg-info/
3839
.installed.cfg
3940
*.egg
41+
django_markwhat/_version.py
4042

4143
# PyInstaller
4244
# Usually these files are written by a python script from a template
@@ -70,6 +72,3 @@ docs/_build/
7072

7173
# PyBuilder
7274
target/
73-
74-
# virtualenv
75-
ve/

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

ChangeLog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2025.5.31
2+
=========
3+
----
4+
5+
* Upgrade all the dependecies to latest version.
6+
* Modernize the build and development tooling process.
7+
8+
19
1.6.2 2019-08-30
210
================
311
----

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: install test build release clean
2+
3+
install:
4+
pip install '.[dev]'
5+
6+
test:
7+
python run_tests.py
8+
9+
coverage:
10+
coverage run run_tests.py
11+
coverage report
12+
coverage xml
13+
14+
build:
15+
python -m build
16+
17+
clean:
18+
rm -rf dist *.egg-info coverage.xml build
19+
20+
lint:
21+
ruff format
22+
ruff check . --fix
23+
mypy . --install-types --non-interactive --exclude build

django_markwhat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
"""Django Markwhat."""
2-
__version__ = (1, 6, 2)
Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
22
Set of "markup" template filters for Django.
3+
34
These filters transform plain text
45
markup syntaxes to HTML; currently there is support for:
56
@@ -16,29 +17,31 @@
1617

1718
from django import template
1819
from django.conf import settings
19-
from django.utils.encoding import force_str
20+
from django.utils.encoding import force_str, smart_str
2021
from django.utils.safestring import mark_safe
2122

2223
register = template.Library()
2324

2425

2526
@register.filter(is_safe=True)
26-
def textile(value):
27+
def textile(value: str) -> str:
2728
"""
28-
:type value: str
29+
Runs textile over a given value.
30+
31+
Syntax::
2932
30-
:rtype: str
33+
{{ value|textile }}
3134
"""
32-
import textile
35+
import textile # type: ignore[import-untyped]
3336

34-
return mark_safe(force_str(
35-
textile.textile(smart_str(value)))
36-
)
37+
return mark_safe(force_str(textile.textile(smart_str(value))))
3738

3839

3940
@register.filter(is_safe=True)
40-
def markdown(value, args=''):
41+
def markdown(value: str, args: str = "") -> str:
4142
"""
43+
Markdown Template tag.
44+
4245
Runs Markdown over a given value, optionally using various
4346
extensions python-markdown supports.
4447
@@ -52,68 +55,45 @@ def markdown(value, args=''):
5255
5356
If the version of Markdown in use does not support extensions,
5457
they will be silently ignored.
55-
56-
:type value: str
57-
:type args: str
58-
59-
:rtype: str
6058
"""
6159
import markdown
6260

63-
extensions = [e for e in args.split(',') if e]
61+
extensions = [e for e in args.split(",") if e]
6462
if len(extensions) > 0 and extensions[0] == "safe":
6563
extensions = extensions[1:]
66-
safe_mode = True
67-
else:
68-
safe_mode = False
6964

70-
return mark_safe(markdown.markdown(
71-
force_str(value),
72-
extensions=extensions,
73-
safe_mode=safe_mode,
74-
enable_attributes=(not safe_mode)
75-
))
65+
return mark_safe(markdown.markdown(force_str(value), extensions=extensions))
7666

7767

7868
@register.filter(is_safe=True)
79-
def commonmark(value):
69+
def commonmark(value: str) -> str:
8070
"""
8171
Runs commonmark over a given value.
8272
8373
Syntax::
8474
8575
{{ value|commonmark }}
86-
87-
:type value: str
88-
89-
:rtype: str
9076
"""
9177
import commonmark
9278

9379
parser = commonmark.Parser()
9480
renderer = commonmark.HtmlRenderer()
9581
ast = parser.parse(force_str(value))
96-
return mark_safe(
97-
force_str(renderer.render(ast))
98-
)
82+
return mark_safe(force_str(renderer.render(ast)))
9983

10084

10185
@register.filter(is_safe=True)
102-
def restructuredtext(value):
86+
def restructuredtext(value: str) -> str:
10387
"""
104-
:type value: str
105-
:rtype: str
88+
Runs restructured text over a given value.
89+
90+
Syntax::
91+
92+
{{ value|restructuredtext }}
10693
"""
94+
""""""
10795
from docutils.core import publish_parts
10896

109-
docutils_settings = getattr(
110-
settings,
111-
"RESTRUCTUREDTEXT_FILTER_SETTINGS",
112-
{}
113-
)
114-
parts = publish_parts(
115-
source=smart_str(value),
116-
writer_name="html4css1",
117-
settings_overrides=docutils_settings
118-
)
97+
docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
98+
parts = publish_parts(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings)
11999
return mark_safe(force_str(parts["fragment"]))

0 commit comments

Comments
 (0)