Last active
August 4, 2024 13:55
Revisions
-
johannrichard revised this gist
Aug 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ _by: [[{{ author | replace('\n', ']], [[')}}]]_ >  {% endif %} > Authors: [[{{ author | replace('\n', ']], [[')}}]] > Category: {{ category }} > Number of Highlights: {{ num_highlights }} > Readwise URL: {{ highlights_url }} > Source URL: [{{ source_url }}]({{ source_url }}) > Date: [[{{ updated }}]] -
johannrichard revised this gist
Aug 4, 2024 . 3 changed files with 12 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,14 @@ --- id: {{ id }} created: {{ updated }} {# For fields like title and aliases, remove linebreaks and either add spaces (title, alias) or create multiple list entries (author) #} title: "{{ title | replace('\n', ' ')}}" aliases: ["{{ title | replace('\n', ' ') }}"{%- if sanitized_title %}, "{{sanitized_title}}"{%- endif %}] author: ["{{ author | replace('\n', '", "')}}"] category: "{{ category }}" highlights: {{ num_highlights }} last_highlight_at: {{ last_highlight_at }} source: {{ unique_url }} {# Replace special characters in tags. Eventually, some of that might end up in the plugin as well #} tags: [ {%- if tags_nohash %}{{ tags_nohash | replace('&', 'and') | replace('@', '') }},{%- endif %}{%- if hl_tags_nohash %}{{ hl_tags_nohash | replace('&', 'and') | replace('@', '')}}{%- endif %} ] --- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ {# Header Template This is included once, and used to display variables of a Readwise Document (e.g. Author, Title, etc.) #} %% ID: {{ id }} Updated: {{ updated }} %% # {{ title }} {# Replace linebreaks and create multiple *Author* entries #} _by: [[{{ author | replace('\n', ']], [[')}}]]_ > [!info]- @@ -36,11 +37,12 @@ _by: [[{{ author | replace('\n', ']], [[')}}]]_ {%- endif %} ## Incoming Links {# This requires that the dataview plugin is installed. It will show all incoming links to this file #} ```dataview LIST FROM [[]] SORT file.frontmatter.created DESC ``` ## Highlights {# After this heading, the highlights will follow, using the Highlight Template #} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ {# Highlight template that does a few things: - Convert Readwise's "Highlight" syntax (__Highlight__) to Obsidian Highlight Syntax (==Highlight==) - Link to the Source and to the Highlight in Readwise - Add block-id's both for the highlight and the note (Please be aware that line breaks, lists etc. in a note might create multiple blocks and referencing the "block-id-note" block might only link to the last block of the note. #} > [!quote] > {{ text | bq | replace('__', '==') }} {%- if category == 'books' %} @@ -13,7 +13,6 @@ ^{{ id }}-note {% endif %} ({% if url %}[Source]({{ url }}), {% endif %}[Readwise](https://readwise.io/open/{{ id }}), [[{{ highlighted_at }}|{{ highlighted_at }}]]) ---- -
johannrichard revised this gist
Aug 4, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ - Add block-id's both for the highlight and the note (Please be aware that line breaks, lists etc. in a note might create multiple blocks and referencing the "block-id-note" block might only link to the last block of the note. -#} > [!quote] > {{ text | bq | replace('__', '==') }} {%- if category == 'books' %} > (*Original*: [{{ location }}]({{ locationUrl }})){%endif %} ^{{ id }} -
johannrichard created this gist
Aug 4, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ {#- Frontmatter Template - also called *Properties* in Obsidian -#} --- id: {{ id }} created: {{ updated }} {#- For fields like title and aliases, remove linebreaks and either add spaces (title, alias) or create multiple list entries (author) -#} title: "{{ title | replace('\n', ' ')}}" aliases: ["{{ title | replace('\n', ' ') }}"{%- if sanitized_title %}, "{{sanitized_title}}"{%- endif %}] author: ["{{ author | replace('\n', '", "')}}"] category: "{{ category }}" highlights: {{ num_highlights }} last_highlight_at: {{ last_highlight_at }} source: {{ unique_url }} {#- Replace special characters in tags. Eventually, some of that might end up in the plugin as well -#} tags: [ {%- if tags_nohash %}{{ tags_nohash | replace('&', 'and') | replace('@', '') }},{%- endif %}{%- if hl_tags_nohash %}{{ hl_tags_nohash | replace('&', 'and') | replace('@', '')}}{%- endif %} ] --- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ {#- Header Template This is included once, and used to display variables of a Readwise Document (e.g. Author, Title, etc.) -#} %% ID: {{ id }} Updated: {{ updated }} %% # {{ title }} {#- Replace linebreaks and create multiple *Author* entries -#} _by: [[{{ author | replace('\n', ']], [[')}}]]_ > [!info]- {%- if category == 'books' or category == 'supplementals' %} >  {% endif %} > Authors: [[{{ author | replace('\n', ']], [[')}}]] > Category: {{ category }} > Number of Highlights: =={{ num_highlights }}== > Readwise URL: {{ highlights_url }} > Source URL: [{{ source_url }}]({{ source_url }}) > Date: [[{{ updated }}]] > Last Highlighted: [[{{ last_highlight_at }}]] {%- if summary %} ## Summary {{ summary }} ^summary {%- endif %} --- {%- if document_note %} ## Document Note {{ document_note }} ^document-note {%- endif %} ## Incoming Links {#- This requires that the dataview plugin is installed. It will show all incoming links to this file -#} ```dataview LIST FROM [[]] SORT file.frontmatter.created DESC ``` ## Highlights {#- After this heading, the highlights will follow, using the Highlight Template -#} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ {#- Highlight template that does a few things: - Convert Readwise's "Highlight" syntax (__Highlight__) to Obsidian Highlight Syntax (==Highlight==) - Link to the Source and to the Highlight in Readwise - Add block-id's both for the highlight and the note (Please be aware that line breaks, lists etc. in a note might create multiple blocks and referencing the "block-id-note" block might only link to the last block of the note. -#} > [!quote] > {{ text | bq | replaace('__', '==') }} {%- if category == 'books' %} > (*Original*: [{{ location }}]({{ locationUrl }})){%endif %} ^{{ id }} {%if note %} {{ note }} ^{{ id }}-note {% endif %} ({% if url %}[Source]({{ url }}), {% endif %}[Readwise](https://readwise.io/open/{{ id }}), [[{{ highlighted_at }}|{{ highlighted_at }}]]) ---- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # What? These three files are my (current) Templates for the [Readwise Mirror](https://github.com/jsonMartin/readwise-mirror) plugin for Obsidian. They include (some) documentation. # Why? They started to become complex enough to warrant some revision control, for which gist is perfect. They're probably useful for others too, hence the public gist. # How? * Install the plugin * Fill in the Header Template, the Frontmatter Template, and the Highlight Template * Use a Jinja Parser & Template engine (e.g. [this one](https://j2live.ttl255.com)[^1] to preview the files. [^1]: I'm not affiliated but found this one to be sufficiently simple to test *basic* templates. However, be aware that the plugin's own functions (e.g. `bq`) can not be parsed and rendered by third party parsers.