@mathcrowd/mmarked 1.8.2 → 1.8.4
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/CHANGELOG.md +13 -0
- package/README.md +31 -31
- package/README.zh.md +109 -0
- package/dist/browser.umd.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/icon.png +0 -0
- package/package.json +18 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [1.8.4](https://cloud.mathcrowd.cn:2444/agile/frontend/mathcrowd-marked-lib/compare/v1.8.3...v1.8.4) (2024-12-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## [1.8.3](https://cloud.mathcrowd.cn:2444/agile/frontend/mathcrowd-marked-lib/compare/v1.8.2...v1.8.3) (2024-12-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* eslint upgraded to v9. ([806c4c1](https://cloud.mathcrowd.cn:2444/agile/frontend/mathcrowd-marked-lib/commits/806c4c15b02e8f18a09b8032be6c2d57e596ba0a))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [1.8.2](https://cloud.mathcrowd.cn:2444/agile/frontend/mathcrowd-marked-lib/compare/v1.8.1...v1.8.2) (2024-10-29)
|
|
2
15
|
|
|
3
16
|
|
package/README.md
CHANGED
|
@@ -3,25 +3,31 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/%40mathcrowd%2Fmmarked)
|
|
4
4
|
[](https://creativecommons.org/licenses/by-nc/4.0)
|
|
5
5
|
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
[中文](./README.zh.md)
|
|
9
|
+
|
|
6
10
|
A powerful TypeScript library for rendering customized markdown syntax with LaTeX support, designed for mathematical visualization in educational contexts.
|
|
7
11
|
|
|
8
12
|
## 🌟 Features
|
|
9
13
|
|
|
10
|
-
- ✅ **Full CommonMark syntax support:** Comprehensive compatibility with CommonMark standards
|
|
11
|
-
- 🔢 **Footnotes Blocks:**
|
|
12
|
-
- 📘 **Theorem-like blocks:**
|
|
13
|
-
- 🖼️ **Image resizing capabilities:**
|
|
14
|
-
- 🔍 **Hidden/
|
|
15
|
-
- 🧮 **TeX to SVG conversion:**
|
|
16
|
-
- 🔗 **Easy Integration with Existing Systems:**
|
|
14
|
+
- ✅ **Full CommonMark syntax support:** Comprehensive compatibility with CommonMark standards
|
|
15
|
+
- 🔢 **Footnotes Blocks:** Support for auto-numbered footnotes with easy reference links
|
|
16
|
+
- 📘 **Theorem-like blocks:** Support for mathematical theorems, lemmas, and examples in a block format with titles, auto-numbering, and reference links
|
|
17
|
+
- 🖼️ **Image resizing capabilities:** Customizable rendering of images and videos using simple syntax
|
|
18
|
+
- 🔍 **Hidden/Show solution blocks:** Solution blocks with toggle buttons for easy visibility control, implemented with straightforward syntax
|
|
19
|
+
- 🧮 **TeX to SVG conversion:** Conversion of TeX equations to scalable vector graphics for high-quality rendering
|
|
20
|
+
- 🔗 **Easy Integration with Existing Systems:** Support for both server-side and browser-side implementations
|
|
17
21
|
|
|
18
22
|
## 🚀 Quick Start
|
|
19
23
|
|
|
20
|
-
### Editor
|
|
24
|
+
### Editor Integration
|
|
25
|
+
|
|
26
|
+
Use mmarked in VSCode: https://marketplace.visualstudio.com/items?itemName=MCLab.mmarked
|
|
21
27
|
|
|
22
|
-
Use mmarked in
|
|
28
|
+
Use mmarked in Logseq: https://github.com/mathedu4all/mmarked-logseq-extension
|
|
23
29
|
|
|
24
|
-
### Server
|
|
30
|
+
### Server-Side Integration
|
|
25
31
|
|
|
26
32
|
#### Installation
|
|
27
33
|
|
|
@@ -41,29 +47,25 @@ const svg = tex2svg('$x^2$')
|
|
|
41
47
|
const html = renderMarkdown('### Heading').parsed
|
|
42
48
|
```
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
### Web Browser Side Integration
|
|
50
|
+
### Browser-Side Integration
|
|
46
51
|
|
|
47
52
|
```html
|
|
48
|
-
<!
|
|
53
|
+
<!DOCTYPE html>
|
|
49
54
|
<html>
|
|
50
|
-
|
|
51
55
|
<head>
|
|
52
|
-
<meta charset="utf-8"
|
|
56
|
+
<meta charset="utf-8">
|
|
53
57
|
<title>Marked in the browser</title>
|
|
54
58
|
</head>
|
|
55
|
-
|
|
56
59
|
<body>
|
|
57
60
|
<div id="content"></div>
|
|
58
61
|
<script src="dist/browser.umd.js"></script>
|
|
59
62
|
<script>
|
|
60
|
-
const { tex2svg, renderMarkdown } = marked
|
|
61
|
-
document.getElementById('content').innerHTML =
|
|
63
|
+
const { tex2svg, renderMarkdown } = marked;
|
|
64
|
+
document.getElementById('content').innerHTML =
|
|
62
65
|
tex2svg(renderMarkdown('# Marked in the browser \n\n $x^2+y^2=1$ \n\nRendered by **mmarked**.').parsed);
|
|
63
|
-
console.log(renderMarkdown('# Marked in the browser\n\nRendered by **mmarked**.').lexed)
|
|
66
|
+
console.log(renderMarkdown('# Marked in the browser\n\nRendered by **mmarked**.').lexed);
|
|
64
67
|
</script>
|
|
65
68
|
</body>
|
|
66
|
-
|
|
67
69
|
</html>
|
|
68
70
|
```
|
|
69
71
|
|
|
@@ -72,8 +74,8 @@ const html = renderMarkdown('### Heading').parsed
|
|
|
72
74
|
| Function | Description |
|
|
73
75
|
|----------|-------------|
|
|
74
76
|
| `tex2svg(tex: string): string` | Converts TeX to SVG in HTML format |
|
|
75
|
-
| `renderMarkdown(markdown: string): {parsed:string, lexed: Token[], time: number}` | Renders Markdown to HTML |
|
|
76
|
-
| `renderMarkdownCompact(markdown: string): {parsed:string, lexed: Token[], time: number}` | Renders Markdown to HTML without `<p>` tags |
|
|
77
|
+
| `renderMarkdown(markdown: string): {parsed: string, lexed: Token[], time: number}` | Renders Markdown to HTML |
|
|
78
|
+
| `renderMarkdownCompact(markdown: string): {parsed: string, lexed: Token[], time: number}` | Renders Markdown to HTML without `<p>` tags |
|
|
77
79
|
|
|
78
80
|
⚠️ **Important**: Always purify the output HTML using [DOMPurify](https://github.com/cure53/DOMPurify) to prevent XSS attacks.
|
|
79
81
|
|
|
@@ -83,23 +85,21 @@ For detailed documentation in Chinese, visit our [Product Page](https://lab.math
|
|
|
83
85
|
|
|
84
86
|
## 🎮 Demo
|
|
85
87
|
|
|
86
|
-
Try out our interactive demo [here](https://mathedu4all.github.io/mmarked/
|
|
88
|
+
Try out our interactive demo [here](https://mathedu4all.github.io/mmarked/).
|
|
87
89
|
|
|
88
90
|
## 👥 About Mathcrowd
|
|
89
91
|
|
|
90
92
|
Mathcrowd is an innovative startup founded by experienced independent developers and mathematics educators. We're on a mission to revolutionize math education in China through cutting-edge technology. Our goal is to create an engaging online community for math enthusiasts and self-learners, offering rich, interactive, and visualized learning content.
|
|
91
93
|
|
|
92
|
-
🌐 MCLab Official Website: [https://lab.mathcrowd.cn](https://lab.mathcrowd.cn)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
💬 Join Our Discord: https://discord.gg/6VMUVA5Yq2
|
|
94
|
+
🌐 MCLab Official Website: [https://lab.mathcrowd.cn](https://lab.mathcrowd.cn)
|
|
95
|
+
🌐 Our Online Math Community: [https://www.mathcrowd.cn](https://www.mathcrowd.cn)
|
|
96
|
+
💬 Join Our Discord: [https://discord.gg/6VMUVA5Yq2](https://discord.gg/6VMUVA5Yq2)
|
|
97
97
|
|
|
98
98
|
## 📄 License
|
|
99
99
|
|
|
100
|
-
[LICENSE](./LICENSE.md)
|
|
100
|
+
See [LICENSE](./LICENSE.md)
|
|
101
101
|
|
|
102
|
-
For commercial use, please contact
|
|
102
|
+
For commercial use, please contact charles@mathcrowd.cn for licensing details.
|
|
103
103
|
|
|
104
104
|
## 🤝 Contributing
|
|
105
105
|
|
|
@@ -107,4 +107,4 @@ We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.
|
|
|
107
107
|
|
|
108
108
|
## 📞 Support
|
|
109
109
|
|
|
110
|
-
For
|
|
110
|
+
For questions or issues, please [open an issue](https://github.com/mathedu4all/mathcrowd-marked-lib/issues) on our GitHub repository.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# mmarked
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40mathcrowd%2Fmmarked)
|
|
4
|
+
[](https://creativecommons.org/licenses/by-nc/4.0)
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
[English](./README.md)
|
|
9
|
+
|
|
10
|
+
这是一个功能强大的 TypeScript 库,用于渲染带有 LaTeX 支持的自定义 Markdown 语法,专为教育领域中的数学可视化而设计
|
|
11
|
+
|
|
12
|
+
## 🌟 功能特性
|
|
13
|
+
|
|
14
|
+
- ✅ **完整的 CommonMark 语法支持:** 与 CommonMark 标准完全兼容
|
|
15
|
+
- 🔢 **脚注块:** 支持自动编号的脚注,并带有易于引用的链接
|
|
16
|
+
- 📘 **定理样式块:** 支持以标题、自动编号和引用链接的形式呈现数学定理、引理和例子
|
|
17
|
+
- 🖼️ **图像缩放功能:** 使用简单的语法可自定义渲染图像和视频
|
|
18
|
+
- 🔍 **隐藏/显示解决方案块:** 带有切换按钮的解决方案块,轻松控制可见性
|
|
19
|
+
- 🧮 **TeX 转 SVG:** 将 TeX 方程式转换为矢量图形,实现高质量渲染
|
|
20
|
+
- 🔗 **与现有系统轻松集成:** 支持服务器端和浏览器端实现
|
|
21
|
+
|
|
22
|
+
## 🚀 快速入门
|
|
23
|
+
|
|
24
|
+
### 编辑器集成
|
|
25
|
+
|
|
26
|
+
在 VSCode 中使用 mmarked: https://marketplace.visualstudio.com/items?itemName=MCLab.mmarked
|
|
27
|
+
在 Logseq 中使用 mmarked: https://github.com/mathedu4all/mmarked-logseq-extension
|
|
28
|
+
|
|
29
|
+
### 服务器端集成
|
|
30
|
+
|
|
31
|
+
#### 安装
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @mathcrowd/mmarked mathjax-full highlight.js
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### 基本用法
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { tex2svg, renderMarkdown } from '@mathcrowd/mmarked'
|
|
41
|
+
|
|
42
|
+
// 将 TeX 转换为 SVG
|
|
43
|
+
const svg = tex2svg('$x^2$')
|
|
44
|
+
|
|
45
|
+
// 将 Markdown 渲染为 HTML
|
|
46
|
+
const html = renderMarkdown('### 标题').parsed
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 浏览器端集成
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<!DOCTYPE html>
|
|
53
|
+
<html>
|
|
54
|
+
<head>
|
|
55
|
+
<meta charset="utf-8">
|
|
56
|
+
<title>在浏览器中使用 Marked</title>
|
|
57
|
+
</head>
|
|
58
|
+
<body>
|
|
59
|
+
<div id="content"></div>
|
|
60
|
+
<script src="dist/browser.umd.js"></script>
|
|
61
|
+
<script>
|
|
62
|
+
const { tex2svg, renderMarkdown } = marked;
|
|
63
|
+
document.getElementById('content').innerHTML =
|
|
64
|
+
tex2svg(renderMarkdown('# 在浏览器中使用 Marked \n\n $x^2+y^2=1$ \n\n由 **mmarked** 渲染').parsed);
|
|
65
|
+
console.log(renderMarkdown('# 在浏览器中使用 Marked\n\n由 **mmarked** 渲染').lexed);
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 📚 API 参考
|
|
72
|
+
|
|
73
|
+
| 函数 | 描述 |
|
|
74
|
+
|----------|-------------|
|
|
75
|
+
| `tex2svg(tex: string): string` | 将 TeX 转换为 HTML 格式的 SVG |
|
|
76
|
+
| `renderMarkdown(markdown: string): {parsed: string, lexed: Token[], time: number}` | 将 Markdown 渲染为 HTML |
|
|
77
|
+
| `renderMarkdownCompact(markdown: string): {parsed: string, lexed: Token[], time: number}` | 将 Markdown 渲染为 HTML,不包含 `<p>` 标签 |
|
|
78
|
+
|
|
79
|
+
⚠️ **重要提示:** 始终使用 [DOMPurify](https://github.com/cure53/DOMPurify) 清洁输出的 HTML,以防止 XSS 攻击
|
|
80
|
+
|
|
81
|
+
## 📖 文档
|
|
82
|
+
|
|
83
|
+
详细的中文文档请访问我们的 [产品页面](https://lab.mathcrowd.cn/mmarked)
|
|
84
|
+
|
|
85
|
+
## 🎮 演示
|
|
86
|
+
|
|
87
|
+
您可以在这里尝试我们的交互式演示: [https://mathedu4all.github.io/mmarked/demo/](https://mathedu4all.github.io/mmarked/demo/)
|
|
88
|
+
|
|
89
|
+
## 👥 关于 Mathcrowd
|
|
90
|
+
|
|
91
|
+
Mathcrowd 是一家由经验丰富的独立开发者和数学教育工作者创办的创新型初创公司我们的目标是通过尖端技术革新中国的数学教育,为数学爱好者和自主学习者创造一个富有吸引力的在线社区,提供丰富、互动和可视化的学习内容
|
|
92
|
+
|
|
93
|
+
🌐 MCLab 官方网站: [https://lab.mathcrowd.cn](https://lab.mathcrowd.cn)
|
|
94
|
+
🌐 我们的在线数学社区: [https://www.mathcrowd.cn](https://www.mathcrowd.cn)
|
|
95
|
+
💬 加入我们的 Discord: [https://discord.gg/6VMUVA5Yq2](https://discord.gg/6VMUVA5Yq2)
|
|
96
|
+
|
|
97
|
+
## 📄 许可证
|
|
98
|
+
|
|
99
|
+
请参见 [LICENSE](./LICENSE.md)
|
|
100
|
+
|
|
101
|
+
如需商业用途,请联系 charles@mathcrowd.cn 获取许可证详情
|
|
102
|
+
|
|
103
|
+
## 🤝 贡献
|
|
104
|
+
|
|
105
|
+
我们欢迎各种形式的贡献!请查看我们的[贡献指南](CONTRIBUTING.md)了解更多详情
|
|
106
|
+
|
|
107
|
+
## 📞 支持
|
|
108
|
+
|
|
109
|
+
如有任何问题或问题,请在我们的 GitHub 仓库[提交 issue](https://github.com/mathedu4all/mathcrowd-marked-lib/issues)
|