svmarkdown 0.1.0
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/LICENSE +21 -0
- package/README.md +210 -0
- package/README.zh-CN.md +208 -0
- package/dist/Markdown.svelte.d.ts +11 -0
- package/dist/SvmdChildren-V6hrbwsd.js +853 -0
- package/dist/SvmdChildren.svelte.d.ts +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/internal/RenderNode.svelte.d.ts +9 -0
- package/dist/internal/RenderNodes.svelte.d.ts +9 -0
- package/dist/parser.d.ts +5 -0
- package/dist/types.d.ts +76 -0
- package/package.json +63 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SvmdComponentMap, SvmdNode, SvmdRenderOptions } from './types';
|
|
2
|
+
interface Props {
|
|
3
|
+
nodes: SvmdNode[];
|
|
4
|
+
components?: SvmdComponentMap;
|
|
5
|
+
renderOptions?: SvmdRenderOptions;
|
|
6
|
+
}
|
|
7
|
+
declare const SvmdChildren: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SvmdChildren = ReturnType<typeof SvmdChildren>;
|
|
9
|
+
export default SvmdChildren;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Markdown } from './Markdown.svelte';
|
|
2
|
+
export { default as SvmdChildren } from './SvmdChildren.svelte';
|
|
3
|
+
export { createParser, inferComponentBlocksFromMap, parseMarkdown } from './parser';
|
|
4
|
+
export type { SvmdBreakNode, SvmdCodeNode, SvmdComponent, SvmdComponentBlockConfig, SvmdComponentBlocks, SvmdComponentMap, SvmdComponentNode, SvmdElementNode, SvmdHtmlNode, SvmdMarkdownItPlugin, SvmdNode, SvmdParseOptions, SvmdProps, SvmdRenderOptions, SvmdRoot, SvmdTextNode, } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SvmdComponentMap, SvmdNode, SvmdRenderOptions } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
node: SvmdNode;
|
|
4
|
+
components?: SvmdComponentMap;
|
|
5
|
+
renderOptions?: SvmdRenderOptions;
|
|
6
|
+
}
|
|
7
|
+
declare const RenderNode: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type RenderNode = ReturnType<typeof RenderNode>;
|
|
9
|
+
export default RenderNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SvmdComponentMap, SvmdNode, SvmdRenderOptions } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
nodes: SvmdNode[];
|
|
4
|
+
components?: SvmdComponentMap;
|
|
5
|
+
renderOptions?: SvmdRenderOptions;
|
|
6
|
+
}
|
|
7
|
+
declare const RenderNodes: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type RenderNodes = ReturnType<typeof RenderNodes>;
|
|
9
|
+
export default RenderNodes;
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SvmdComponentBlocks, SvmdParseOptions, SvmdRoot } from './types';
|
|
2
|
+
export type SvmdParser = (markdown: string) => SvmdRoot;
|
|
3
|
+
export declare function createParser(options?: SvmdParseOptions): SvmdParser;
|
|
4
|
+
export declare function parseMarkdown(markdown: string, options?: SvmdParseOptions): SvmdRoot;
|
|
5
|
+
export declare function inferComponentBlocksFromMap(components: Record<string, unknown>): SvmdComponentBlocks;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type MarkdownIt from 'markdown-it';
|
|
2
|
+
import type { Options as MarkdownItOptions, PluginSimple as MarkdownItPluginSimple, PluginWithOptions as MarkdownItPluginWithOptions, PluginWithParams as MarkdownItPluginWithParams } from 'markdown-it';
|
|
3
|
+
import type { Component } from 'svelte';
|
|
4
|
+
export type SvmdPrimitive = string | number | boolean | null;
|
|
5
|
+
export type SvmdPropValue = SvmdPrimitive | SvmdPropValue[] | {
|
|
6
|
+
[key: string]: SvmdPropValue;
|
|
7
|
+
};
|
|
8
|
+
export type SvmdProps = Record<string, SvmdPropValue>;
|
|
9
|
+
interface SvmdNodeBase {
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SvmdRoot {
|
|
13
|
+
kind: 'root';
|
|
14
|
+
children: SvmdNode[];
|
|
15
|
+
}
|
|
16
|
+
export interface SvmdTextNode extends SvmdNodeBase {
|
|
17
|
+
kind: 'text';
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SvmdBreakNode extends SvmdNodeBase {
|
|
21
|
+
kind: 'break';
|
|
22
|
+
hard: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface SvmdHtmlNode extends SvmdNodeBase {
|
|
25
|
+
kind: 'html';
|
|
26
|
+
value: string;
|
|
27
|
+
block: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface SvmdElementNode extends SvmdNodeBase {
|
|
30
|
+
kind: 'element';
|
|
31
|
+
name: string;
|
|
32
|
+
attrs: Record<string, string>;
|
|
33
|
+
children: SvmdNode[];
|
|
34
|
+
block: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface SvmdCodeNode extends SvmdNodeBase {
|
|
37
|
+
kind: 'code';
|
|
38
|
+
inline: boolean;
|
|
39
|
+
text: string;
|
|
40
|
+
lang?: string;
|
|
41
|
+
info?: string;
|
|
42
|
+
attrs: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
export interface SvmdComponentNode extends SvmdNodeBase {
|
|
45
|
+
kind: 'component';
|
|
46
|
+
name: string;
|
|
47
|
+
syntax: 'container' | 'fence';
|
|
48
|
+
props: SvmdProps;
|
|
49
|
+
children: SvmdNode[];
|
|
50
|
+
source?: string;
|
|
51
|
+
}
|
|
52
|
+
export type SvmdNode = SvmdTextNode | SvmdBreakNode | SvmdHtmlNode | SvmdElementNode | SvmdCodeNode | SvmdComponentNode;
|
|
53
|
+
export type SvmdComponent = Component<any>;
|
|
54
|
+
export type SvmdComponentMap = Record<string, SvmdComponent | undefined>;
|
|
55
|
+
export type SvmdMarkdownItPlugin = MarkdownItPluginSimple | MarkdownItPluginWithParams | [MarkdownItPluginSimple | MarkdownItPluginWithOptions<any> | MarkdownItPluginWithParams, ...unknown[]];
|
|
56
|
+
export interface SvmdComponentBlockConfig {
|
|
57
|
+
container?: boolean;
|
|
58
|
+
fence?: boolean;
|
|
59
|
+
parseFenceBodyAsMarkdown?: boolean;
|
|
60
|
+
parseProps?: (raw: string, context: {
|
|
61
|
+
name: string;
|
|
62
|
+
syntax: 'container' | 'fence';
|
|
63
|
+
}) => SvmdProps;
|
|
64
|
+
}
|
|
65
|
+
export type SvmdComponentBlocks = Record<string, boolean | SvmdComponentBlockConfig>;
|
|
66
|
+
export interface SvmdParseOptions {
|
|
67
|
+
markdownIt?: MarkdownIt;
|
|
68
|
+
markdownItOptions?: MarkdownItOptions;
|
|
69
|
+
markdownItPlugins?: SvmdMarkdownItPlugin[];
|
|
70
|
+
componentBlocks?: SvmdComponentBlocks;
|
|
71
|
+
fenceComponentPrefix?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface SvmdRenderOptions {
|
|
74
|
+
allowDangerousHtml?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svmarkdown",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Runtime markdown renderer for Svelte based on markdown-it and AST blocks.",
|
|
6
|
+
"author": "grtsinry43",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/grtsinry43/svmarkdown#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/grtsinry43/svmarkdown.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/grtsinry43/svmarkdown/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"svelte": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
34
|
+
"@tsconfig/svelte": "^5.0.6",
|
|
35
|
+
"@types/markdown-it": "^14.1.2",
|
|
36
|
+
"@types/markdown-it-container": "^4.0.0",
|
|
37
|
+
"@types/node": "^25.0.3",
|
|
38
|
+
"@vitest/browser-playwright": "^4.0.16",
|
|
39
|
+
"bumpp": "^10.3.2",
|
|
40
|
+
"rollup-plugin-svelte": "^7.2.3",
|
|
41
|
+
"svelte": "^5.46.0",
|
|
42
|
+
"svelte-check": "^4.3.4",
|
|
43
|
+
"svelte-preprocess": "^6.0.3",
|
|
44
|
+
"svelte2tsx": "^0.7.45",
|
|
45
|
+
"tsdown": "0.18.1",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vite": "^7.3.0",
|
|
48
|
+
"vitest": "^4.0.16",
|
|
49
|
+
"vitest-browser-svelte": "^2.0.1"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"markdown-it": "^14.1.0",
|
|
53
|
+
"markdown-it-container": "^4.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsdown",
|
|
57
|
+
"dev": "tsdown --watch",
|
|
58
|
+
"play": "vite",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"typecheck": "svelte-check --tsconfig ./tsconfig.json",
|
|
61
|
+
"release": "bumpp && pnpm publish"
|
|
62
|
+
}
|
|
63
|
+
}
|