Skip to content

Commit

Permalink
feat: inlude notes in the export
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
OGKevin committed Sep 25, 2022
1 parent 8ac0919 commit af75dbf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 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-kobo-highlights-importer-plugin",
"name": "Kobo Highlights Importer",
"version": "1.2.0",
"version": "1.3.0-beta.1",
"minAppVersion": "0.15.9",
"description": "Import highlights from your Kobo device",
"author": "Kevin Hellemun",
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-kobo-highlights-importer-plugin",
"version": "1.2.0",
"version": "1.3.0-beta.1",
"description": "Import highlights from your Kobo device",
"main": "src/main.js",
"scripts": {
Expand Down
8 changes: 2 additions & 6 deletions src/database/Highlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ describe('HighlightService', async function () {
## Chapter Eight: Holden
“I guess I can’t be. How do you prove a negative?” - [[2022-08-05T20:46:41+00:00]]
`
> “I guess I can’t be. How do you prove a negative?” — [[2022-08-05T20:46:41+00:00]]`
)
});

Expand Down Expand Up @@ -85,9 +83,7 @@ describe('HighlightService', async function () {
## Chapter Eight: Holden
“I guess I can’t be. How do you prove a negative?”
`
> “I guess I can’t be. How do you prove a negative?”`
)
});

Expand Down
16 changes: 12 additions & 4 deletions src/database/Highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ export class HighlightService {
markdown += `\n\n`
}

return markdown
return markdown.trim()
}

convertToMap(arr: Highlight[], includeDate: boolean, dateFormat: string): Map<bookTitle, Map<chapter, highlight[]>> {
convertToMap(
arr: Highlight[],
includeDate: boolean,
dateFormat: string,
): Map<bookTitle, Map<chapter, highlight[]>> {
const m = new Map<string, Map<string, string[]>>()

arr.forEach(x => {
if (!x.content.bookTitle) {
throw new Error("bookTitle must be set")
}

let text = x.bookmark.text
let text = `> ${x.bookmark.text}`

if (x.bookmark.note) {
text += `\n\n${x.bookmark.note}`
}

if (includeDate) {
text = text + ` - [[${moment(x.bookmark.dateCreated).format(dateFormat)}]]`
text += ` — [[${moment(x.bookmark.dateCreated).format(dateFormat)}]]`
}

const existingBook = m.get(x.content.bookTitle)
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1.0.2": "0.15.9",
"1.1.1": "0.15.9",
"1.2.0-beta.1": "0.15.9",
"1.2.0": "0.15.9"
"1.2.0": "0.15.9",
"1.3.0-beta.1": "0.15.9"
}

0 comments on commit af75dbf

Please sign in to comment.