Skip to content

Commit

Permalink
Merge pull request #192 from hadynz/feature/handle-squares-in-title
Browse files Browse the repository at this point in the history
Replace [] with () in book titles
  • Loading branch information
hadynz authored Sep 4, 2022
2 parents d901b1b + 256dbc7 commit f601ce3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
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();
};

0 comments on commit f601ce3

Please sign in to comment.