@humanspeak/svelte-markdown 0.7.14 → 0.7.16
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.
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ A powerful, customizable markdown renderer for Svelte with TypeScript support. B
|
|
|
8
8
|
[](https://github.com/humanspeak/svelte-markdown/blob/main/LICENSE)
|
|
9
9
|
[](https://www.npmjs.com/package/@humanspeak/svelte-markdown)
|
|
10
10
|
[](https://github.com/humanspeak/svelte-markdown/actions/workflows/codeql.yml)
|
|
11
|
+
[](https://packagephobia.com/result?p=@humanspeak/svelte-markdown)
|
|
11
12
|
[](https://trunk.io)
|
|
12
13
|
[](http://www.typescriptlang.org/)
|
|
13
14
|
[](https://www.npmjs.com/package/@humanspeak/svelte-markdown)
|
package/dist/Parser.svelte
CHANGED
|
@@ -123,7 +123,11 @@
|
|
|
123
123
|
<Parser
|
|
124
124
|
tokens={token.tokens}
|
|
125
125
|
{renderers}
|
|
126
|
-
{...
|
|
126
|
+
{...Object.fromEntries(
|
|
127
|
+
Object.entries(localRest).filter(
|
|
128
|
+
([key]) => key !== 'attributes'
|
|
129
|
+
)
|
|
130
|
+
)}
|
|
127
131
|
/>
|
|
128
132
|
{/if}
|
|
129
133
|
</HtmlComponent>
|
|
@@ -168,7 +172,13 @@
|
|
|
168
172
|
{@const tokens = (rest.tokens as Token[]) ?? ([] as Token[])}
|
|
169
173
|
<HtmlComponent {...rest}>
|
|
170
174
|
{#if tokens.length}
|
|
171
|
-
<Parser
|
|
175
|
+
<Parser
|
|
176
|
+
{tokens}
|
|
177
|
+
{renderers}
|
|
178
|
+
{...Object.fromEntries(
|
|
179
|
+
Object.entries(localRest).filter(([key]) => key !== 'attributes')
|
|
180
|
+
)}
|
|
181
|
+
/>
|
|
172
182
|
{/if}
|
|
173
183
|
</HtmlComponent>
|
|
174
184
|
{:else}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type { Renderers, SvelteMarkdownOptions } from './utils/markdown-parser.j
|
|
|
22
22
|
export type SvelteMarkdownProps = {
|
|
23
23
|
source: Token[] | string;
|
|
24
24
|
renderers?: Partial<Renderers>;
|
|
25
|
-
options?: SvelteMarkdownOptions
|
|
25
|
+
options?: Partial<SvelteMarkdownOptions>;
|
|
26
26
|
isInline?: boolean;
|
|
27
27
|
parsed?: (tokens: Token[] | TokensList) => void;
|
|
28
28
|
};
|
|
@@ -83,7 +83,7 @@ export declare const parseHtmlBlock: (html: string) => Token[];
|
|
|
83
83
|
* Used as a preprocessing step to optimize token processing.
|
|
84
84
|
*
|
|
85
85
|
* @param {string} html - HTML string to analyze
|
|
86
|
-
* @returns {boolean} True if multiple tags are present
|
|
86
|
+
* @returns {boolean} True if multiple tags are present or if it's a single pair of matching tags
|
|
87
87
|
*
|
|
88
88
|
* @internal
|
|
89
89
|
*/
|
|
@@ -197,15 +197,21 @@ export const parseHtmlBlock = (html) => {
|
|
|
197
197
|
* Used as a preprocessing step to optimize token processing.
|
|
198
198
|
*
|
|
199
199
|
* @param {string} html - HTML string to analyze
|
|
200
|
-
* @returns {boolean} True if multiple tags are present
|
|
200
|
+
* @returns {boolean} True if multiple tags are present or if it's a single pair of matching tags
|
|
201
201
|
*
|
|
202
202
|
* @internal
|
|
203
203
|
*/
|
|
204
204
|
export const containsMultipleTags = (html) => {
|
|
205
|
-
// Count the number of opening
|
|
205
|
+
// Count the number of opening and closing tags
|
|
206
206
|
const openingTags = html.match(/<[a-zA-Z][^>]*>/g) || [];
|
|
207
207
|
const closingTags = html.match(/<\/[a-zA-Z][^>]*>/g) || [];
|
|
208
|
-
|
|
208
|
+
// Return true if:
|
|
209
|
+
// 1. There are multiple opening tags OR
|
|
210
|
+
// 2. There are multiple closing tags OR
|
|
211
|
+
// 3. There is exactly one opening and one closing tag (matching pair)
|
|
212
|
+
return (openingTags.length > 1 ||
|
|
213
|
+
closingTags.length > 1 ||
|
|
214
|
+
(openingTags.length === 1 && closingTags.length === 1));
|
|
209
215
|
};
|
|
210
216
|
/**
|
|
211
217
|
* Primary entry point for HTML token processing. Transforms flat token arrays
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanspeak/svelte-markdown",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.16",
|
|
4
4
|
"description": "A powerful, customizable markdown renderer for Svelte with TypeScript support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -75,20 +75,20 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@eslint/eslintrc": "^3.2.0",
|
|
78
|
-
"@eslint/js": "^9.
|
|
79
|
-
"@playwright/test": "^1.
|
|
78
|
+
"@eslint/js": "^9.19.0",
|
|
79
|
+
"@playwright/test": "^1.50.1",
|
|
80
80
|
"@sveltejs/adapter-auto": "^4.0.0",
|
|
81
|
-
"@sveltejs/kit": "^2.
|
|
82
|
-
"@sveltejs/package": "^2.3.
|
|
81
|
+
"@sveltejs/kit": "^2.17.1",
|
|
82
|
+
"@sveltejs/package": "^2.3.10",
|
|
83
83
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
84
84
|
"@testing-library/jest-dom": "^6.6.3",
|
|
85
85
|
"@testing-library/svelte": "^5.2.6",
|
|
86
|
-
"@testing-library/user-event": "^14.6.
|
|
87
|
-
"@types/node": "^22.
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
89
|
-
"@typescript-eslint/parser": "^8.
|
|
90
|
-
"@vitest/coverage-v8": "^3.0.
|
|
91
|
-
"eslint": "^9.
|
|
86
|
+
"@testing-library/user-event": "^14.6.1",
|
|
87
|
+
"@types/node": "^22.13.1",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
|
89
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
90
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
91
|
+
"eslint": "^9.19.0",
|
|
92
92
|
"eslint-config-prettier": "^10.0.1",
|
|
93
93
|
"eslint-plugin-svelte": "^2.46.1",
|
|
94
94
|
"globals": "^15.14.0",
|
|
@@ -96,19 +96,19 @@
|
|
|
96
96
|
"prettier": "^3.4.2",
|
|
97
97
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
98
98
|
"prettier-plugin-svelte": "^3.3.3",
|
|
99
|
-
"prettier-plugin-tailwindcss": "^0.6.
|
|
99
|
+
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
100
100
|
"publint": "^0.3.2",
|
|
101
|
-
"svelte": "^5.19.
|
|
101
|
+
"svelte": "^5.19.7",
|
|
102
102
|
"svelte-check": "^4.1.4",
|
|
103
103
|
"typescript": "^5.7.3",
|
|
104
104
|
"vite": "^6.0.11",
|
|
105
|
-
"vitest": "^3.0.
|
|
105
|
+
"vitest": "^3.0.5"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"svelte": "^5.0.0"
|
|
109
109
|
},
|
|
110
110
|
"volta": {
|
|
111
|
-
"node": "22.13.
|
|
111
|
+
"node": "22.13.1"
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": {
|
|
114
114
|
"access": "public"
|