Skip to content

Commit

Permalink
Merge pull request #63 from timvink/60_disable_lazy_loading
Browse files Browse the repository at this point in the history
Attempt to disable lazy loading
  • Loading branch information
timvink authored Jan 14, 2022
2 parents 52fd293 + 13c0ced commit c6c4b51
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mkdocs_print_site_plugin/js/print-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ function remove_element_by_classname(class_name) {
if( el.length > 0) {
el[0].style.display = "none"
}
}
}
4 changes: 4 additions & 0 deletions mkdocs_print_site_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ def on_post_build(self, config, **kwargs):
# Render the theme template for the print page
html = template.render(self.context)

# Remove lazy loading attributes from images
# https://regex101.com/r/HVpKPs/1
html = re.sub(r"(\<img.+)(loading=\"lazy\")", r"\1", html)

# Compatiblity with mkdocs-chart-plugin
# As this plugin adds some javascript to every page
# It should be included in the print site also
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="mkdocs-print-site-plugin",
version="2.2.3",
version="2.2.4",
description="MkDocs plugin that combines all pages into one, allowing for easy export to PDF and standalone HTML.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
10 changes: 9 additions & 1 deletion tests/fixtures/projects/basic/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ An to an anchor on page A [link](a.md#anchor-links)

## Subsection

On the homepage
On the homepage

## An image with lazy loading

See https://github.com/timvink/mkdocs-print-site-plugin/issues/60

![Image title](https://dummyimage.com/600x400/){ loading=lazy }


Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ plugins:
nav:
- Home: index.md
- Page Z: z.md
- Page A: a.md
- Page A: a.md

markdown_extensions:
- attr_list
- md_in_html
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ plugins:
nav:
- Home: index.md
- Page Z: z.md
- Page A: a.md
- Page A: a.md

markdown_extensions:
- attr_list
- md_in_html

0 comments on commit c6c4b51

Please sign in to comment.