I'm building a website using Jekyll I would like to automatically remove liquid code (and only liquid code) from a given HTML file. I'm doing it in Python using regular expressions, and so far I have this one:
{.*?}|{{.*?}}
As I am not too familiar with liquid (and .html), could someone confirm that this will suffice for my goal?
Here is an example of the kind of file I will be working with:
<div class="post-preview">
<div class="post-title">
<div class="post-name">
<a href="{{ post.url }}">{{ post.title }}</a>
</div>
<div class="post-date">
{% include time.html %}
</div>
</div>
<div class="post-snippet">
{% if post.content contains '<!--break-->' %}
{{ post.content | split:'<!--break-->' | first }}
<div class="post-readmore">
<a href="{{ post.url }}">read more-></a>
</div>
{% endif %}
</div>
{% include post-meta.html %}
</div>
In this case my regex works, but I wanted to make sure I'm not missing something for the future. I could go for a hackish way and surround all liquid code with comments like
/* start_liquid */ {blalala} /* end_liquid */
but I'm looking for a more elegant way to do it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…