From f8b9f4a7618bf4b60d7c8433b167cfa0c80b9133 Mon Sep 17 00:00:00 2001 From: thzxx <1440196015@qq.com> Date: Fri, 24 Jul 2026 09:35:51 +0800 Subject: [PATCH] =?UTF-8?q?release:=20v0.1.4=20=E2=80=94=20parser=20enhanc?= =?UTF-8?q?ement,=20new=20syntax,=20performance=20optimization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(parser): comprehensive Markdown parser enhancement - Add nested list support (multi-level unordered/ordered, mixed nesting) - Add Setext headings (=== / ---) - Add indented code blocks (4-space indent) - Add HTML comment passthrough () - Add entity reference protection (& ©) - Add ordered list start attribute - Add link title single-quote support - Add LaTeX math formulas ($inline$ / $$block$$) - Add footnote support ([^1] ref + [^1]: definition) - Add definition lists (term\n: definition) - Extend emoji map from 85 to 150+ common emojis - Fix backtick code block matching (CommonMark spec) - Fix italic regex character truncation (lookbehind assertions) - Fix superscript/subscript/strikethrough ambiguity - Fix blockquote prefix handling (>text without space) - Enhance safeUrl filtering (additional protocol checks) - Enhance slugify (Unicode NFKC normalization) perf(parser): single-pass inline scanning, render cache, pre-compiled regex - Replace 14-step chained regex with unified single-pass scanInline() - Add cachedRenderInline() with FIFO LRU eviction (300-entry cap) - Pre-compile 15+ static regex constants for block boundary detection - Skip redundant style='text-align:left' on default-aligned table cells style(parser): add CSS for footnotes, definition lists, math formulas, sup/sub test(parser): 44 new test cases covering all v0.1.4 syntax additions (469 total) chore: bump version 0.1.3 → 0.1.4 across all source files, docs, site pages --- README.md | 24 +- package.json | 2 +- site/demo.html | 29 +- site/docs.html | 4 +- site/index.html | 4 +- src/animations.js | 2 +- src/constants.js | 2 +- src/core.js | 2 +- src/i18n.js | 2 +- src/icons.js | 2 +- src/index.js | 8 +- src/locales.js | 2 +- src/parser.js | 857 +++++++++++++++++++++++++++++++++++-------- src/plugins.js | 2 +- src/styles.js | 52 ++- src/themes.js | 2 +- src/utils.js | 2 +- tests/parser.test.js | 320 +++++++++++++++- types/index.d.ts | 8 +- 19 files changed, 1128 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index 5957c4a..0e9f23e 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ > 轻量、零依赖、精致美观的 Markdown Editor 库。单文件,开箱即用,中文优先。 -[](https://www.npmjs.com/package/@metona-team/metona-editor) +[](https://www.npmjs.com/package/@metona-team/metona-editor) [](./LICENSE) -[](./tests) +[](./tests) [](./tests) --- @@ -17,7 +17,7 @@ - **易维护** — 模块化源码,JSDoc 注释完整,TypeScript 类型声明,425 个单元测试覆盖 - **易使用** — 工厂函数 `create()` 一行接入,链式 API,中文优先文档与翻译 - **安全** — 内置 XSS 防护(`javascript:`/`vbscript:`/`file:` 协议过滤),HTML 转义,`safeUrl` 净化 -- **内置解析器** — 自研 CommonMark 子集 + GFM 扩展(表格含列对齐、任务列表、emoji 短码、上下标),可整体替换 +- **内置解析器** — 自研 CommonMark 子集 + GFM 扩展(表格含列对齐、任务列表、上下标、数学公式、脚注、嵌套列表、emoji 短码等),可整体替换 - **三模式视图** — edit / split / preview 自由切换,分屏拖拽调整比例,滚动同步,模式切换保持滚动位置 - **主题系统** — light / dark / auto / warm 四套预设,CSS 变量定制,跟随系统主题,@media print 打印样式 - **国际化** — zh-CN / en-US 完整翻译,RTL 支持,`Intl` 数字/货币/日期格式化 @@ -680,6 +680,7 @@ MetonaEditor 内置自研轻量解析器,支持 CommonMark 子集 + GFM 扩展 | 语法 | 示例 | 输出 | |------|------|------| | 标题 | `# H1` `## H2` | `
` |
| 粗体 | `**bold**` `__bold__` | `` |
| 斜体 | `*italic*` `_italic_` | `` |
@@ -689,16 +690,23 @@ MetonaEditor 内置自研轻量解析器,支持 CommonMark 子集 + GFM 扩展
| 下标 | `H~2~O` | `` |
| 行内代码 | `` `code` `` | `` |
| 代码块 | ` ```lang ` | `` |
+| 缩进代码块 | ` code` | `` |
| 引用 | `> quote` | `` |
| 无序列表 | `- item` / `* item` / `+ item` | `
/
` |
+| 有序列表 | `1. item` / `3. start` | `
` |
| 任务列表 | `- [x] done` | `
` |
| 表格 | `\| a \| b \|` | `