Obsidian Clipper: how to read {{highlights}}?

What I’m trying to do

I am using Obsidian Clipper, and I am trying to write on the note the following content:

The code I am using is the following:

# Highlights
{{highlights}}

# Content
{{content}}

But instead of the markdown format of my highlights, I get:

[
    {
        "text": "Selector variables allow you to extract text content",
        "timestamp": "2024-10-20T19:34:05.462Z"
    },
    {
        "text": "eturns text content of the first `h1` element on the page.\n-first `.author` element on the page.\n- ",
        "timestamp": "2024-10-20T19:34:05.462Z"
    }
]

So, I want the highlights and the full content of the page.

Things I have tried

I tried the two options at the Clip behavior, but does not allow me to get both contents at the same time.

So, how to I format the {{highlights}} in JSON format to a markdown format?
Thanks!

My environment

SYSTEM INFO:
	Obsidian version: v1.7.4
	Installer version: v1.7.4
	Operating system: Windows 11 Pro 10.0.22631
	Login status: logged in
	Language: en
	Catalyst license: insider
	Insider build toggle: on
	Live preview: on
	Base theme: dark
	Community theme: none
	Snippets enabled: 4
	Restricted mode: off
	Plugins installed: 19
	Plugins enabled: 19
		1: Text Format v3.1.0
		2: Omnivore v1.10.4
		3: Templater v2.8.3
		4: Dataview v0.5.67
		5: Calendar v1.5.10
		6: Settings Search v1.3.10
		7: Homepage v4.0.6
		8: Text Extractor v0.5.2
		9: Omnisearch v1.24.1
		10: Natural Language Dates v0.6.2
		11: Mind Map v1.1.0
		12: Excalidraw v2.5.2
		13: Git v2.27.0
		14: Tag Wrangler v0.6.1
		15: Tasks v7.11.1
		16: Plugin Update Tracker v1.6.0
		17: Image Converter v1.1.7
		18: Enhancing Export v1.10.8
		19: CSV Codeblock v1.1.0
Microsoft Edge
Version 130.0.2849.46 (Official build) (64-bit)
Obsidian Web Clipper
Size: < 1 MB
Version: 0.9.4

The highlights variable is an object. So, you need to use filters to render them like you want.

For exemple, personnaly I render them as list like that:

{{highlights|map:item => item.text|list}}
1 Like

Thank you! Works perfectly!

I just want to make another quick change… how to add an if so the highlights are not created if the lenght of highligths is 0?

Something like:

{% if highlights.size %}
# Highlights
{{highlights|map:item => item.text|list}}
{% endif %}

# Content
{{content}}

or

{% if highlights.length%}
# Highlights
{{highlights|map:item => item.text|list}}
{% endif %}

# Content
{{content}}

or

{% if highlights|length%}
# Highlights
{{highlights|map:item => item.text|list}}
{% endif %}

# Content
{{content}}

or

{{#if highlights.length > 0}}
# Highlights
{{highlights|map:item => item.text|list}}
{{/if}}

# Content
{{content}}

and combinations of lenght, size, . or | .

I have not been able to make it work.
Any ideas or things to try?
Thanks!

1 Like

For the moment, there isn’t an if filter, you can’t have a condition in the template like that. Maybe it’ll be just later, it’s still in the beginning.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.