Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d66a471c76
|
|||
|
bbab9de1f6
|
|||
|
d4f27c9ad8
|
|||
|
424ec3621d
|
13
CHANGELOG.md
13
CHANGELOG.md
@@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
Included is a summary of changes to the project, by version. Details can be found in the commit history.
|
Included is a summary of changes to the project, by version. Details can be found in the commit history.
|
||||||
|
|
||||||
|
## v2.0.5
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* The Markdown parser replaces links to e.g. `[Page](page.md)` with a href of `page`, rather than the Markdown source
|
||||||
|
specifying a link of `page` explicitly. This allows for some improved site navigation when browsing the Markdown
|
||||||
|
files, e.g. when going to files in Vim, or browsing a site in a Git web UI.
|
||||||
|
|
||||||
|
### Miscellaneous
|
||||||
|
|
||||||
|
* `tox.ini` also runs tests in a Python 3.13 environment now.
|
||||||
|
* Some trivial bumps to CI requirements.
|
||||||
|
|
||||||
## v2.0.4
|
## v2.0.4
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|||||||
@@ -58,7 +58,18 @@ def parse_md(path: str, pages_root: str):
|
|||||||
with open(absolute_path, 'r') as input_file:
|
with open(absolute_path, 'r') as input_file:
|
||||||
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(input_file.name), tz=datetime.timezone.utc)
|
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(input_file.name), tz=datetime.timezone.utc)
|
||||||
entry = input_file.read()
|
entry = input_file.read()
|
||||||
|
|
||||||
logger.debug("path '%s' read", absolute_path)
|
logger.debug("path '%s' read", absolute_path)
|
||||||
|
|
||||||
|
# remove .md extensions used for navigating in vim and replace them with
|
||||||
|
# the pattern we use for HTML output here
|
||||||
|
# foo/index.md -> foo/, foo/index.md#anchor -> foo/#anchor
|
||||||
|
# ../index.md -> ../, ../index.md#anchor -> ../#anchor
|
||||||
|
entry = re.sub(r'\[([^]]+)\]\(([^)]+)index.md(#[^)]*)?\)', r'[\1](\2\3)', entry)
|
||||||
|
# index.md -> ., index.md#anchor -> .#anchor
|
||||||
|
entry = re.sub(r'\[([^]]+)\]\(index.md(#[^)]*)?\)', r'[\1](.\2)', entry)
|
||||||
|
# bar.md -> bar, foo/bar.md -> foo/bar, bar.md#anchor -> bar#anchor
|
||||||
|
entry = re.sub(r'\[([^]]+)\]\(([^)]+).md(#[^)]*)?\)', r'[\1](\2\3)', entry)
|
||||||
md = init_md()
|
md = init_md()
|
||||||
content = Markup(md.convert(entry)) # nosec B704
|
content = Markup(md.convert(entry)) # nosec B704
|
||||||
except (OSError, FileNotFoundError):
|
except (OSError, FileNotFoundError):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# This file is autogenerated by pip-compile with Python 3.12
|
# This file is autogenerated by pip-compile with Python 3.13
|
||||||
# by the following command:
|
# by the following command:
|
||||||
#
|
#
|
||||||
# pip-compile --extra=dev --output-file=requirements/requirements-dev.txt
|
# pip-compile --extra=dev --output-file=requirements/requirements-dev.txt
|
||||||
@@ -22,7 +22,7 @@ build==1.2.2.post1
|
|||||||
# via pip-tools
|
# via pip-tools
|
||||||
cachetools==5.5.2
|
cachetools==5.5.2
|
||||||
# via tox
|
# via tox
|
||||||
certifi==2025.1.31
|
certifi==2025.8.3
|
||||||
# via requests
|
# via requests
|
||||||
cffi==1.17.1
|
cffi==1.17.1
|
||||||
# via cryptography
|
# via cryptography
|
||||||
@@ -217,9 +217,9 @@ pyyaml==6.0.2
|
|||||||
# via bandit
|
# via bandit
|
||||||
readme-renderer==44.0
|
readme-renderer==44.0
|
||||||
# via twine
|
# via twine
|
||||||
regex==2024.11.6
|
regex==2025.9.1
|
||||||
# via nltk
|
# via nltk
|
||||||
requests==2.32.3
|
requests==2.32.5
|
||||||
# via
|
# via
|
||||||
# id
|
# id
|
||||||
# requests-toolbelt
|
# requests-toolbelt
|
||||||
@@ -240,8 +240,6 @@ ruamel-yaml==0.18.10
|
|||||||
# via
|
# via
|
||||||
# safety
|
# safety
|
||||||
# safety-schemas
|
# safety-schemas
|
||||||
ruamel-yaml-clib==0.2.12
|
|
||||||
# via ruamel-yaml
|
|
||||||
safety==3.3.1
|
safety==3.3.1
|
||||||
# via incorporeal-cms (pyproject.toml)
|
# via incorporeal-cms (pyproject.toml)
|
||||||
safety-schemas==0.0.11
|
safety-schemas==0.0.11
|
||||||
@@ -278,7 +276,7 @@ typing-extensions==4.12.2
|
|||||||
# safety
|
# safety
|
||||||
# safety-schemas
|
# safety-schemas
|
||||||
# typer
|
# typer
|
||||||
urllib3==2.3.0
|
urllib3==2.5.0
|
||||||
# via
|
# via
|
||||||
# requests
|
# requests
|
||||||
# twine
|
# twine
|
||||||
|
|||||||
6
tests/instance/pages/file-with-index.md-link.md
Normal file
6
tests/instance/pages/file-with-index.md-link.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Cool](cool/index.md)
|
||||||
|
[Anchored Cool](cool/index.md#anchor)
|
||||||
|
[This Index](index.md)
|
||||||
|
[Anchored This Index](index.md#anchor)
|
||||||
|
[Parent](../index.md)
|
||||||
|
[Anchored Parent](../index.md#anchor)
|
||||||
4
tests/instance/pages/file-with-md-link.md
Normal file
4
tests/instance/pages/file-with-md-link.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Foo](foo.md)
|
||||||
|
[Anchored Foo](foo.md#anchor)
|
||||||
|
[Sub Foo](sub/foo.md)
|
||||||
|
[Anchored Sub Foo](sub/foo.md#anchor)
|
||||||
@@ -163,3 +163,23 @@ def test_parse_md_bad_file():
|
|||||||
"""Test the direct results of parsing a markdown file."""
|
"""Test the direct results of parsing a markdown file."""
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'actually-a-png.md'), PAGES_DIR)
|
content, md, page_name, page_title, mtime = parse_md(os.path.join(PAGES_DIR, 'actually-a-png.md'), PAGES_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
def test_md_extension_in_source_link_is_stripped():
|
||||||
|
"""Test that if a foo.md file link is specified in the Markdown, it is foo in the HTML."""
|
||||||
|
content, _, _, _, _ = parse_md(os.path.join(PAGES_DIR, 'file-with-md-link.md'), PAGES_DIR)
|
||||||
|
assert '<a href="foo">Foo</a>' in content
|
||||||
|
assert '<a href="foo#anchor">Anchored Foo</a>' in content
|
||||||
|
assert '<a href="sub/foo">Sub Foo</a>' in content
|
||||||
|
assert '<a href="sub/foo#anchor">Anchored Sub Foo</a>' in content
|
||||||
|
|
||||||
|
|
||||||
|
def test_index_in_source_link_is_stripped():
|
||||||
|
"""Test that if a index.md file link is specified in the Markdown, it is just the dir in the HTML."""
|
||||||
|
content, _, _, _, _ = parse_md(os.path.join(PAGES_DIR, 'file-with-index.md-link.md'), PAGES_DIR)
|
||||||
|
assert '<a href="cool/">Cool</a>' in content
|
||||||
|
assert '<a href="cool/#anchor">Anchored Cool</a>' in content
|
||||||
|
assert '<a href=".">This Index</a>' in content
|
||||||
|
assert '<a href=".#anchor">Anchored This Index</a>' in content
|
||||||
|
assert '<a href="../">Parent</a>' in content
|
||||||
|
assert '<a href="../#anchor">Anchored Parent</a>' in content
|
||||||
|
|||||||
7
tox.ini
7
tox.ini
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[tox]
|
[tox]
|
||||||
isolated_build = true
|
isolated_build = true
|
||||||
envlist = begin,py39,py310,py311,py312,coverage,security,lint,reuse
|
envlist = begin,py39,py310,py311,py312,py313,coverage,security,lint,reuse
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
allow_externals = pytest, coverage
|
allow_externals = pytest, coverage
|
||||||
@@ -41,6 +41,11 @@ commands =
|
|||||||
commands =
|
commands =
|
||||||
pytest --cov-append --cov={envsitepackagesdir}/incorporealcms/ --cov-branch
|
pytest --cov-append --cov={envsitepackagesdir}/incorporealcms/ --cov-branch
|
||||||
|
|
||||||
|
[testenv:py313]
|
||||||
|
# run pytest with coverage
|
||||||
|
commands =
|
||||||
|
pytest --cov-append --cov={envsitepackagesdir}/incorporealcms/ --cov-branch
|
||||||
|
|
||||||
[testenv:coverage]
|
[testenv:coverage]
|
||||||
# report on coverage runs from above
|
# report on coverage runs from above
|
||||||
skip_install = true
|
skip_install = true
|
||||||
|
|||||||
Reference in New Issue
Block a user