@humanspeak/svelte-markdown 0.8.12 → 0.8.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
1
1
  import { Unsupported } from '../renderers/index.js';
2
2
  import { defaultRenderers } from './markdown-parser.js';
3
3
  import { rendererKeysInternal } from './rendererKeys.js';
4
- const allRendererKeys = rendererKeysInternal;
4
+ import { createFilterUtilities } from './createFilterUtilities.js';
5
+ // Create filter utilities using the generic factory
6
+ const filterUtils = createFilterUtilities(rendererKeysInternal, Unsupported, defaultRenderers);
5
7
  /**
6
8
  * Builds a map where every markdown renderer (excluding the special `html` map)
7
9
  * is set to the `Unsupported` component.
8
10
  *
9
11
  * @function buildUnsupportedRenderers
10
- * @returns {Partial<Renderers>} A map with all non‑HTML renderers set to `Unsupported`.
12
+ * @returns {Omit<Renderers, 'html'>} A map with all non‑HTML renderers set to `Unsupported`.
11
13
  * @example
12
14
  * import { buildUnsupportedRenderers } from '@humanspeak/svelte-markdown'
13
15
  * const renderers = {
@@ -15,23 +17,17 @@ const allRendererKeys = rendererKeysInternal;
15
17
  * html: {} // customize HTML separately
16
18
  * }
17
19
  */
18
- export const buildUnsupportedRenderers = () => {
19
- const result = {};
20
- for (const key of allRendererKeys) {
21
- result[key] = Unsupported;
22
- }
23
- return result;
24
- };
20
+ export const buildUnsupportedRenderers = filterUtils.buildUnsupported;
25
21
  /**
26
22
  * Produces a renderer map that allows only the specified markdown renderers (excluding `html`).
27
23
  * All non‑listed renderer keys are set to `Unsupported`.
28
- * Each entry can be either a renderer key (to use the librarys default component),
24
+ * Each entry can be either a renderer key (to use the library's default component),
29
25
  * or a tuple `[key, component]` to specify a custom component for that key.
30
26
  *
31
27
  * @function allowRenderersOnly
32
28
  * @param {Array<RendererKey | [RendererKey, RendererComponent]>} allowed
33
29
  * Renderer keys to allow, or tuples for custom component overrides.
34
- * @returns {Partial<Renderers>} A renderer map with only the provided keys enabled.
30
+ * @returns {Omit<Renderers, 'html'>} A renderer map with only the provided keys enabled.
35
31
  * @example
36
32
  * // Allow only paragraph and link with defaults
37
33
  * const renderers = allowRenderersOnly(['paragraph', 'link'])
@@ -40,25 +36,10 @@ export const buildUnsupportedRenderers = () => {
40
36
  * // Allow paragraph with a custom component
41
37
  * const renderers = allowRenderersOnly([['paragraph', MyParagraph]])
42
38
  */
43
- export const allowRenderersOnly = (allowed) => {
44
- const result = buildUnsupportedRenderers();
45
- for (const entry of allowed) {
46
- if (Array.isArray(entry)) {
47
- const [key, component] = entry;
48
- if (allRendererKeys.includes(key))
49
- result[key] = component;
50
- }
51
- else {
52
- const key = entry;
53
- if (allRendererKeys.includes(key))
54
- result[key] = defaultRenderers[key];
55
- }
56
- }
57
- return result;
58
- };
39
+ export const allowRenderersOnly = filterUtils.allowOnly;
59
40
  /**
60
41
  * Produces a renderer map that excludes only the specified markdown renderer keys (excluding `html`).
61
- * Excluded keys are mapped to `Unsupported`, while all other keys use the librarys default components.
42
+ * Excluded keys are mapped to `Unsupported`, while all other keys use the library's default components.
62
43
  * Optionally override specific non‑excluded keys with custom components via `[key, component]` tuples.
63
44
  *
64
45
  * Exclusions take precedence over overrides.
@@ -68,7 +49,7 @@ export const allowRenderersOnly = (allowed) => {
68
49
  * Renderer keys to exclude (set to `Unsupported`).
69
50
  * @param {Array<[RendererKey, RendererComponent]>} [overrides]
70
51
  * Optional tuples mapping non‑excluded keys to custom components.
71
- * @returns {Partial<Renderers>} A renderer map with only the provided keys excluded.
52
+ * @returns {Omit<Renderers, 'html'>} A renderer map with only the provided keys excluded.
72
53
  * @example
73
54
  * // Disable just paragraph and link, keep others as defaults
74
55
  * const renderers = excludeRenderersOnly(['paragraph', 'link'])
@@ -77,22 +58,4 @@ export const allowRenderersOnly = (allowed) => {
77
58
  * // Disable link; override paragraph to a custom component
78
59
  * const renderers = excludeRenderersOnly(['link'], [['paragraph', MyParagraph]])
79
60
  */
80
- export const excludeRenderersOnly = (excluded, overrides) => {
81
- const result = {};
82
- for (const key of allRendererKeys) {
83
- result[key] = defaultRenderers[key];
84
- }
85
- for (const key of excluded) {
86
- if (allRendererKeys.includes(key))
87
- result[key] = Unsupported;
88
- }
89
- if (overrides) {
90
- for (const [key, component] of overrides) {
91
- if (excluded.includes(key))
92
- continue;
93
- if (allRendererKeys.includes(key))
94
- result[key] = component;
95
- }
96
- }
97
- return result;
98
- };
61
+ export const excludeRenderersOnly = filterUtils.excludeOnly;
package/package.json CHANGED
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "name": "@humanspeak/svelte-markdown",
3
- "version": "0.8.12",
4
- "description": "A powerful, customizable markdown renderer for Svelte with TypeScript support",
3
+ "version": "0.8.14",
4
+ "description": "Fast, customizable markdown renderer for Svelte with built-in caching, TypeScript support, and Svelte 5 runes",
5
5
  "keywords": [
6
6
  "svelte",
7
+ "svelte5",
8
+ "sveltekit",
7
9
  "markdown",
8
10
  "renderer",
9
11
  "parser",
12
+ "fast",
13
+ "performance",
14
+ "cache",
15
+ "caching",
10
16
  "marked",
11
17
  "component",
12
- "sveltekit",
13
- "svelte5",
18
+ "typescript",
19
+ "runes",
14
20
  "md",
15
21
  "documentation",
16
22
  "html",
17
23
  "converter",
18
- "formatting"
24
+ "formatting",
25
+ "customizable",
26
+ "extensible"
19
27
  ],
20
28
  "homepage": "https://markdown.svelte.page",
21
29
  "bugs": {
@@ -55,51 +63,52 @@
55
63
  }
56
64
  },
57
65
  "dependencies": {
66
+ "@humanspeak/memory-cache": "^1.0.2",
58
67
  "github-slugger": "^2.0.0",
59
68
  "htmlparser2": "^10.0.0",
60
- "marked": "^16.3.0"
69
+ "marked": "^17.0.1"
61
70
  },
62
71
  "devDependencies": {
63
- "@eslint/compat": "^1.4.0",
64
- "@eslint/js": "^9.36.0",
65
- "@playwright/test": "^1.55.1",
66
- "@sveltejs/adapter-auto": "^6.1.0",
67
- "@sveltejs/kit": "^2.43.5",
68
- "@sveltejs/package": "^2.5.4",
69
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
70
- "@testing-library/jest-dom": "^6.8.0",
71
- "@testing-library/svelte": "^5.2.8",
72
+ "@eslint/compat": "^2.0.0",
73
+ "@eslint/js": "^9.39.2",
74
+ "@playwright/test": "^1.57.0",
75
+ "@sveltejs/adapter-auto": "^7.0.0",
76
+ "@sveltejs/kit": "^2.49.3",
77
+ "@sveltejs/package": "^2.5.7",
78
+ "@sveltejs/vite-plugin-svelte": "^6.2.2",
79
+ "@testing-library/jest-dom": "^6.9.1",
80
+ "@testing-library/svelte": "^5.3.1",
72
81
  "@testing-library/user-event": "^14.6.1",
73
- "@types/node": "^24.5.2",
74
- "@typescript-eslint/eslint-plugin": "^8.44.1",
75
- "@typescript-eslint/parser": "^8.44.1",
76
- "@vitest/coverage-v8": "^3.2.4",
82
+ "@types/node": "^25.0.3",
83
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
84
+ "@typescript-eslint/parser": "^8.52.0",
85
+ "@vitest/coverage-v8": "^4.0.16",
77
86
  "concurrently": "^9.2.1",
78
- "eslint": "^9.36.0",
87
+ "eslint": "^9.39.2",
79
88
  "eslint-config-prettier": "^10.1.8",
80
89
  "eslint-plugin-import": "^2.32.0",
81
- "eslint-plugin-svelte": "^3.12.4",
82
- "eslint-plugin-unused-imports": "^4.2.0",
83
- "globals": "^16.4.0",
90
+ "eslint-plugin-svelte": "^3.13.1",
91
+ "eslint-plugin-unused-imports": "^4.3.0",
92
+ "globals": "^17.0.0",
84
93
  "husky": "^9.1.7",
85
- "jsdom": "^27.0.0",
86
- "prettier": "^3.6.2",
94
+ "jsdom": "^27.4.0",
95
+ "prettier": "^3.7.4",
87
96
  "prettier-plugin-organize-imports": "^4.3.0",
88
- "prettier-plugin-svelte": "^3.4.0",
89
- "prettier-plugin-tailwindcss": "^0.6.14",
90
- "publint": "^0.3.13",
91
- "svelte": "^5.39.6",
92
- "svelte-check": "^4.3.2",
93
- "typescript": "^5.9.2",
94
- "typescript-eslint": "^8.44.1",
95
- "vite": "^7.1.7",
96
- "vitest": "^3.2.4"
97
+ "prettier-plugin-svelte": "^3.4.1",
98
+ "prettier-plugin-tailwindcss": "^0.7.2",
99
+ "publint": "^0.3.16",
100
+ "svelte": "^5.46.1",
101
+ "svelte-check": "^4.3.5",
102
+ "typescript": "^5.9.3",
103
+ "typescript-eslint": "^8.52.0",
104
+ "vite": "^7.3.1",
105
+ "vitest": "^4.0.16"
97
106
  },
98
107
  "peerDependencies": {
99
108
  "svelte": "^5.0.0"
100
109
  },
101
110
  "volta": {
102
- "node": "22.17.1"
111
+ "node": "24.12.0"
103
112
  },
104
113
  "publishConfig": {
105
114
  "access": "public"