hadynz / obsidian-kindle-plugin

Sync your Kindle notes and highlights directly into your Obsidian vault
MIT License
922 stars 52 forks source link

[BUG] Book titles with non-filename-safe characters are cut off. #175

Closed evitiello closed 1 year ago

evitiello commented 2 years ago

Describe the bug

When the title of a book has a character in it that isn't allowed by the filesystem, only the first word is used as the filename.

Example: "Summary: Sapiens: A Brief History of Humankind" is created with a filename of "Summary"

Method of syncing

Expected behaviour

the filename should be something like "Summary Sapiens A Brief History of Humankind". or bad characters should be replaced with something good such as "Summary- Sapiens- A Brief History of Humankind

Metadata

hadynz commented 2 years ago

Thanks for raising this. You are running into an issue with the "smarts" that's been built in the plugin to truncate long book titles in a meaningful way (regardless if it has invalid characters not allowed by the file system).

The main use case is managing books with a colon. For the following examples, the plugin behaves as follows:

Original book title Shortened title
The Four Agreements: A Practical Guide to Personal Freedom (A Toltec Wisdom The Four Agreements
The Manager's Path: A Guide for Tech Leaders Navigating Growth and Change The Manager's Path

It's because of the above reason, that in your example Summary: Sapiens: A Brief history of humankind that it gets reduced to Summary which is not very helpful.

I'll make a fix to cater for this scenario. In your example, the short name of the book will be Summary: Sapiens.

evitiello commented 2 years ago

Would it be possible to have a configuration option to disable the truncation altogether?

hadynz commented 2 years ago

Would it be possible to have a configuration option to disable the truncation altogether?

You should be able to use the existing feature of using {{longTitle}} as a variable for the "file name template"

image

image

hadynz commented 2 years ago

This has now been fixed in 1.6.9.

Can you try it out and let me know if this fix or the previous solution I suggested have helped you achieve what you wanted?

evitiello commented 1 year ago

Much better, thank you!!