diff --git a/helper.py b/helper.py index f979184..ff944cd 100644 --- a/helper.py +++ b/helper.py @@ -1,6 +1,7 @@ import os import stat import yaml +import re # Calls a YAML parser for the given relative path inside the presentation root # directory. Returns a dictionary with the YAML content. @@ -29,4 +30,14 @@ def insert_metadata(content, root, lang): # Retrieve the modification time for a given file. def get_modification_time(path): - return os.stat(path)[stat.ST_MTIME] \ No newline at end of file + return os.stat(path)[stat.ST_MTIME] + +# Replace the "src" attribute on images by "data-src". +# Should be done after caching because fragments#defragmentize requires +# valid XHTML and data-src causes problems with that. +# Also: Toggling lazyload is easier this way. +def add_lazyload(source, lazyload_images): + if lazyload_images: + return re.sub(r'