From a4e0d938a37a27f86553cd8e55b1fe2eb08f31d1 Mon Sep 17 00:00:00 2001 From: Eric Mika Date: Sun, 2 Jun 2024 01:11:06 -0400 Subject: [PATCH] Clean up config. --- .cspell.json | 1 + .vscode/extensions.json | 3 -- .vscode/settings.json | 28 ++-------------- package.json | 1 + pnpm-lock.yaml | 3 ++ readme.md | 6 ++-- test.ts | 73 +++++++++++++++++++++++++++++++++++++++++ tsconfig.eslint.json | 13 +------- 8 files changed, 85 insertions(+), 43 deletions(-) create mode 100644 test.ts diff --git a/.cspell.json b/.cspell.json index 7a9cba8..b3fe562 100644 --- a/.cspell.json +++ b/.cspell.json @@ -22,6 +22,7 @@ "throughs", "Weinstein-Raun", "Yanki", + "Yankī", "Yatskov" ] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 45eca11..f54a0b2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,11 +1,8 @@ { "recommendations": [ - "astro-build.astro-vscode", - "svelte.svelte-vscode", "streetsidesoftware.code-spell-checker", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", - "unifiedjs.vscode-mdx", "stylelint.vscode-stylelint" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 66b6558..eaaee01 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,45 +12,23 @@ "source.fixAll": "explicit" }, "eslint.enable": true, - "eslint.validate": [ - "astro", - "html", - "javascript", - "javascriptreact", - "markdown", - "mdx", - "svelte", - "typescript", - "typescriptreact" - ], + "eslint.validate": ["html", "javascript", "markdown", "typescript"], "typescript.tsdk": "node_modules/typescript/lib", - "[astro]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, "[gitignore]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "[ruby]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, "[shellscript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "[svelte]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "prettier.documentSelectors": [ "**/.eslintignore", "**/.node-version", "**/.npmrc", - "**/.prettierignore", - "**/*.astro", - "**/*.rb", - "**/*.svelte" + "**/.prettierignore" ], "prettier.enable": true, "stylelint.enable": true, - "stylelint.validate": ["css", "html", "svelte", "astro"] + "stylelint.validate": ["css", "html"] } diff --git a/package.json b/package.json index 9187e82..a029601 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "string-strip-html": "^13.4.8", "tsx": "^4.11.0", "type-fest": "^4.18.3", + "typescript": "^5.4.5", "unified": "^11.0.4", "unist-builder": "^4.0.0", "unist-util-visit": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e46b5ea..c0e1a6f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,6 +102,9 @@ importers: type-fest: specifier: ^4.18.3 version: 4.18.3 + typescript: + specifier: ^5.4.5 + version: 5.4.5 unified: specifier: ^11.0.4 version: 11.0.4 diff --git a/readme.md b/readme.md index ef28caf..0b68c23 100644 --- a/readme.md +++ b/readme.md @@ -23,9 +23,9 @@ Yanki MD simply syncs a folder of Markdown notes to Anki. -The "Y" prefix in "Yanki" is in the "Yet another" naming tradition; a nod to Anki's robust and occasionally duplicative ecosystem of third-party tools. +The "Y" prefix in "Yanki" is in the "Yet another" naming tradition; a nod to Anki's robust and occasionally duplicative ecosystem of third-party tools. (Also, appropriately, Yankī are a variety of [truant youth](https://en.wikipedia.org/wiki/Yankee#/media/File:ヤンキー.jpg).) -This library leverages my [`yanki-connect`](https://github.com/kitschpatrol/yanki-connect) library, and powers my [`yanki-obsidian`](https://github.com/kitschpatrol/yanki-obsidian) plugin. +This library leverages the [`yanki-connect`](https://github.com/kitschpatrol/yanki-connect) library, and powers the [`yanki-obsidian`](https://github.com/kitschpatrol/yanki-obsidian) plugin. ## Quick start @@ -142,7 +142,7 @@ Jazz isn't dead _It just smells funny_ ``` ---- +*** ### Cloze diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..0319bc4 --- /dev/null +++ b/test.ts @@ -0,0 +1,73 @@ +import { cleanNotes, syncFiles } from './src/lib' +// Import { mdastToHtml } from './src/lib/parse/rehype-utilities' +// import { getAstFromMarkdown } from './src/lib/parse/remark-utilities' +// import fs from 'node:fs/promises' + +const paths = [ + 'test/assets/minimal-notes/basic-and-reversed-card-with-no-back.md', + 'test/assets/minimal-notes/basic-and-reversed-card-with-no-front.md', + 'test/assets/minimal-notes/basic-and-reversed-card.md', + 'test/assets/minimal-notes/basic-type-in-the-answer-with-empty-frontmatter.md', + 'test/assets/minimal-notes/basic-type-in-the-answer-with-frontmatter.md', + 'test/assets/minimal-notes/basic-type-in-the-answer-with-multiple-emphasis.md', + 'test/assets/minimal-notes/basic-type-in-the-answer.md', + 'test/assets/minimal-notes/basic-with-cloze-like-back.md', + 'test/assets/minimal-notes/basic-with-empty-everything.md', + 'test/assets/minimal-notes/basic-with-empty-frontmatter.md', + 'test/assets/minimal-notes/basic-with-no-back.md', + 'test/assets/minimal-notes/basic-with-no-front-empty-frontmatter.md', + 'test/assets/minimal-notes/basic-with-no-front.md', + 'test/assets/minimal-notes/basic-with-type-in-like-answer-and-no-back.md', + 'test/assets/minimal-notes/basic-with-type-in-like-answer-and-no-front.md', + 'test/assets/minimal-notes/basic-with-type-in-like-single-line-with-empty-frontmatter.md', + 'test/assets/minimal-notes/basic-with-type-in-like-single-line-with-frontmatter.md', + 'test/assets/minimal-notes/basic-with-type-in-like-single-line.md', + 'test/assets/minimal-notes/basic.md', + 'test/assets/minimal-notes/cloze-with-extra-empty.md', + 'test/assets/minimal-notes/cloze-with-extra.md', + 'test/assets/minimal-notes/cloze-with-style.md', + 'test/assets/minimal-notes/cloze.md', +] + +const cleanResults = await cleanNotes({ + dryRun: false, + namespace: '*', +}) + +console.log('Cleaned ----------------------------------') +console.log(cleanResults.deleted.length) + +const results = await syncFiles(paths, { + namespace: 'YankiTestFile', +}) + +console.log('----------------------------------') +console.log('----------------------------------') +console.log(JSON.stringify(results, undefined, 2)) + +// +// const markdown = await fs.readFile( +// './test/assets/minimal-notes/basic-with-empty-everything.md', +// 'utf8', +// ) + +// Console.log('----------------------------------') +// console.log(markdown) + +// const mdast = await getAstFromMarkdown(markdown, { +// obsidianVault: 'Vault', +// }) + +// console.log('----------------------------------') +// console.log(JSON.stringify(mdast, undefined, 2)) + +// console.log('----------------------------------') +// const html = await mdastToHtml(mdast) + +// console.log(html) + +// "

I'm an answer to which there is no question.

" +// "

I'm an answer to which there is no question.

", + +// "" +// "" diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 096b04d..d7de8c3 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -5,16 +5,5 @@ }, "extends": "./tsconfig.json", "exclude": [], - "include": [ - "**/**.js", - "**/**.ts", - "**/**.svelte", - "**/**.astro", - "**/**.cjs", - "**/**.mjs", - "**/**.cts", - "**/**.mts", - "**/**.jsx", - "**/**.tsx" - ] + "include": ["**/**.js", "**/**.ts", "**/**.cjs", "**/**.mjs", "**/**.cts", "**/**.mts"] }