omnivore-app / obsidian-omnivore

Obsidian plugin to fetch articles and highlights from Omnivore
MIT License
842 stars 83 forks source link

Multi-line notes are improperly formatted #253

Open Thiago-Morais opened 2 months ago

Thiago-Morais commented 2 months ago

Related to https://github.com/omnivore-app/obsidian-omnivore/issues/23 but for notes

When a multi-line note is rendered inside a quote block it ignores the new lines within the note so no new > are inserted and the formatting looks wrong image

The first line is displayed inside the quote block but the following ones don't add a > per new line so anything after the first line is badly formatted


This is the template I'm using:

# {{{title}}}
{{{#description}}}
{{{description}}}
{{{/description}}}
{{#highlights.length}}
## Highlights

{{#highlights}}
> [!QUOTE]+ Highlighted on {{{dateHighlighted}}}
> 
> {{{text}}} [⤴️]({{{highlightUrl}}}) {{#labels}} #{{name}} {{/labels}} ^{{{highlightID}}}
{{#note}}

> {{{note}}}
{{/note}}

{{/highlights}}
{{/highlights.length}}

It is inspired off the Raindrop Highlights plugin that uses this Nunjucks template:

{% if is_new_article %}# {{title}}
{% if excerpt %}
{{excerpt}}
{% endif %}
## Highlights
{% endif -%}{% for highlight in highlights %}
{% if highlight.color == "red" -%}
    {%- set callout = "danger" -%}
{%- elif highlight.color == "blue" -%}
    {%- set callout = "info" -%}
{%- elif highlight.color == "green" -%}
    {%- set callout = "check" -%}
{%- else -%}
    {%- set callout = "quote" -%}
{%- endif -%}
> [!{{callout}}]+ Updated on {{highlight.lastUpdate}}
>
> {{highlight.text.split("\n") | join("\n>")}}
{% if highlight.note -%}> > {{highlight.note + "\n"}}{%- endif %}

{%- endfor -%}
levidcd commented 2 months ago

👍