bandantonio / obsidian-apple-books-highlights-plugin

Import highlights and notes from your Apple Books to Obsidian
https://obsidian.md/plugins?id=apple-books-import-highlights
MIT License
26 stars 0 forks source link

[Bug] Error when callout meets newline #21

Open modatwork opened 4 days ago

modatwork commented 4 days ago

Hi bandantonio, thanks for sharing this nice plugin.

Description the bug

Also include the following details:

General information

To Reproduce Steps to reproduce the behavior:

  1. Create a highlight for a paragraph which contains newlines
  2. Add Obsidian Callout syntax to the plugin template as showed below
  3. Import highlights
  4. The highlight is not quoted correctly

Expected behavior

All the text from the highlight is quoted.

Screenshots

the current output:

image image

expected output:

image image

Additional context

The template used:

{{#each annotations}}
----

> [!QUOTE]
>  {{{highlight}}}

{{/each}}
bandantonio commented 4 days ago

@modatwork Thank you for the feedback and submitting the report. Recently, I stumbled upon a similar behavior with regular highlights, so it's time to fix it 🙃

bandantonio commented 4 days ago

@modatwork I spent some time with this bug and basically, there are two options available:

1 - preserve newlines. The only reasonable way for this option to work (at least, with the current tooling) is to add a tiny bit of HTML to the resulting Markdown file, like this:

Rendered Markdown file:

> [!QUOTE]
>  Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br>
Sed non risus.
Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat.

Preview:

2 - remove newlines. Still an option, the only minor issue is a slight decrease of readability

> [!QUOTE]
>  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed non risus.
Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat.

What option you like more? Personally, I feel like adding a tiny bit of HTML won't hurt, as many people use HTML snippets in their Obsidian vaults as well. Plus it will preserve the original structure and won't impact readability.

modatwork commented 2 days ago

<br> should work. But I found that my case is a little special. The newline begins with 4 spaces. And Obsidian can't render that correctly without a > in each line.

modatwork commented 2 days ago

Another option is to add an {{#each}}{{/each}} syntax for each line of the highlight text. I'm not sure if that's a good idea to add this complexity.