Skip to content

Commit

Permalink
Set python version to 3.8 (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jun 25, 2024
1 parent 12dd5f5 commit de73390
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hacs/doumentation",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"image": "mcr.microsoft.com/devcontainers/python:3.8",
"postCreateCommand": "scripts/setup",
"customizations": {
"vscode": {
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ jobs:
- name: Checkout the repository
uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
cache: "pip"
cache-dependency-path: "requirements.txt"

- name: Setup
run: scripts/setup

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
16 changes: 8 additions & 8 deletions source/hooks/html_tag_modifier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from urllib.parse import urlparse

import markdown
Expand All @@ -9,15 +10,14 @@
class Processor(markdown.treeprocessors.Treeprocessor):
def run(self, root: Element) -> Element | None:
for element in root.iter():
match element.tag:
case "a":
if urlparse(element.get("href", "")).scheme not in EXTERNAL_SCHEMES:
continue
element.set("target", "_blank")
element.set("rel", "noopener")
if element.tag == "a":
if urlparse(element.get("href", "")).scheme not in EXTERNAL_SCHEMES:
continue
element.set("target", "_blank")
element.set("rel", "noopener")

case "img":
element.set("loading", "lazy")
elif element.tag == "img":
element.set("loading", "lazy")


class Extension(markdown.Extension):
Expand Down
10 changes: 4 additions & 6 deletions source/hooks/shortcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ def replace(match: Match):
kwargs = get_dict(extra)


match tag:
case "my":
return _my_link(args, **kwargs)

case _:
raise RuntimeError(f"Unknown shortcode: {tag}")
if tag == "my":
return _my_link(args, **kwargs)
else:
raise RuntimeError(f"Unknown shortcode: {tag}")

return re.sub(r"<!-- hacs:(\w+)(.*?) -->", replace, markdown, flags=re.I | re.M)

Expand Down

0 comments on commit de73390

Please sign in to comment.