Skip to content

Commit

Permalink
Also parse source HTML tags for files to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
MartenBE committed Jan 12, 2025
1 parent 5b4f966 commit 9c02f4c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mkslides/markupgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ def __find_all_links(self, markdown_content: str) -> set[str]:
if not link.find_parents(["code", "pre"]):
found_links.add(link["src"])

for link in soup.find_all("source", src=True):
if not link.find_parents(["code", "pre"]):
found_links.add(link["src"])

for comment in soup.find_all(string=lambda text: isinstance(text, Comment)):
if match := HTML_BACKGROUND_IMAGE_REGEX.search(comment):
found_links.add(match.group("location"))
Expand Down
5 changes: 5 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
run_build_with_custom_input,
)

# The output can be seen manually by running the following command:
# poetry run mkslides build tests/test_files


def test_process_directory_without_config(setup_paths: Any) -> None:
cwd, output_path = setup_paths
Expand Down Expand Up @@ -35,6 +38,7 @@ def test_process_directory_without_config(setup_paths: Any) -> None:
"test-1.txt",
"test-2.txt",
"test-(3).txt",
"video/demo.webm",
],
)

Expand Down Expand Up @@ -79,6 +83,7 @@ def test_process_file_without_config(setup_paths: Any) -> None:
"test-1.txt",
"test-2.txt",
"test-(3).txt",
"video/demo.webm",
],
)

Expand Down
9 changes: 9 additions & 0 deletions tests/test_files/someslides.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,12 @@ This should not throw an error:
@

---

## Video

<video controls preload="metadata">
<source src="./video/demo.webm" type="video/webm"/>
Video not supported.
</video>

---
Binary file added tests/test_files/video/demo.webm
Binary file not shown.

0 comments on commit 9c02f4c

Please sign in to comment.