@humanspeak/svelte-markdown 0.8.4 → 0.8.6

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.
@@ -3,8 +3,11 @@
3
3
 
4
4
  interface Props {
5
5
  children?: Snippet
6
+ listItemIndex?: number
6
7
  }
7
- const { children }: Props = $props()
8
+
9
+ // trunk-ignore(eslint/@typescript-eslint/no-unused-vars,eslint/no-unused-vars)
10
+ const { children, listItemIndex = undefined }: Props = $props()
8
11
  </script>
9
12
 
10
13
  <li>{@render children?.()}</li>
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  interface Props {
3
3
  children?: Snippet;
4
+ listItemIndex?: number;
4
5
  }
5
6
  declare const ListItem: import("svelte").Component<Props, {}, "">;
6
7
  type ListItem = ReturnType<typeof ListItem>;
@@ -1,4 +1,4 @@
1
- import { Parser } from 'htmlparser2';
1
+ import * as htmlparser2 from 'htmlparser2';
2
2
  /**
3
3
  * Matches HTML tags with comprehensive coverage of edge cases.
4
4
  * Pattern breakdown:
@@ -119,7 +119,7 @@ export const parseHtmlBlock = (html) => {
119
119
  let currentText = '';
120
120
  const selfClosingTags = /^(br|hr|img|input|link|meta|area|base|col|embed|keygen|param|source|track|wbr)$/i;
121
121
  const openTags = [];
122
- const parser = new Parser({
122
+ const parser = new htmlparser2.Parser({
123
123
  onopentag: (name, attributes) => {
124
124
  if (currentText.trim()) {
125
125
  tokens.push({
@@ -240,7 +240,15 @@ export const containsMultipleTags = (html) => {
240
240
  export const shrinkHtmlTokens = (tokens) => {
241
241
  const result = [];
242
242
  for (const token of tokens) {
243
- if (token.type === 'table') {
243
+ if (token.type === 'list') {
244
+ token.items = token.items.map((item, index) => ({
245
+ ...item,
246
+ listItemIndex: index,
247
+ tokens: item.tokens ? shrinkHtmlTokens(item.tokens) : []
248
+ }));
249
+ result.push(token);
250
+ }
251
+ else if (token.type === 'table') {
244
252
  // Process header cells
245
253
  if (token.header) {
246
254
  token.header = token.header.map((cell) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humanspeak/svelte-markdown",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "A powerful, customizable markdown renderer for Svelte with TypeScript support",
5
5
  "keywords": [
6
6
  "svelte",