Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[project]
name = "website-build-tools"
version = "0.1.11"
version = "0.1.12"
description = "tools for building websites, used by defelement.org and quadraturerules.org"
readme = "README.md"
requires-python = ">=3.8.0"
requires-python = ">=3.10.0"
license = { file = "LICENSE" }
authors = [
{ name = "Matthew Scroggs", email = "defelement@mscroggs.co.uk" }
Expand Down
6 changes: 6 additions & 0 deletions test/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ def test_code_highlight_cpp():
assert "<br />&nbsp;&nbsp;&nbsp;&nbsp;" in markup(
"```python\nfor i in range(10):\n print(i)\n```\n",
)


def test_nomd():
assert "[A](B)" not in markup("[A](B)<nomd>[C](D)</nomd>[E](F)")
assert "[C](D)" in markup("[A](B)<nomd>[C](D)</nomd>[E](F)")
assert "[E](F)" not in markup("[A](B)<nomd>[C](D)</nomd>[E](F)")
2 changes: 1 addition & 1 deletion webtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Website building tools."""

__version__ = "0.1.11"
__version__ = "0.1.12"
13 changes: 12 additions & 1 deletion webtools/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ def markup(content: str, root_dir: str = "") -> str:
content = preprocess(content)
content = content.replace("\\vec", "\\mathbf")

nomd: typing.List[str] = []
while "<nomd>" in content:
before, after = content.split("<nomd>", 1)
inner, after = after.split("</nomd>", 1)
content = f"{before}<!!nomd{len(nomd)}>{after}"
nomd.append(inner)

out = ""
popen = False
ulopen = False
Expand Down Expand Up @@ -456,7 +463,11 @@ def markup(content: str, root_dir: str = "") -> str:
)
out += "</ul>"

return insert_dates(out)
out = insert_dates(out)

for i, t in enumerate(nomd):
out = out.replace(f"<!!nomd{i}>", t)
return out


def code_include(matches: typing.Match[str]) -> str:
Expand Down