readwiseio / logseq-readwise-official-plugin

GNU General Public License v3.0
56 stars 3 forks source link

How to remove empty line(s) in jinja /page properties #22

Closed Holanda73 closed 1 year ago

Holanda73 commented 1 year ago

I am trying to export highlights from readwise to logseq with correct page properties.

However for some pages an empty line appears which prevents all properties to appear correctly. How can I fix this?

This is the current jinja code:

author:: [[{{author}}]]\
full-title:: "{{full_title}}"\
category:: #{{category}}\
if url %}url:: {{url}}{% endif %}\
if document_note       %}document_note:: {{document_note}}{% endif %}\
if document_tags %}tags:: {% for tag in document_tags %}#[[{{tag}}]] {% endfor %} {% endif %}
if image_url %}![]({{image_url}}){% endif %}

ine issue for example: If document note is empty it still creates a line for that property and thus does not take following properties into account

Holanda73 commented 1 year ago

I managed by adding - before the % in case of endif but only there where there was an issue:

author:: [[{{author}}]]\
full-title:: "{{full_title}}"\
category:: #{{category}}\
{% if url %}url:: {{url}}{% endif -%}\
{% if document_note %}document_note:: {{document_note}}{% endif -%}
{% if document_tags %}tags:: {% for tag in document_tags %}#[[{{tag}}]] {% endfor %} {% endif %}\
{% if image_url %}![]({{image_url}}){% endif %}