Custom Filter for Jinja Templates

You may have noticed, prior to this, my blog posts have looked like a wall of text. That’s because Jinja (Templating engine) was stipping newlines. To resolve this issue, use a custom filter: def BlogPostFilter(value): return value.replace(‘\n’,’\n’) app.jinja_env.filters[‘BlogPostFilter’] = BlogPostFilter {{ blogPost.body | BlogPostFilter }} … I still need to work on whitespace to get[…]

Unicode of DOOOM!!

So I have this great system to automatically update the blog from a list of files when I click a button. Of course it broke while bringing in the latest post about Hyper-V – UNICODE!!! Solution was to decode when reading in from file: with open(blogpost, ‘r’) as bp: body = bp.read().decode(‘utf-8’)