pd-markdown 1.0.0 → 1.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 +293 -0
- package/package.json +68 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.d.ts +0 -4
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.js +0 -5
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.d.ts +0 -4
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.js +0 -4
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.d.ts +0 -6
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.js +0 -36
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.d.ts +0 -14
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.js +0 -18
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.d.ts +0 -27
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.js +0 -37
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.d.ts +0 -22
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.js +0 -95
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.js.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.d.ts +0 -55
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.d.ts.map +0 -1
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.js +0 -2
- package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.js.map +0 -1
- package/packages/parser/__tests__/frontmatter.test.ts +0 -69
- package/packages/parser/__tests__/gfm.test.ts +0 -83
- package/packages/parser/__tests__/processor.test.ts +0 -136
- package/packages/parser/__tests__/transform/heading.test.ts +0 -56
- package/packages/parser/__tests__/transform/list.test.ts +0 -67
- package/packages/parser/__tests__/transform/table.test.ts +0 -85
- package/packages/parser/node_modules/.bin/yaml +0 -17
- package/packages/parser/package.json +0 -38
- package/packages/parser/rollup.config.ts +0 -38
- package/packages/parser/src/index.ts +0 -15
- package/packages/parser/src/plugins/index.ts +0 -3
- package/packages/parser/src/plugins/transform/heading.ts +0 -40
- package/packages/parser/src/plugins/transform/list.ts +0 -29
- package/packages/parser/src/plugins/transform/table.ts +0 -62
- package/packages/parser/src/processor.ts +0 -119
- package/packages/parser/src/types/index.ts +0 -60
- package/packages/parser/tsconfig.json +0 -9
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.d.ts +0 -36
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.js +0 -99
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.js.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.d.ts +0 -22
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.js +0 -46
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.js.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.d.ts +0 -7
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.js +0 -8
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.js.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.d.ts +0 -22
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.js +0 -140
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.js.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.d.ts +0 -16
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.js +0 -39
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.js.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.d.ts +0 -49
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.d.ts.map +0 -1
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.js +0 -19
- package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.js.map +0 -1
- package/packages/utils/__tests__/query.test.ts +0 -155
- package/packages/utils/__tests__/sanitize.test.ts +0 -96
- package/packages/utils/__tests__/slugify.test.ts +0 -71
- package/packages/utils/__tests__/traverse.test.ts +0 -131
- package/packages/utils/package.json +0 -27
- package/packages/utils/rollup.config.ts +0 -26
- package/packages/utils/src/ast/query.ts +0 -127
- package/packages/utils/src/ast/traverse.ts +0 -73
- package/packages/utils/src/index.ts +0 -20
- package/packages/utils/src/string/sanitize.ts +0 -155
- package/packages/utils/src/string/slugify.ts +0 -43
- package/packages/utils/src/types/index.ts +0 -72
- package/packages/utils/tsconfig.json +0 -8
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.d.ts +0 -27
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.js +0 -39
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.d.ts +0 -10
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.js +0 -130
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.d.ts +0 -17
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.js +0 -14
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.d.ts +0 -8
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.js +0 -5
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.d.ts +0 -13
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.js +0 -9
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.d.ts +0 -8
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.js +0 -7
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.d.ts +0 -7
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.js +0 -5
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.d.ts +0 -8
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.js +0 -7
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.d.ts +0 -13
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.js +0 -14
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.d.ts +0 -8
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.js +0 -5
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.d.ts +0 -19
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.js +0 -18
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.d.ts +0 -34
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.js +0 -28
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.d.ts +0 -11
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.js +0 -28
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.js.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.d.ts +0 -6
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.d.ts.map +0 -1
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.js +0 -9
- package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.js.map +0 -1
- package/packages/web/__tests__/MarkdownRenderer.test.tsx +0 -89
- package/packages/web/__tests__/NodeRenderer.test.tsx +0 -97
- package/packages/web/__tests__/components/Code.test.tsx +0 -71
- package/packages/web/__tests__/components/Heading.test.tsx +0 -65
- package/packages/web/__tests__/components/List.test.tsx +0 -100
- package/packages/web/__tests__/components/Table.test.tsx +0 -105
- package/packages/web/__tests__/useMarkdown.test.ts +0 -63
- package/packages/web/package.json +0 -40
- package/packages/web/rollup.config.ts +0 -36
- package/packages/web/src/components/MarkdownRenderer.tsx +0 -70
- package/packages/web/src/components/NodeRenderer.tsx +0 -205
- package/packages/web/src/components/context.ts +0 -24
- package/packages/web/src/components/defaults/Blockquote.tsx +0 -11
- package/packages/web/src/components/defaults/Code.tsx +0 -26
- package/packages/web/src/components/defaults/Heading.tsx +0 -14
- package/packages/web/src/components/defaults/Image.tsx +0 -10
- package/packages/web/src/components/defaults/Link.tsx +0 -18
- package/packages/web/src/components/defaults/List.tsx +0 -33
- package/packages/web/src/components/defaults/Paragraph.tsx +0 -11
- package/packages/web/src/components/defaults/Table.tsx +0 -50
- package/packages/web/src/components/defaults/index.tsx +0 -80
- package/packages/web/src/hooks/useMarkdown.ts +0 -32
- package/packages/web/src/index.ts +0 -37
- package/packages/web/tsconfig.json +0 -11
- package/packages/web/vitest.config.ts +0 -9
- package/pnpm-workspace.yaml +0 -2
- package/tsconfig.base.json +0 -26
- package/tsconfig.json +0 -8
- package/vitest.config.ts +0 -28
- package/vitest.setup.ts +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pd-markdown/parser",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Markdown parser based on unified/remark",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"import": "./dist/index.mjs",
|
|
9
|
-
"require": "./dist/index.cjs",
|
|
10
|
-
"types": "./dist/index.d.ts"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"main": "./dist/index.cjs",
|
|
14
|
-
"module": "./dist/index.mjs",
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "rollup -c rollup.config.ts --configPlugin typescript",
|
|
21
|
-
"clean": "rm -rf dist *.tsbuildinfo"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@pd-markdown/utils": "workspace:*",
|
|
25
|
-
"remark-frontmatter": "^5.0.0",
|
|
26
|
-
"remark-gfm": "^4.0.1",
|
|
27
|
-
"remark-parse": "^11.0.0",
|
|
28
|
-
"unified": "^11.0.5",
|
|
29
|
-
"unist-util-visit": "^5.0.0",
|
|
30
|
-
"yaml": "^2.7.0"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/mdast": "^4.0.4",
|
|
34
|
-
"vfile": "^6.0.3"
|
|
35
|
-
},
|
|
36
|
-
"sideEffects": false,
|
|
37
|
-
"license": "MIT"
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import typescript from '@rollup/plugin-typescript'
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve'
|
|
3
|
-
import commonjs from '@rollup/plugin-commonjs'
|
|
4
|
-
import { defineConfig } from 'rollup'
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
input: 'src/index.ts',
|
|
8
|
-
output: [
|
|
9
|
-
{
|
|
10
|
-
file: 'dist/index.mjs',
|
|
11
|
-
format: 'esm',
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
file: 'dist/index.cjs',
|
|
16
|
-
format: 'cjs',
|
|
17
|
-
sourcemap: true,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
plugins: [
|
|
21
|
-
resolve(),
|
|
22
|
-
commonjs(),
|
|
23
|
-
typescript({
|
|
24
|
-
tsconfig: './tsconfig.json',
|
|
25
|
-
declaration: true,
|
|
26
|
-
declarationDir: './dist',
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
29
|
-
external: [
|
|
30
|
-
'@pd-markdown/utils',
|
|
31
|
-
'unified',
|
|
32
|
-
'remark-parse',
|
|
33
|
-
'remark-gfm',
|
|
34
|
-
'remark-frontmatter',
|
|
35
|
-
'unist-util-visit',
|
|
36
|
-
'yaml',
|
|
37
|
-
],
|
|
38
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Types
|
|
2
|
-
export type {
|
|
3
|
-
Parser,
|
|
4
|
-
ParserOptions,
|
|
5
|
-
ParserPlugin,
|
|
6
|
-
PluginConfig,
|
|
7
|
-
FrontmatterData,
|
|
8
|
-
FileData,
|
|
9
|
-
} from './types'
|
|
10
|
-
|
|
11
|
-
// Core
|
|
12
|
-
export { createParser, definePlugin } from './processor'
|
|
13
|
-
|
|
14
|
-
// Transform plugins (for advanced usage)
|
|
15
|
-
export { transformHeading, transformList, transformTable } from './plugins'
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Root, Heading, PhrasingContent } from 'mdast'
|
|
2
|
-
import { visit } from 'unist-util-visit'
|
|
3
|
-
import { uniqueSlugify } from '@pd-markdown/utils'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Extract text content from phrasing content nodes
|
|
7
|
-
*/
|
|
8
|
-
function extractText(nodes: PhrasingContent[]): string {
|
|
9
|
-
return nodes
|
|
10
|
-
.map((node) => {
|
|
11
|
-
if (node.type === 'text') {
|
|
12
|
-
return node.value
|
|
13
|
-
}
|
|
14
|
-
if ('children' in node) {
|
|
15
|
-
return extractText(node.children as PhrasingContent[])
|
|
16
|
-
}
|
|
17
|
-
return ''
|
|
18
|
-
})
|
|
19
|
-
.join('')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Transform plugin that adds slug IDs to headings
|
|
24
|
-
*/
|
|
25
|
-
export function transformHeading(tree: Root): void {
|
|
26
|
-
const slugs = new Set<string>()
|
|
27
|
-
|
|
28
|
-
visit(tree, 'heading', (node: Heading) => {
|
|
29
|
-
const text = extractText(node.children)
|
|
30
|
-
const slug = uniqueSlugify(text, slugs)
|
|
31
|
-
|
|
32
|
-
// Add data.id to the heading node
|
|
33
|
-
const data = (node.data || {}) as Record<string, unknown>
|
|
34
|
-
data.id = slug
|
|
35
|
-
const hProperties = (data.hProperties || {}) as Record<string, string>
|
|
36
|
-
hProperties.id = slug
|
|
37
|
-
data.hProperties = hProperties
|
|
38
|
-
node.data = data
|
|
39
|
-
})
|
|
40
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Root, List, ListItem } from 'mdast'
|
|
2
|
-
import { visit } from 'unist-util-visit'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Extended list item with index
|
|
6
|
-
*/
|
|
7
|
-
declare module 'mdast' {
|
|
8
|
-
interface ListItemData {
|
|
9
|
-
index?: number
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Transform plugin that adds index to list items
|
|
15
|
-
*/
|
|
16
|
-
export function transformList(tree: Root): void {
|
|
17
|
-
visit(tree, 'list', (node: List) => {
|
|
18
|
-
node.children.forEach((item: ListItem, index: number) => {
|
|
19
|
-
item.data = item.data || {}
|
|
20
|
-
item.data.index = index
|
|
21
|
-
|
|
22
|
-
// For ordered lists, also store the actual number
|
|
23
|
-
if (node.ordered) {
|
|
24
|
-
const start = node.start ?? 1
|
|
25
|
-
item.data.index = start + index
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Root, Table, TableCell } from 'mdast'
|
|
2
|
-
import { visit } from 'unist-util-visit'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Extended table data
|
|
6
|
-
*/
|
|
7
|
-
declare module 'mdast' {
|
|
8
|
-
interface TableData {
|
|
9
|
-
/** Header row */
|
|
10
|
-
header?: TableRow
|
|
11
|
-
/** Body rows */
|
|
12
|
-
body?: TableRow[]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface TableCellData {
|
|
16
|
-
/** Whether this cell is in header */
|
|
17
|
-
isHeader?: boolean
|
|
18
|
-
/** Column alignment */
|
|
19
|
-
align?: 'left' | 'center' | 'right' | null
|
|
20
|
-
/** Column index */
|
|
21
|
-
columnIndex?: number
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Transform plugin that enhances table structure
|
|
27
|
-
* - Separates header and body rows
|
|
28
|
-
* - Adds alignment and index info to cells
|
|
29
|
-
*/
|
|
30
|
-
export function transformTable(tree: Root): void {
|
|
31
|
-
visit(tree, 'table', (node: Table) => {
|
|
32
|
-
if (node.children.length === 0) return
|
|
33
|
-
|
|
34
|
-
const [headerRow, ...bodyRows] = node.children
|
|
35
|
-
const align = node.align || []
|
|
36
|
-
|
|
37
|
-
// Mark header row and cells
|
|
38
|
-
if (headerRow) {
|
|
39
|
-
headerRow.children.forEach((cell: TableCell, index: number) => {
|
|
40
|
-
cell.data = cell.data || {}
|
|
41
|
-
cell.data.isHeader = true
|
|
42
|
-
cell.data.align = align[index] || null
|
|
43
|
-
cell.data.columnIndex = index
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Mark body cells
|
|
48
|
-
bodyRows.forEach((row) => {
|
|
49
|
-
row.children.forEach((cell: TableCell, index: number) => {
|
|
50
|
-
cell.data = cell.data || {}
|
|
51
|
-
cell.data.isHeader = false
|
|
52
|
-
cell.data.align = align[index] || null
|
|
53
|
-
cell.data.columnIndex = index
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
// Store structured data on table node
|
|
58
|
-
node.data = node.data || {}
|
|
59
|
-
node.data.header = headerRow
|
|
60
|
-
node.data.body = bodyRows
|
|
61
|
-
})
|
|
62
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { unified } from 'unified'
|
|
2
|
-
import remarkParse from 'remark-parse'
|
|
3
|
-
import remarkGfm from 'remark-gfm'
|
|
4
|
-
import remarkFrontmatter from 'remark-frontmatter'
|
|
5
|
-
import { visit } from 'unist-util-visit'
|
|
6
|
-
import { parse as parseYaml } from 'yaml'
|
|
7
|
-
import type { Root, Yaml } from 'mdast'
|
|
8
|
-
import type { VFile } from 'vfile'
|
|
9
|
-
|
|
10
|
-
import type { Parser, ParserOptions, ParserPlugin, FileData } from './types'
|
|
11
|
-
import { transformHeading, transformList, transformTable } from './plugins'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Default parser options
|
|
15
|
-
*/
|
|
16
|
-
const DEFAULT_OPTIONS: Required<Omit<ParserOptions, 'plugins'>> = {
|
|
17
|
-
gfm: true,
|
|
18
|
-
frontmatter: true,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create frontmatter extraction plugin
|
|
23
|
-
*/
|
|
24
|
-
function extractFrontmatter() {
|
|
25
|
-
return (tree: Root, file: VFile) => {
|
|
26
|
-
visit(tree, 'yaml', (node: Yaml) => {
|
|
27
|
-
try {
|
|
28
|
-
const data = parseYaml(node.value) as Record<string, unknown>
|
|
29
|
-
;(file.data as FileData).frontmatter = data
|
|
30
|
-
} catch {
|
|
31
|
-
// Invalid YAML, ignore
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create a markdown parser with the specified options
|
|
39
|
-
*
|
|
40
|
-
* @param options - Parser configuration options
|
|
41
|
-
* @returns Parser instance with parse method
|
|
42
|
-
*/
|
|
43
|
-
export function createParser(options: ParserOptions = {}): Parser {
|
|
44
|
-
const opts = { ...DEFAULT_OPTIONS, ...options }
|
|
45
|
-
const customPlugins = options.plugins || []
|
|
46
|
-
|
|
47
|
-
// Build processor (使用 any 绕过复杂的类型检查)
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
let processor: any = unified().use(remarkParse)
|
|
50
|
-
|
|
51
|
-
// Add GFM support
|
|
52
|
-
if (opts.gfm) {
|
|
53
|
-
processor = processor.use(remarkGfm)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Add frontmatter support
|
|
57
|
-
if (opts.frontmatter) {
|
|
58
|
-
processor = processor.use(remarkFrontmatter, ['yaml'])
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Run custom "before" plugins
|
|
62
|
-
const beforePlugins = customPlugins.filter((p) => p.phase === 'before')
|
|
63
|
-
for (const plugin of beforePlugins) {
|
|
64
|
-
processor = processor.use(() => plugin.transform)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Add frontmatter extraction
|
|
68
|
-
if (opts.frontmatter) {
|
|
69
|
-
processor = processor.use(extractFrontmatter)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Add built-in transform plugins
|
|
73
|
-
processor = processor
|
|
74
|
-
.use(() => transformHeading)
|
|
75
|
-
.use(() => transformList)
|
|
76
|
-
.use(() => transformTable)
|
|
77
|
-
|
|
78
|
-
// Run custom "after" plugins
|
|
79
|
-
const afterPlugins = customPlugins.filter((p) => p.phase === 'after')
|
|
80
|
-
for (const plugin of afterPlugins) {
|
|
81
|
-
processor = processor.use(() => plugin.transform)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Freeze processor
|
|
85
|
-
processor.freeze()
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
parse(content: string): Root {
|
|
89
|
-
// Parse markdown to AST
|
|
90
|
-
const tree = processor.parse(content) as Root
|
|
91
|
-
|
|
92
|
-
// Run all transform plugins
|
|
93
|
-
processor.runSync(tree)
|
|
94
|
-
|
|
95
|
-
return tree
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Type-safe helper to define a parser plugin
|
|
102
|
-
*
|
|
103
|
-
* @param config - Plugin configuration
|
|
104
|
-
* @returns Parser plugin
|
|
105
|
-
*/
|
|
106
|
-
export function definePlugin<T = void>(
|
|
107
|
-
config: {
|
|
108
|
-
name: string
|
|
109
|
-
phase: 'before' | 'after'
|
|
110
|
-
transform: (options?: T) => (tree: Root, file: VFile) => void
|
|
111
|
-
},
|
|
112
|
-
options?: T
|
|
113
|
-
): ParserPlugin {
|
|
114
|
-
return {
|
|
115
|
-
name: config.name,
|
|
116
|
-
phase: config.phase,
|
|
117
|
-
transform: config.transform(options),
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast'
|
|
2
|
-
import type { VFile } from 'vfile'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Parser plugin configuration
|
|
6
|
-
*/
|
|
7
|
-
export interface ParserPlugin {
|
|
8
|
-
/** Unique plugin name */
|
|
9
|
-
name: string
|
|
10
|
-
/** When to run: before or after built-in transforms */
|
|
11
|
-
phase: 'before' | 'after'
|
|
12
|
-
/** Transform function */
|
|
13
|
-
transform: (tree: Root, file: VFile) => void
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Parser options
|
|
18
|
-
*/
|
|
19
|
-
export interface ParserOptions {
|
|
20
|
-
/** Custom plugins to add */
|
|
21
|
-
plugins?: ParserPlugin[]
|
|
22
|
-
/** Enable GFM syntax (default: true) */
|
|
23
|
-
gfm?: boolean
|
|
24
|
-
/** Enable frontmatter parsing (default: true) */
|
|
25
|
-
frontmatter?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Parser instance
|
|
30
|
-
*/
|
|
31
|
-
export interface Parser {
|
|
32
|
-
/** Parse markdown string to AST */
|
|
33
|
-
parse(content: string): Root
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Plugin definition helper config
|
|
38
|
-
*/
|
|
39
|
-
export interface PluginConfig<T = unknown> {
|
|
40
|
-
/** Plugin name */
|
|
41
|
-
name: string
|
|
42
|
-
/** When to run */
|
|
43
|
-
phase: 'before' | 'after'
|
|
44
|
-
/** Transform function factory */
|
|
45
|
-
transform: (options?: T) => (tree: Root, file: VFile) => void
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Frontmatter data extracted from markdown
|
|
50
|
-
*/
|
|
51
|
-
export interface FrontmatterData {
|
|
52
|
-
[key: string]: unknown
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Extended file data with frontmatter
|
|
57
|
-
*/
|
|
58
|
-
export interface FileData {
|
|
59
|
-
frontmatter?: FrontmatterData
|
|
60
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Node } from 'unist';
|
|
2
|
-
import type { MdNode, Parent } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Find all nodes of a specific type in the AST
|
|
5
|
-
*
|
|
6
|
-
* @param node - Root node to search from
|
|
7
|
-
* @param type - Node type to find
|
|
8
|
-
* @returns Array of matching nodes
|
|
9
|
-
*/
|
|
10
|
-
export declare function findNodes<T extends Node = MdNode>(node: Node, type: string): T[];
|
|
11
|
-
/**
|
|
12
|
-
* Find the first node of a specific type in the AST
|
|
13
|
-
*
|
|
14
|
-
* @param node - Root node to search from
|
|
15
|
-
* @param type - Node type to find
|
|
16
|
-
* @returns The first matching node or undefined
|
|
17
|
-
*/
|
|
18
|
-
export declare function findNode<T extends Node = MdNode>(node: Node, type: string): T | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Find all nodes matching a predicate
|
|
21
|
-
*
|
|
22
|
-
* @param node - Root node to search from
|
|
23
|
-
* @param predicate - Function to test each node
|
|
24
|
-
* @returns Array of matching nodes
|
|
25
|
-
*/
|
|
26
|
-
export declare function findNodesBy<T extends Node = MdNode>(node: Node, predicate: (node: Node) => boolean): T[];
|
|
27
|
-
/**
|
|
28
|
-
* Get the parent of a node in the AST
|
|
29
|
-
* Note: This requires traversing from root, use sparingly
|
|
30
|
-
*
|
|
31
|
-
* @param root - Root node of the AST
|
|
32
|
-
* @param target - Node to find parent of
|
|
33
|
-
* @returns Parent node or undefined if not found or is root
|
|
34
|
-
*/
|
|
35
|
-
export declare function findParent(root: Node, target: Node): Parent | undefined;
|
|
36
|
-
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/ast/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAG9C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,GAAG,MAAM,EAC/C,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,GACX,CAAC,EAAE,CAiBL;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,IAAI,GAAG,MAAM,EAC9C,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS,CAsBf;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,GAAG,MAAM,EACjD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GACjC,CAAC,EAAE,CAiBL;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAsBvE"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { isParent } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Find all nodes of a specific type in the AST
|
|
4
|
-
*
|
|
5
|
-
* @param node - Root node to search from
|
|
6
|
-
* @param type - Node type to find
|
|
7
|
-
* @returns Array of matching nodes
|
|
8
|
-
*/
|
|
9
|
-
export function findNodes(node, type) {
|
|
10
|
-
const results = [];
|
|
11
|
-
function visit(current) {
|
|
12
|
-
if (current.type === type) {
|
|
13
|
-
results.push(current);
|
|
14
|
-
}
|
|
15
|
-
if (isParent(current)) {
|
|
16
|
-
for (const child of current.children) {
|
|
17
|
-
visit(child);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
visit(node);
|
|
22
|
-
return results;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Find the first node of a specific type in the AST
|
|
26
|
-
*
|
|
27
|
-
* @param node - Root node to search from
|
|
28
|
-
* @param type - Node type to find
|
|
29
|
-
* @returns The first matching node or undefined
|
|
30
|
-
*/
|
|
31
|
-
export function findNode(node, type) {
|
|
32
|
-
let result;
|
|
33
|
-
function visit(current) {
|
|
34
|
-
if (current.type === type) {
|
|
35
|
-
result = current;
|
|
36
|
-
return true; // Found, stop searching
|
|
37
|
-
}
|
|
38
|
-
if (isParent(current)) {
|
|
39
|
-
for (const child of current.children) {
|
|
40
|
-
if (visit(child)) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
visit(node);
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Find all nodes matching a predicate
|
|
52
|
-
*
|
|
53
|
-
* @param node - Root node to search from
|
|
54
|
-
* @param predicate - Function to test each node
|
|
55
|
-
* @returns Array of matching nodes
|
|
56
|
-
*/
|
|
57
|
-
export function findNodesBy(node, predicate) {
|
|
58
|
-
const results = [];
|
|
59
|
-
function visit(current) {
|
|
60
|
-
if (predicate(current)) {
|
|
61
|
-
results.push(current);
|
|
62
|
-
}
|
|
63
|
-
if (isParent(current)) {
|
|
64
|
-
for (const child of current.children) {
|
|
65
|
-
visit(child);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
visit(node);
|
|
70
|
-
return results;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get the parent of a node in the AST
|
|
74
|
-
* Note: This requires traversing from root, use sparingly
|
|
75
|
-
*
|
|
76
|
-
* @param root - Root node of the AST
|
|
77
|
-
* @param target - Node to find parent of
|
|
78
|
-
* @returns Parent node or undefined if not found or is root
|
|
79
|
-
*/
|
|
80
|
-
export function findParent(root, target) {
|
|
81
|
-
let result;
|
|
82
|
-
function visit(current, parent) {
|
|
83
|
-
if (current === target) {
|
|
84
|
-
result = parent;
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
if (isParent(current)) {
|
|
88
|
-
for (const child of current.children) {
|
|
89
|
-
if (visit(child, current)) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
visit(root, undefined);
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/ast/query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,IAAU,EACV,IAAY;IAEZ,MAAM,OAAO,GAAQ,EAAE,CAAA;IAEvB,SAAS,KAAK,CAAC,OAAa;QAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,OAAY,CAAC,CAAA;QAC5B,CAAC;QAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,CAAA;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAA;IACX,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAU,EACV,IAAY;IAEZ,IAAI,MAAqB,CAAA;IAEzB,SAAS,KAAK,CAAC,OAAa;QAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC1B,MAAM,GAAG,OAAY,CAAA;YACrB,OAAO,IAAI,CAAA,CAAC,wBAAwB;QACtC,CAAC;QAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;oBACjB,OAAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAA;IACX,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,IAAU,EACV,SAAkC;IAElC,MAAM,OAAO,GAAQ,EAAE,CAAA;IAEvB,SAAS,KAAK,CAAC,OAAa;QAC1B,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,OAAY,CAAC,CAAA;QAC5B,CAAC;QAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,CAAA;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAA;IACX,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,MAAY;IACjD,IAAI,MAA0B,CAAA;IAE9B,SAAS,KAAK,CAAC,OAAa,EAAE,MAA0B;QACtD,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;YACvB,MAAM,GAAG,MAAM,CAAA;YACf,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;oBAC1B,OAAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IACtB,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Node } from 'unist';
|
|
2
|
-
import type { MdNode, Visitor } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Traverse AST in depth-first order
|
|
5
|
-
*
|
|
6
|
-
* @param node - Root node to start traversal
|
|
7
|
-
* @param visitor - Visitor function called for each node
|
|
8
|
-
* Return `false` to skip children of current node
|
|
9
|
-
* Return `true` or `undefined` to continue
|
|
10
|
-
*/
|
|
11
|
-
export declare function traverseAst<T extends Node = MdNode>(node: T, visitor: Visitor<T>): void;
|
|
12
|
-
/**
|
|
13
|
-
* Traverse AST with enter and leave callbacks
|
|
14
|
-
*
|
|
15
|
-
* @param node - Root node to start traversal
|
|
16
|
-
* @param callbacks - Object with optional enter and leave functions
|
|
17
|
-
*/
|
|
18
|
-
export declare function traverseAstWithCallbacks<T extends Node = MdNode>(node: T, callbacks: {
|
|
19
|
-
enter?: Visitor<T>;
|
|
20
|
-
leave?: Visitor<T>;
|
|
21
|
-
}): void;
|
|
22
|
-
//# sourceMappingURL=traverse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/ast/traverse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAU,MAAM,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGvD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,IAAI,GAAG,MAAM,EACjD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,IAAI,CAsBN;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,IAAI,GAAG,MAAM,EAC9D,IAAI,EAAE,CAAC,EACP,SAAS,EAAE;IACT,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CACnB,GACA,IAAI,CAqBN"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { isParent } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Traverse AST in depth-first order
|
|
4
|
-
*
|
|
5
|
-
* @param node - Root node to start traversal
|
|
6
|
-
* @param visitor - Visitor function called for each node
|
|
7
|
-
* Return `false` to skip children of current node
|
|
8
|
-
* Return `true` or `undefined` to continue
|
|
9
|
-
*/
|
|
10
|
-
export function traverseAst(node, visitor) {
|
|
11
|
-
function visit(current, index, parent) {
|
|
12
|
-
const result = visitor(current, index, parent);
|
|
13
|
-
// Skip children if visitor returns false
|
|
14
|
-
if (result === false) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (isParent(current)) {
|
|
18
|
-
const children = current.children;
|
|
19
|
-
for (let i = 0; i < children.length; i++) {
|
|
20
|
-
visit(children[i], i, current);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
visit(node, undefined, undefined);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Traverse AST with enter and leave callbacks
|
|
28
|
-
*
|
|
29
|
-
* @param node - Root node to start traversal
|
|
30
|
-
* @param callbacks - Object with optional enter and leave functions
|
|
31
|
-
*/
|
|
32
|
-
export function traverseAstWithCallbacks(node, callbacks) {
|
|
33
|
-
const { enter, leave } = callbacks;
|
|
34
|
-
function visit(current, index, parent) {
|
|
35
|
-
const shouldSkipChildren = enter?.(current, index, parent) === false;
|
|
36
|
-
if (!shouldSkipChildren && isParent(current)) {
|
|
37
|
-
const children = current.children;
|
|
38
|
-
for (let i = 0; i < children.length; i++) {
|
|
39
|
-
visit(children[i], i, current);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
leave?.(current, index, parent);
|
|
43
|
-
}
|
|
44
|
-
visit(node, undefined, undefined);
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=traverse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/ast/traverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,IAAO,EACP,OAAmB;IAEnB,SAAS,KAAK,CACZ,OAAU,EACV,KAAyB,EACzB,MAA0B;QAE1B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAE9C,yCAAyC;QACzC,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YACrB,OAAM;QACR,CAAC;QAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAA;YACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAA4B,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAO,EACP,SAGC;IAED,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAA;IAElC,SAAS,KAAK,CACZ,OAAU,EACV,KAAyB,EACzB,MAA0B;QAE1B,MAAM,kBAAkB,GAAG,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,CAAA;QAEpE,IAAI,CAAC,kBAAkB,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAA;YACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAA4B,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;QAED,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { MdNode, MdRoot, Parent, Literal, Visitor, PluginOptions, Position, Location, } from './types';
|
|
2
|
-
export { isParent, isLiteral, isNodeType } from './types';
|
|
3
|
-
export { traverseAst, traverseAstWithCallbacks } from './ast/traverse';
|
|
4
|
-
export { findNodes, findNode, findNodesBy, findParent } from './ast/query';
|
|
5
|
-
export { slugify, uniqueSlugify } from './string/slugify';
|
|
6
|
-
export { escapeHtml, sanitizeHtml, stripHtml } from './string/sanitize';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,GACT,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzD,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG1E,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA"}
|
package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { isParent, isLiteral, isNodeType } from './types';
|
|
2
|
-
// AST utilities
|
|
3
|
-
export { traverseAst, traverseAstWithCallbacks } from './ast/traverse';
|
|
4
|
-
export { findNodes, findNode, findNodesBy, findParent } from './ast/query';
|
|
5
|
-
// String utilities
|
|
6
|
-
export { slugify, uniqueSlugify } from './string/slugify';
|
|
7
|
-
export { escapeHtml, sanitizeHtml, stripHtml } from './string/sanitize';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzD,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE1E,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA"}
|