Hooks
In [1]:
Copied!
import logging
import os
import re
import logging
import os
import re
In [2]:
Copied!
log = logging.getLogger("mkdocs")
log = logging.getLogger("mkdocs")
In [3]:
Copied!
def on_page_content(html, page, config, **kwargs):
for src in re.findall(r'<img[^>]+src=["\']([^"\']+)["\']', html, re.IGNORECASE):
if src.startswith(("http://", "https://", "data:")):
continue
page_dir = os.path.dirname(page.file.src_path)
img_path = os.path.normpath(os.path.join(config["docs_dir"], page_dir, src))
if not os.path.exists(img_path):
log.warning("Image not found: '%s' in %s", src, page.file.src_path)
def on_page_content(html, page, config, **kwargs):
for src in re.findall(r'<img[^>]+src=["\']([^"\']+)["\']', html, re.IGNORECASE):
if src.startswith(("http://", "https://", "data:")):
continue
page_dir = os.path.dirname(page.file.src_path)
img_path = os.path.normpath(os.path.join(config["docs_dir"], page_dir, src))
if not os.path.exists(img_path):
log.warning("Image not found: '%s' in %s", src, page.file.src_path)