emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
279 stars 21 forks source link

Template filter to convert Org to HTML #28

Open semente opened 3 years ago

semente commented 3 years ago

Let's say I have the following title in a post:

#+TITLE: This is the /title/

I would to render it in HTML when using {{ post.title }}. Maybe have a html template filter to do this org-to-html conversion: {{ post.title|html }} (which could be "|safe" by default).

Currently I can use #+TITLE: This is the <i>title</i> and {{ post.title|safe }} just fine but if I, let's say, try to publish this same Org file to PDF using org-publish I won't have the desired results.

clarete commented 3 years ago

this is a very interesting issue. I think this might have been caused by the fact that the title needs to be captured when it's not formatted by ox-html so it can go within the head's <title></title> tag. Maybe the title should be treated like the post.html property. If it contains org-mode, it should probably be unsafe by default. I feel like it'd be more consistent.

What do you think? It'd be a breaking change, but we'd get a more consistent behavior on escaping.

semente commented 3 years ago

Yea, agree. What you suggest is more consistent. #+SUBTITLE and #+DESCRIPTION are also Org export keywords and should behave the same as #+TITLE as well, I guess.

And perhaps post.html should be renamed to post.content too.