@humanspeak/svelte-markdown 0.7.12 → 0.7.15
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 +3 -2
- package/dist/Parser.svelte +14 -3
- package/dist/SvelteMarkdown.svelte +1 -1
- package/dist/renderers/html/Select.svelte +3 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/token-cleanup.d.ts +1 -1
- package/dist/utils/token-cleanup.js +9 -3
- package/package.json +17 -20
- /package/{LICENSE.md → LICENSE} +0 -0
package/README.md
CHANGED
|
@@ -5,9 +5,10 @@ A powerful, customizable markdown renderer for Svelte with TypeScript support. B
|
|
|
5
5
|
[](https://www.npmjs.com/package/@humanspeak/svelte-markdown)
|
|
6
6
|
[](https://github.com/humanspeak/svelte-markdown/actions/workflows/npm-publish.yml)
|
|
7
7
|
[](https://coveralls.io/github/humanspeak/svelte-markdown?branch=main)
|
|
8
|
-
[](https://github.com/humanspeak/svelte-markdown/blob/main/LICENSE
|
|
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)
|
|
@@ -243,7 +244,7 @@ The component emits a `parsed` event when tokens are calculated:
|
|
|
243
244
|
|
|
244
245
|
## License
|
|
245
246
|
|
|
246
|
-
MIT © [Humanspeak, Inc.](LICENSE
|
|
247
|
+
MIT © [Humanspeak, Inc.](LICENSE)
|
|
247
248
|
|
|
248
249
|
## Credits
|
|
249
250
|
|
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>
|
|
@@ -152,7 +156,8 @@
|
|
|
152
156
|
<renderers.list {ordered} {...rest}>
|
|
153
157
|
{@const { items, ...parserRest }: {items: Props[]} = rest}
|
|
154
158
|
{#each items as item}
|
|
155
|
-
{@const UnorderedListComponent =
|
|
159
|
+
{@const UnorderedListComponent =
|
|
160
|
+
renderers.unorderedlistitem || renderers.listitem}
|
|
156
161
|
<UnorderedListComponent {...item}>
|
|
157
162
|
<Parser tokens={item.tokens} {renderers} {...parserRest} />
|
|
158
163
|
</UnorderedListComponent>
|
|
@@ -167,7 +172,13 @@
|
|
|
167
172
|
{@const tokens = (rest.tokens as Token[]) ?? ([] as Token[])}
|
|
168
173
|
<HtmlComponent {...rest}>
|
|
169
174
|
{#if tokens.length}
|
|
170
|
-
<Parser
|
|
175
|
+
<Parser
|
|
176
|
+
{tokens}
|
|
177
|
+
{renderers}
|
|
178
|
+
{...Object.fromEntries(
|
|
179
|
+
Object.entries(localRest).filter(([key]) => key !== 'attributes')
|
|
180
|
+
)}
|
|
181
|
+
/>
|
|
171
182
|
{/if}
|
|
172
183
|
</HtmlComponent>
|
|
173
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.15",
|
|
4
4
|
"description": "A powerful, customizable markdown renderer for Svelte with TypeScript support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"prepublishOnly": "npm run package",
|
|
61
61
|
"preview": "vite preview",
|
|
62
62
|
"test": "vitest run --coverage",
|
|
63
|
+
"test:all": "npm run test && npm run test:e2e",
|
|
63
64
|
"test:e2e": "playwright test",
|
|
64
65
|
"test:e2e:debug": "playwright test --debug",
|
|
65
66
|
"test:e2e:report": "playwright show-report",
|
|
@@ -74,20 +75,20 @@
|
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@eslint/eslintrc": "^3.2.0",
|
|
77
|
-
"@eslint/js": "^9.
|
|
78
|
-
"@playwright/test": "^1.
|
|
78
|
+
"@eslint/js": "^9.19.0",
|
|
79
|
+
"@playwright/test": "^1.50.0",
|
|
79
80
|
"@sveltejs/adapter-auto": "^4.0.0",
|
|
80
|
-
"@sveltejs/kit": "^2.
|
|
81
|
-
"@sveltejs/package": "^2.3.
|
|
81
|
+
"@sveltejs/kit": "^2.16.1",
|
|
82
|
+
"@sveltejs/package": "^2.3.9",
|
|
82
83
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
83
84
|
"@testing-library/jest-dom": "^6.6.3",
|
|
84
85
|
"@testing-library/svelte": "^5.2.6",
|
|
85
|
-
"@testing-library/user-event": "^14.6.
|
|
86
|
-
"@types/node": "^22.
|
|
87
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
88
|
-
"@typescript-eslint/parser": "^8.
|
|
89
|
-
"@vitest/coverage-v8": "^3.0.
|
|
90
|
-
"eslint": "^9.
|
|
86
|
+
"@testing-library/user-event": "^14.6.1",
|
|
87
|
+
"@types/node": "^22.12.0",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
89
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
90
|
+
"@vitest/coverage-v8": "^3.0.4",
|
|
91
|
+
"eslint": "^9.19.0",
|
|
91
92
|
"eslint-config-prettier": "^10.0.1",
|
|
92
93
|
"eslint-plugin-svelte": "^2.46.1",
|
|
93
94
|
"globals": "^15.14.0",
|
|
@@ -95,19 +96,19 @@
|
|
|
95
96
|
"prettier": "^3.4.2",
|
|
96
97
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
97
98
|
"prettier-plugin-svelte": "^3.3.3",
|
|
98
|
-
"prettier-plugin-tailwindcss": "^0.6.
|
|
99
|
+
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
99
100
|
"publint": "^0.3.2",
|
|
100
|
-
"svelte": "^5.
|
|
101
|
+
"svelte": "^5.19.5",
|
|
101
102
|
"svelte-check": "^4.1.4",
|
|
102
103
|
"typescript": "^5.7.3",
|
|
103
|
-
"vite": "^6.0.
|
|
104
|
-
"vitest": "^3.0.
|
|
104
|
+
"vite": "^6.0.11",
|
|
105
|
+
"vitest": "^3.0.4"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
108
|
"svelte": "^5.0.0"
|
|
108
109
|
},
|
|
109
110
|
"volta": {
|
|
110
|
-
"node": "22.
|
|
111
|
+
"node": "22.13.1"
|
|
111
112
|
},
|
|
112
113
|
"publishConfig": {
|
|
113
114
|
"access": "public"
|
|
@@ -115,10 +116,6 @@
|
|
|
115
116
|
"overrides": {
|
|
116
117
|
"@sveltejs/kit": {
|
|
117
118
|
"cookie": "^0.7.0"
|
|
118
|
-
},
|
|
119
|
-
"jsdom": {
|
|
120
|
-
"cssstyle": "2.3.0",
|
|
121
|
-
"@asamuzakjp/css-color": "1.0.0"
|
|
122
119
|
}
|
|
123
120
|
},
|
|
124
121
|
"tags": [
|
/package/{LICENSE.md → LICENSE}
RENAMED
|
File without changes
|