Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also parse source HTML tags for files to copy #30

Merged
merged 1 commit into from
Jan 12, 2025
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: 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.
Loading