Readwise template: tags and notes as block properties

I have been using the official Readwise plugin and am generally quite happy with it. I am experimenting a bit with setting up some advanced queries and want to use block properties to annotate my notes with tags and other information, so I can query blocks by properties. The Readwise template generates blocks for each highlight, with tags and notes a sub-bullets, which complicates my queries. I would prefer the tags and notes to be block properties - i.e. directly under each highlight, without turning into sub-bullets. Does anyone know if there is a syntax notation for this?

1 Like

I am using Readwise Reader as my capture/read-later app.
In the app, I am able to annotate articles, videos, etc and by going to Notebook -> Export -> edit export template I was able to customize it to the following:

### {{ title }}
author:: {{ author }}
source:: {{ url }}
type:: [[content/article]]
tags:: {{ tags }}

{% for highlight in highlights %}
    - {{ highlight.content }}
    {% if highlight.tags %}tags:: {% for tag in highlight.tags %} {{ tag }} {% endfor %}{% endif %}
    {% if highlight.note %}> {{ highlight.note }}{% endif %}

{% endfor %}

It does something similar to what you described.
If you’re not talking about Read, but Readwise’s traditional export features, then it also has a template language, but the syntax is different and i have not played around with that one yet.

The language of the Readwise Logseq template looks similar to what you have there, with a few differences. This is what I have in the template for the highlights:

{{ highlight_text }} #card {% if highlight_location and highlight_location_url %} ({{highlight_location}}){% elif highlight_location %} ({{highlight_location}}){% endif %}
{% if highlight_tags %}
tags:: {% for tag in highlight_tags %}#[[{{tag}}]], {% endfor %}
{% endif %}
{% if highlight_note %}
note:: {{ highlight_note }}{% endif %}

What I don’t like is that this creates the tags and note content as sub-bullets under the highlight text block. What I want is to have them as properties of that text block. For some reason the Readwise export inserts a “-” in front of the tags:: and note:: lines, even though I haven’t specified them in the template.

I did some further experimentation and seem to have found the solution. This code works:

{{ highlight_text }} #card {% if highlight_location and highlight_location_url %} ([{{highlight_location}}]({{highlight_location_url}})){% elif highlight_location %} ({{highlight_location}}){% endif %}\ {% if highlight_tags %} tags:: {% for tag in highlight_tags %}#[[{{tag}}]], {% endfor %}{% endif %}\ {% if highlight_note %} note:: {{ highlight_note }}{% endif %}

Note the backslashes after the {% endif %} statements, and the removal of all linebreaks. It is a single line of code now. I don’t exactly know why this works, but it does.

1 Like

Hi. I wanted to tag on a related question, given this thread is about custom readwise export.

My issue is that I want highlights to appear in logseq as block quotes. For this I added:

“> {{ highlight_text }}”

This only works, however, for any highlight content before a line or paragraph break. After this, it imports simply as text.

An example. The first and second paragraph are part of one highlight:


was in 2015 that leaked documents first revealed that the US fossil fuel giant ExxonMobil knew as far back as the 1970s about the “potentially catastrophic” science of climate change and the business threat it posed.

The internal documents, most of which the company had kept secret, contained not only an acknowledgement of the link between burning fossil fuels and rising global temperatures, but data-driven projections of just how much the climate was likely to change. (View Highlight)


Is it possible to setup the custom export to arrive in logseq as blockquotes for highlights that include more than one paragraph?

thanks for any help.

Thomas.

It may be worth experimenting with the backslash character. It seems to turn hard line breaks into ‘soft’ line breaks, comparable to shift+enter in Logseq. I am not sure, though, whether Readwise exports each paragraph separately, or as a single block, with the line-breaks hard-coded in.

Thanks for this. Where would the backslash go? Next to the “>”?

I am afraid the backslash won’t work for multi-paragraph quotes. From the looks of it, Readwise exports those with ‘hard’ line breaks within the text. Logseq will interpret that as the start of a new block. I haven’t found any way to tell Readwise to do this differently.

I reported the same issue in readwise discos and logseq discord. No luck so far.

I found this though, not tried it out yet.

https://jinja.palletsprojects.com/en/latest/templates/#whitespace-control

By the way

With the default code provided by readwise I have the issue that document notes and document tags are in a block and not as page properties but only in some cases.

These are the default settings used:

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 %}{% endif %}

Here’s mine

{%- if true %}{{'#+BEGIN_QUOTE'}}{%- endif -%}\ 
{%- if true %}
{{ highlight_text }}{{' '}}
{%- endif -%}\ 
{%- if true %}
{{'#+END_QUOTE'}}
{%- endif -%}\ 
{%- if highlight_date %}
    date:: [[{{highlight_date}}]] 
{%- endif -%}\ 
{%- if highlight_tags %}
    tags:: {% for tag in highlight_tags %}#[[{{tag}}]] {% endfor %} 
{%- endif %}

    - from _{{title}}_ {% if author %}by {{author}}{% endif %}

{%- if highlight_location and highlight_location_url %}
    [{{highlight_location}}]({{highlight_location_url}})
{% elif highlight_location %}
    ({{highlight_location}})
{%- endif %}

    {% if highlight_note %}
    {%- if true %}{{'Note:'}}{%- endif -%}\ 
        {%- if true %}
            > {{highlight_note}}
        {%- endif -%}
    {% endif %}
1 Like