diff options
author | neodarz <neodarz@neodarz.net> | 2019-05-26 12:38:04 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-05-26 12:38:04 +0200 |
commit | 2e8c6dfd876d25a00897e05ae2883a47f79d3eea (patch) | |
tree | e468a61aeb1a602ea14ae7afa6a5f0a8103b5c68 /pyblog | |
parent | c29e1ab61ab659eb9ba1f440a3d52aa4294d70c3 (diff) | |
download | my_new_personal_website-2e8c6dfd876d25a00897e05ae2883a47f79d3eea.tar.xz my_new_personal_website-2e8c6dfd876d25a00897e05ae2883a47f79d3eea.zip |
Move postprocess_html_file function to external file
Diffstat (limited to 'pyblog')
-rwxr-xr-x | pyblog | 18 |
1 files changed, 1 insertions, 17 deletions
@@ -766,22 +766,6 @@ def generate_index_and_feed(): generate_sitemap(feed) -def postprocess_html_file(htmlfilepath): - """Perform a series of postprocessing to an HTML file.""" - with open(htmlfilepath, "r+", encoding="utf-8") as htmlfileobj: - soup = bs4.BeautifulSoup(htmlfileobj.read(), "lxml") - - # a series of postprocessing (extensible) - utils.process_image_sizes(soup) - utils.link_img_tags(soup) - utils.process_footnote_backlinks(soup) - - # write back - htmlfileobj.seek(0) - htmlfileobj.write(str(soup)) - htmlfileobj.truncate() - - def static_vars(**kwargs): def decorate(func): for k in kwargs: @@ -917,7 +901,7 @@ def generate_blog(fresh=False, report_total_errors=True): sys.stderr.write("error: failed to generate %s" % relpath) # postprocess generated HTML file - postprocess_html_file(dstpath) + utils.postprocess_html_file(dstpath) if anything_modified: generate_index_and_feed() |