svelte-streamdown 3.0.0 → 3.0.1
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
|
@@ -99,7 +99,8 @@ $$
|
|
|
99
99
|
- Pan and Zoom
|
|
100
100
|
- Full screen mode
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
|
|
103
|
+
# **Example:**
|
|
103
104
|
|
|
104
105
|
```mermaid
|
|
105
106
|
graph TD
|
|
@@ -802,7 +803,7 @@ The `mdx` snippet receives three parameters:
|
|
|
802
803
|
- `children`: Snippet containing parsed markdown content
|
|
803
804
|
|
|
804
805
|
Use `token.tagName` to determine which component is being rendered:
|
|
805
|
-
|
|
806
|
+
<Card title="Hello" count={5}>Content</Card>
|
|
806
807
|
```svelte
|
|
807
808
|
<!-- Markdown: <Card title="Hello" count={5}>Content</Card> -->
|
|
808
809
|
<Streamdown {content}>
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
popover.isOpen = false;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
$inspect(token);
|
|
40
42
|
</script>
|
|
41
43
|
|
|
42
44
|
{#if popover.isOpen}
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
{@attach clickOutside.attachment}
|
|
49
51
|
{@attach popover.popoverAttachment}
|
|
50
52
|
open
|
|
51
|
-
class={
|
|
53
|
+
class={streamdown.theme.components.popover}
|
|
52
54
|
>
|
|
53
55
|
<Slot
|
|
54
56
|
props={{
|
package/dist/Streamdown.svelte
CHANGED
|
@@ -40,7 +40,11 @@
|
|
|
40
40
|
const darkMode = useDarkMode();
|
|
41
41
|
|
|
42
42
|
const shikiThemedTheme = $derived(
|
|
43
|
-
shikiThemes
|
|
43
|
+
shikiThemes
|
|
44
|
+
? Object.keys(shikiThemes)[0] || 'github-light'
|
|
45
|
+
: darkMode.current
|
|
46
|
+
? 'github-dark'
|
|
47
|
+
: 'github-light'
|
|
44
48
|
);
|
|
45
49
|
|
|
46
50
|
const mermaidThemedTheme = $derived(
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {} from './index.js';
|
|
2
2
|
import { StreamdownContext } from '../context.svelte.js';
|
|
3
3
|
import { getContext } from 'svelte';
|
|
4
|
+
const footnoteRegex = /^\[\^([^\]\n]+)\]:(?:[ \t]+|\n|$)([^\n]*(?:\n(?:[ \t]+[^\n]*)?)*)/;
|
|
5
|
+
const footnoteRefRegex = /^\[\^([^\]\n]+)\]/;
|
|
6
|
+
const footNoteLastLineRegex = /^[ \t]*?[>\-*][ ]|[`]{3,}$|^[ \t]*?[|].+[|]$/;
|
|
4
7
|
const safeGetContext = () => {
|
|
5
8
|
try {
|
|
6
9
|
return getContext('streamdown');
|
|
@@ -32,18 +35,16 @@ export function markedFootnote() {
|
|
|
32
35
|
level: 'block',
|
|
33
36
|
tokenizer(src) {
|
|
34
37
|
const maps = ensureMaps(this);
|
|
35
|
-
const match =
|
|
38
|
+
const match = footnoteRegex.exec(src);
|
|
36
39
|
if (match) {
|
|
37
40
|
const [raw, label, text = ''] = match;
|
|
38
41
|
let content = text.split('\n').reduce((acc, curr) => {
|
|
39
|
-
return acc + '\n' + curr.replace(/^
|
|
42
|
+
return acc + '\n' + curr.replace(/^[ \t]+/, '');
|
|
40
43
|
}, '');
|
|
41
44
|
const contentLastLine = content.trimEnd().split('\n').pop();
|
|
42
45
|
content +=
|
|
43
46
|
// add lines after list, blockquote, codefence, and table
|
|
44
|
-
contentLastLine &&
|
|
45
|
-
? '\n\n'
|
|
46
|
-
: '';
|
|
47
|
+
contentLastLine && footNoteLastLineRegex.test(contentLastLine) ? '\n\n' : '';
|
|
47
48
|
const lines = content.split('\n');
|
|
48
49
|
const token = {
|
|
49
50
|
type: 'footnote',
|
|
@@ -66,7 +67,7 @@ export function markedFootnote() {
|
|
|
66
67
|
level: 'inline',
|
|
67
68
|
tokenizer(src) {
|
|
68
69
|
const maps = ensureMaps(this);
|
|
69
|
-
const match =
|
|
70
|
+
const match = footnoteRefRegex.exec(src);
|
|
70
71
|
if (match) {
|
|
71
72
|
const [raw, label] = match;
|
|
72
73
|
const footnote = maps.footnotes.get(label);
|