omnivore-app / obsidian-omnivore

Obsidian plugin to fetch articles and highlights from Omnivore
MIT License
813 stars 46 forks source link

Multi-line highlights are improperly formatted #23

Closed profucius closed 1 year ago

profucius commented 1 year ago

I have found a possible issue with downloading highlights which span across multiple paragraphs, particularly if they include bullet/number lists.

Example: I am using your "Getting Started With Omnivore" article which is included in a fresh signup to your service.

Paragraph line with a following list.

I made a highlight of this text at the top of the article:

image

And the resulting highlight downloaded to my Obsidian vault appears this way:

image

As you can see, the formatting for the first line is correct, but the bulleted/numbered list following it is formatted with incorrect tabulations and no > (obsidian quote symbol)


Another example with a different incorrect format:

List only (no leading paragraph line). Same article as above.

I make a highlight as such:

image

Which is downloaded to Obsidian as such:

image


One more example with yet another different incorrect format:

Sub-bullet list under a numbered list. Same article as above.

I make a highlight as such: (note I do not highlight the numbered line)

image

Which is downloaded to Obsidian as such:

image


Template I am using within Obsidian:

{{#highlights.length}}
## Highlights

{{#highlights}}
> {{{text}}} [⤴️]({{{highlightUrl}}})
{{#note}}

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

{{/highlights}}
{{/highlights.length}}
RicSanOP commented 1 year ago

Here's a personal fix I wrote. Just replace what is currently in the main.js file of the plugin with this (at line ~7862). Then surround the highlight text in the blockify wrapper i.e. {{#blockify}}{{{text}}}{{/blockify}}

const content = mustache_default.render(template, {
            id: article.id,
            title: article.title,
            omnivoreUrl: `https://omnivore.app/me/${article.slug}`,
            siteName,
            originalUrl: article.originalArticleUrl,
            author: article.author,
            labels: (_c = article.labels) == null ? void 0 : _c.map((l2) => {
              return {
                name: l2.name.replace(" ", "_")
              };
            }),
            dateSaved,
            highlights,
            content: article.content,
            blockify: function () {
              return function(text, render) {
                return render(text).replace(/\s*\n\s*/gm,'\n').split('\n').slice(0, -1).join('\n> ')
            }},
            linkify: function () {
              return function(text, render) {
                console.log(text, render(text))
                return render(text) != '' ? `"[[${render(text).split(' ').join(']]", "[[')}]]"` : ''
            }},
sywhb commented 1 year ago

Hey @profucius, sorry for the late reply. We have some root issues with saving the multi-line or merged highlights content in Omnivore. I'm trying to retain the format of the highlighted content as it is in the Omnivore API.

Hey @RicSanOP, thanks for the fix! Yeah, I think this should work for most cases. Let me know if you'd like to submit a PR for that or I can create one too

RicSanOP commented 1 year ago

Hey @sywhb, sorry to lay this on you, but could you PR it. I don't think this is release worthy. I also haven't cloned/forked the repo. However, I may be interested in collabing on solving the root issue on the backend side that sends the data in such wrong formatting. Happy that an open source and free option read it later app exists.

sywhb commented 1 year ago

We are working on creating highlight quote in markdown format in Omnivore to retain some of the HTML format including multi-line paragraphs

sywhb commented 1 year ago

Hey @profucius @RicSanOP, a new version 1.2.2 is released to address this issue.

Kindly upgrade the plugin and let me know if it works for you