@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
  [![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)
@@ -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>
@@ -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 {tokens} {renderers} {...localRest} />
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}
@@ -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.14",
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.18.0",
79
- "@playwright/test": "^1.49.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.16.1",
82
- "@sveltejs/package": "^2.3.8",
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.0",
87
- "@types/node": "^22.10.7",
88
- "@typescript-eslint/eslint-plugin": "^8.21.0",
89
- "@typescript-eslint/parser": "^8.21.0",
90
- "@vitest/coverage-v8": "^3.0.3",
91
- "eslint": "^9.18.0",
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.10",
99
+ "prettier-plugin-tailwindcss": "^0.6.11",
100
100
  "publint": "^0.3.2",
101
- "svelte": "^5.19.1",
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.3"
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.0"
111
+ "node": "22.13.1"
112
112
  },
113
113
  "publishConfig": {
114
114
  "access": "public"