@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 CHANGED
@@ -5,9 +5,10 @@ A powerful, customizable markdown renderer for Svelte with TypeScript support. B
5
5
  [![NPM version](https://img.shields.io/npm/v/@humanspeak/svelte-markdown.svg)](https://www.npmjs.com/package/@humanspeak/svelte-markdown)
6
6
  [![Build Status](https://github.com/humanspeak/svelte-markdown/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/humanspeak/svelte-markdown/actions/workflows/npm-publish.yml)
7
7
  [![Coverage Status](https://coveralls.io/repos/github/humanspeak/svelte-markdown/badge.svg?branch=main)](https://coveralls.io/github/humanspeak/svelte-markdown?branch=main)
8
- [![License](https://img.shields.io/npm/l/@humanspeak/svelte-markdown.svg)](https://github.com/humanspeak/svelte-markdown/blob/main/LICENSE.md)
8
+ [![License](https://img.shields.io/npm/l/@humanspeak/svelte-markdown.svg)](https://github.com/humanspeak/svelte-markdown/blob/main/LICENSE)
9
9
  [![Downloads](https://img.shields.io/npm/dm/@humanspeak/svelte-markdown.svg)](https://www.npmjs.com/package/@humanspeak/svelte-markdown)
10
10
  [![CodeQL](https://github.com/humanspeak/svelte-markdown/actions/workflows/codeql.yml/badge.svg)](https://github.com/humanspeak/svelte-markdown/actions/workflows/codeql.yml)
11
+ [![Install size](https://packagephobia.com/badge?p=@humanspeak/svelte-markdown)](https://packagephobia.com/result?p=@humanspeak/svelte-markdown)
11
12
  [![Code Style: Trunk](https://img.shields.io/badge/code%20style-trunk-blue.svg)](https://trunk.io)
12
13
  [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
13
14
  [![Types](https://img.shields.io/npm/types/@humanspeak/svelte-markdown.svg)](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.md)
247
+ MIT © [Humanspeak, Inc.](LICENSE)
247
248
 
248
249
  ## Credits
249
250
 
@@ -123,7 +123,11 @@
123
123
  <Parser
124
124
  tokens={token.tokens}
125
125
  {renderers}
126
- {...localRest}
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 = renderers.unorderedlistitem || renderers.listitem}
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 {tokens} {renderers} {...localRest} />
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}
@@ -71,7 +71,7 @@
71
71
  } = $props()
72
72
 
73
73
  const combinedOptions = { ...defaultOptions, ...options }
74
- const slugger = source ? new Slugger() : undefined
74
+ const slugger = new Slugger()
75
75
 
76
76
  const tokens = $derived.by(() => {
77
77
  const lexer = new Lexer(combinedOptions)
@@ -9,4 +9,6 @@
9
9
  const { children, attributes }: Props = $props()
10
10
  </script>
11
11
 
12
- <select {...attributes}>{@render children?.()}</select>
12
+ <select {...attributes}>
13
+ {@render children?.()}
14
+ </select>
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 tags (excluding self-closing)
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
- return openingTags.length > 1 || closingTags.length > 1;
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.12",
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.18.0",
78
- "@playwright/test": "^1.49.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.15.3",
81
- "@sveltejs/package": "^2.3.7",
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.0",
86
- "@types/node": "^22.10.6",
87
- "@typescript-eslint/eslint-plugin": "^8.20.0",
88
- "@typescript-eslint/parser": "^8.20.0",
89
- "@vitest/coverage-v8": "^3.0.0-beta.4",
90
- "eslint": "^9.18.0",
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.10",
99
+ "prettier-plugin-tailwindcss": "^0.6.11",
99
100
  "publint": "^0.3.2",
100
- "svelte": "^5.18.0",
101
+ "svelte": "^5.19.5",
101
102
  "svelte-check": "^4.1.4",
102
103
  "typescript": "^5.7.3",
103
- "vite": "^6.0.7",
104
- "vitest": "^3.0.0-beta.4"
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.12.0"
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": [
File without changes