Skip to content

Commit

Permalink
Support image without extension (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Mar 19, 2023
1 parent 32b013f commit 0c0a580
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mkdocs-glightbox-0.3.2 (2023-03-19)

* Supported image without extension (#13)

mkdocs-glightbox-0.3.1 (2022-11-22)

* Supported lightbox slide effect customization (#8)
Expand Down
1 change: 1 addition & 0 deletions mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def on_page_content(self, html, page, config, **kwargs):
a = soup.new_tag("a")
a["class"] = "glightbox"
a["href"] = img.get("src", "")
a["data-type"] = "image"
# setting data-width and data-height with plugin options
for k, v in plugin_config.items():
a[f"data-{k}"] = v
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="mkdocs-glightbox",
version="0.3.1",
version="0.3.2",
author="Blueswen",
author_email="[email protected]",
url="https://blueswen.github.io/mkdocs-glightbox",
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/docs/without_ext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Image without extension](https://picsum.photos/1200/800)
24 changes: 22 additions & 2 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,27 @@ def test_image_in_anchor(tmp_path):
path = "../"
validate_static(contents, path)
validate_script(contents)
assert (
re.search(
rf'<a class="glightbox" .* href="{path}img.png"><img .* src="{path}img.png"\/><\/a>',
contents,
)
is None
)


def test_image_without_ext(tmp_path):
"""
Image without extension
"""
mkdocs_file = "mkdocs.yml"
testproject_path = validate_mkdocs_file(tmp_path, f"tests/fixtures/{mkdocs_file}")
file = testproject_path / "site/without_ext/index.html"
contents = file.read_text(encoding="utf8")
path = "../"
validate_static(contents, path)
validate_script(contents)
assert re.search(
rf'<a class="glightbox" .* href="{path}img.png"><img .* src="{path}img.png"\/><\/a>',
rf'<a class="glightbox" .* data-type="image" .* href="https://picsum.photos/1200/800"><img .* src="https://picsum.photos/1200/800"\/><\/a>',
contents,
) is None
)

0 comments on commit 0c0a580

Please sign in to comment.