Skip to content

Commit

Permalink
chore(fmt): auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 30, 2024
1 parent e616b4d commit 024cfaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions manim_slides/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ class RevealTheme(str, StrEnum):
class RevealJS(Converter):
# Export option:
data_uri: bool = False
offline: bool = Field(False, description="Download remote assets for offline presentation.")
offline: bool = Field(
False, description="Download remote assets for offline presentation."
)
# Presentation size options from RevealJS
width: Union[Str, int] = Str("100%")
height: Union[Str, int] = Str("100%")
Expand Down Expand Up @@ -457,14 +459,15 @@ def prefix(i: int) -> str:
**options,
)


if self.offline:
soup = BeautifulSoup(content, "html.parser")
session = requests.Session()

for tag, inner in [("linl", "href"), ("script", "src")]:
for item in soup.find_all(tag):
if item.has_attr(inner) and (link := item[inner]).startswith("http"):
if item.has_attr(inner) and (link := item[inner]).startswith(
"http"
):
asset_filename = assets_dir / link.rsplit("/", 1)[1]
asset = session.get(link)
with open(asset_filename, "wb") as asset_file:
Expand Down

0 comments on commit 024cfaa

Please sign in to comment.