Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace [] with () in book titles #192

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-kindle-plugin",
"name": "Kindle Highlights",
"version": "1.6.9",
"version": "1.6.10",
"description": "Sync your Kindle book highlights using your Amazon login or uploading your My Clippings file",
"minAppVersion": "0.10.2",
"author": "Hady Osman",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-kindle-plugin",
"version": "1.6.9",
"version": "1.6.10",
"description": "Sync your Kindle book highlights using your Amazon login or uploading your My Clippings file",
"main": "src/index.ts",
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/shortenTitle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ describe('Santize title for Obsidian environment', () => {
const santizedTitle = shortenTitle(' The Warm-Hearted Snowman ');
expect(santizedTitle).toEqual('The Warm-Hearted Snowman');
});

it('replace [] with ()', () => {
const santizedTitle = shortenTitle('Ricochet Joe [Kindle in Motion]');
expect(santizedTitle).toEqual('Ricochet Joe (Kindle in Motion)');
});
});
2 changes: 2 additions & 0 deletions src/utils/shortenTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export const shortenTitle = (title: string): string => {
.replace(/ *\([^)]*\) */g, '') // remove parenthesis and contents from title
.replace(/:([^:]*)$/g, '') // remove text after last colon
.replace(/[']/g, '') // remove single quotes from title
.replace('[', '(') // replace [ with (
.replace(']', ')') // replace ] with )
.trim();
};