Skip to content

Commit

Permalink
make sure content syncs to pkm properly
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Mar 11, 2024
1 parent 14a7152 commit 7930382
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/pkm-integrations/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,13 +1090,27 @@ export class PKMSyncBackgroundModule {
}
}
}

function convertHTMLintoMarkdown(html) {
let turndownService = new TurndownService({
headingStyle: 'atx',
hr: '---',
codeBlockStyle: 'fenced',
})
const markdown = turndownService.turndown(html)

// Add a rule for handling paragraphs to remove extra newlines
turndownService.addRule('paragraph', {
filter: 'p',
replacement: function (content) {
// Trim the content to remove leading and trailing whitespace
// and return the content with a single newline at the end
return content.trim() + '\n'
},
})

let markdown = turndownService.turndown(html)

// The following replacements might not be necessary anymore if the custom rule handles the conversion correctly
markdown = markdown.replace(/[\\](?!\n)/g, '')

return markdown
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,13 @@ export class AnnotationsSidebarContainer<
})
}
},
removeSpaceFromEditorPicker(spaceId) {
this.processEvent('setNewPageNoteLists', {
lists: this.state.commentBox.lists.filter(
(id) => id !== spaceId,
),
})
},
}
}

Expand Down

0 comments on commit 7930382

Please sign in to comment.