Created
February 9, 2023 22:36
-
-
Save tayiorbeii/7c69d868b50748f520c4131f7a398090 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "@johnlindquist/kit" | |
| // Name: page to markdown | |
| let { extract } = await npm('@extractus/article-extractor') | |
| let TurndownService = await npm('turndown') | |
| let input = await getActiveTab() | |
| let turndownService = new TurndownService({codeBlockStyle: 'fenced'}) | |
| turndownService.addRule('codeBlock', { | |
| filter: ['pre'], | |
| replacement: (content) => { | |
| return '```\n' + content + '\n```'; | |
| }, | |
| }); | |
| extract(input) | |
| .then(async article => { | |
| let { title, content } = article | |
| let markdown = `# ${title}\n\n${turndownService.turndown(content)}` | |
| // using Script Kit's file system api | |
| // write markdown with the title of the page as a filename | |
| // to the ~/Documents/Scraped Markdown folder | |
| let path = `/Users/taylor/Documents/Scraped Markdown/${title}.md` | |
| await ensureFile(path) | |
| await writeFile(path, markdown) | |
| debugger; | |
| }) | |
| .catch(err => console.error(err)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment