obsidian-kindle-plugin: Nunjucks filters in Highlight template throws Template render error
Thank you for creating this plugin, much appreciated.
I’m trying to use Nunjucks filter ‘replace’ in the Highlight template,
{{ text | replace('4', '.') }}
{% if note %}{{note}}{% endif %}
---
But it results in template render error,
Error parsing
.../My clippings.txt.
Template render error:(unknown path)
TypeError: Cannot read property 'lineno' of undefined
My actual goal is to use regex with the replace filter, But since it didn’t work I tried a basic replace as sighted above.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
So that we can confirm if the original issue that you had raised was resolved by the last release, you can bypass the validation that the plugin uses and modify the plugin’s
data.json
file directly. Simply sethighlightTemplate
to the nunjucks template that you want and it should be picked up by the plugin.I’ll look into fixing the false negative issue of validation after I am done with another task.
Thanks for raising this @abishekmuthian. I understand this issue and it is a valid bug.
To support resync, the plugin adds a “block reference” (e.g.
^ref-1233
) at the end of a highlight (rendered using{{ text }}
tags in nunjucks). The plugin has not catered for the fact that you could be using a nunjucks modifier such asreplace
to manipulate the content.Will fix shortly.
447 Books, 486 Highlights and my template works with 1.4.1🤟 Well done!
I checked the highlights at random and everything seems to be in order.
I will close this issue tomorrow after syncing few more fresh highlights.
Should we start a discussion about merits of bringing in custom
bookTemplate
? Because there are lot of instapaper users with similar use case as mine who’d like to edit the metadata for highlights from the downloaded content.@abishekmuthian I really, really hope that with the latest version 1.4.0 we have finally resolved all the issues that you’ve been encountering 😆. Let me know if we have finally nailed it. Cheers!
I’ve recently had to rewrite how the plugin parses the My Clippings file. It was missing notes and sometimes attaching them to the wrong annotation.
This should be straight forward to fix since you’ve sent me your file. It is possible that there is a use case in your file that has not been catered for.