question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line breaks are not preserved in Notes

See original GitHub issue

Whenever there are line breaks in Kindle notes, they are not preserved when those notes are synced to Obsidian. For example, in the following screenshot from https://read.amazon.com/notebook

image

I have a line break between two paragraphs. The corresponding HTML code also has two <br/> tags:

<span id="note" class="a-size-base-plus a-color-base">
  Story about firefighters in Montana. They had jumped off a plane into a burning forest to try and contain the fire. But they quickly found out that they couldn't handle it and will have to run to safety. One of the firefighters started another fire to clear away the fuel in front of him, and lay down on the ground. 
  <br>
  <br>
  The fire reached him, bntouldn't burn him because the ground around him provided no fuel to fire. He survived. 12 others didn't.
</span>

However, when this note is synced to Obsidian, it loses the line breaks (the screenshot is from Edit mode):

image

I also looked at the code used to parse the notes, but couldn’t find anything wrong with it at first glance:

https://github.com/hadynz/obsidian-kindle-plugin/blob/5ad275fa8d14bcacf0cdc2347b3a549a11e15356/src/scraper/scrapeBookHighlights.ts#L57

Take a look into this please? It is mildly annoying!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hadynzcommented, Jul 4, 2021

Thanks for raising this issue @rajatarora. It is quite a significant find as preserving line breaks is an important requirement that helps a user understand context of their highlights.

I also looked at the code used to parse the notes, but couldn’t find anything wrong with it at first glance:

The plugin uses cheerio for parsing HTML. The cheerio.text() method strips out all HTML. This includes any break lines meaning that we lose the ability of knowing when break lines used to exist. I would have to come up with a solution that does not use cheerio.text as it doesn’t support this functionality.

0reactions
rajataroracommented, Jul 13, 2021

I used 0.2.18 to re-sync my books to Obsidian. Line breaks are showing up properly now! Thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line breaks in notes for PDF export not preserved - Mockups 3
I added line breaks in the notes added to pages of a mockup (using \r); these are preserved correctly when shown in fullscreen...
Read more >
How do I preserve line breaks when getting text from a textarea?
Line breaks actually are preserved, the target element is just set to ignore them while displaying the text but if you inspect it...
Read more >
Line breaks are removed in posts made in plain text format
Method 1 - Disable the feature that removes extra line breaks · Open Outlook. · On the File tab, select Options. · In...
Read more >
How to Preserve Newlines, Line Breaks, and Whitespace in ...
Preserve Newlines, Line Breaks, and Whitespace in HTML. Use the white-space: pre; setting to display long-form content containing whitespace ...
Read more >
Single line breaks don't appear in embedded notes regardless ...
Turn “strict line breaks” off in editor options. Create Note A and add text separated by single line breaks. Create Note B and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found