pd-markdown 2.0.2 → 2.0.3
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
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
- ⚛️ **React 组件** - 提供开箱即用的 React 渲染组件
|
|
12
12
|
- 🎨 **可定制** - 支持自定义组件覆盖(Heading, Code, Table 等)
|
|
13
13
|
- 🔗 **自动锚点** - 标题自动生成 slug 锚点
|
|
14
|
-
- 📦 **Tree-shakable** -
|
|
14
|
+
- 📦 **Tree-shakable** - 基于 ESM 设计,支持按需加载,最小化打包体积
|
|
15
|
+
- 🛠️ **现代兼容性** - 完美支持 Subpath Exports,确保在 Next.js、Vite 等现代开发环境下无缝解析
|
|
16
|
+
- 🛡️ **类型友好** - 完整的 TypeScript 定义,提供极致的开发体验
|
|
15
17
|
|
|
16
18
|
## 安装
|
|
17
19
|
|
|
@@ -29,10 +31,10 @@ yarn add pd-markdown
|
|
|
29
31
|
## 模块结构
|
|
30
32
|
|
|
31
33
|
| 模块路径 | 描述 |
|
|
32
|
-
|
|
|
33
|
-
| `pd-markdown/parser` |
|
|
34
|
-
| `pd-markdown/web` | React
|
|
35
|
-
| `pd-markdown/utils` |
|
|
34
|
+
| :--- | :--- |
|
|
35
|
+
| `pd-markdown/parser` | **核心解析器**:将 Markdown 转换为标准 AST |
|
|
36
|
+
| `pd-markdown/web` | **React 渲染层**:包含渲染组件与流式处理 Hooks |
|
|
37
|
+
| `pd-markdown/utils` | **通用工具**:提供 AST 遍历、Slug 生成及字符串处理 |
|
|
36
38
|
|
|
37
39
|
## 快速开始
|
|
38
40
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pd-markdown",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./packages/web/dist/index.cjs",
|
|
6
6
|
"module": "./packages/web/dist/index.mjs",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@rollup/rollup-darwin-arm64": "^4.57.1",
|
|
75
75
|
"@testing-library/jest-dom": "^6.9.1",
|
|
76
76
|
"@types/node": "^22.13.5",
|
|
77
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
77
78
|
"rollup": "^4.34.8",
|
|
78
79
|
"rollup-plugin-dts": "^6.1.1",
|
|
79
80
|
"tslib": "^2.8.1",
|
|
@@ -6,7 +6,7 @@ var remarkGfm = require('remark-gfm');
|
|
|
6
6
|
var remarkFrontmatter = require('remark-frontmatter');
|
|
7
7
|
var unistUtilVisit = require('unist-util-visit');
|
|
8
8
|
var yaml = require('yaml');
|
|
9
|
-
var pdMarkdownUtils = require('pd-markdown
|
|
9
|
+
var pdMarkdownUtils = require('pd-markdown/utils');
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Extract text content from phrasing content nodes
|
|
@@ -4,7 +4,7 @@ import remarkGfm from 'remark-gfm';
|
|
|
4
4
|
import remarkFrontmatter from 'remark-frontmatter';
|
|
5
5
|
import { visit } from 'unist-util-visit';
|
|
6
6
|
import { parse } from 'yaml';
|
|
7
|
-
import { uniqueSlugify } from 'pd-markdown
|
|
7
|
+
import { uniqueSlugify } from 'pd-markdown/utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Extract text content from phrasing content nodes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ReactNode, FC, CSSProperties } from 'react';
|
|
3
3
|
import { Heading as Heading$1, Paragraph as Paragraph$1, List as List$1, ListItem as ListItem$1, Table as Table$1, TableRow as TableRow$1, TableCell as TableCell$1, Code as Code$1, InlineCode, Link as Link$1, Image as Image$1, Blockquote as Blockquote$1, Root, Content } from 'mdast';
|
|
4
|
-
import { ParserOptions } from 'pd-markdown
|
|
4
|
+
import { ParserOptions } from 'pd-markdown/parser';
|
|
5
5
|
|
|
6
6
|
interface HeadingProps {
|
|
7
7
|
node: Heading$1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { createParser } from 'pd-markdown
|
|
2
|
+
import { createParser } from 'pd-markdown/parser';
|
|
3
3
|
import { createContext, useContext, useRef, useState, useEffect, useMemo, useCallback } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|