release: v0.1.1 — bug fixes, CSS scoping, parser improvements
Bug Fixes: - fix(core): insert() replace param was non-functional due to identical ternary branches - fix(types): correct project URL typo (MetonaToast → MetonaEditor) Improvements: - feat(core): scope CSS theme variables to .me-wrapper per-instance, preventing global style pollution - feat(themes): add optional target parameter to setThemeVariables() for element-scoped theming - perf(parser): improve bold/strikethrough regex to support inline delimiter chars (e.g. **a*b**, ~~a~b~~) - fix(parser): prevent *** cross-tag nesting by requiring first content char ≠ delimiter - docs(animations): clarify module purpose as future-use animation metadata registry Tests: - test(core): add 2 cases for insert() replace:true / replace:false behavior - All 409 tests passing (+2 new) Chores: - bump version 0.1.0 → 0.1.1 across all source files, package.json, README, and demo
This commit is contained in:
+7
-7
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* MetonaEditor Parser - 轻量 Markdown 解析器
|
||||
* @module parser
|
||||
* @version 0.1.0
|
||||
* @version 0.1.1
|
||||
* @description 自研零依赖 Markdown 解析器,覆盖 CommonMark 子集 + GFM 扩展
|
||||
*
|
||||
* 支持语法:
|
||||
@@ -286,16 +286,16 @@ const renderInline = (text, env) => {
|
||||
return `<a href="${u}" target="_blank" rel="noopener noreferrer">${url}</a>`;
|
||||
});
|
||||
|
||||
// 6. 粗体 **text** / __text__
|
||||
s = s.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
|
||||
s = s.replace(/__([^_]+)__/g, '<strong>$1</strong>');
|
||||
// 6. 粗体 **text** / __text__(内容首字符不能是分隔符,避免 *** 歧义)
|
||||
s = s.replace(/\*\*([^*].*?)\*\*/g, '<strong>$1</strong>');
|
||||
s = s.replace(/__([^_].*?)__/g, '<strong>$1</strong>');
|
||||
|
||||
// 7. 斜体 *text* / _text_
|
||||
// 7. 斜体 *text* / _text_(贪婪匹配,避免匹配 ** 或 __ 前缀)
|
||||
s = s.replace(/(^|[^*])\*([^*\n]+)\*/g, '$1<em>$2</em>');
|
||||
s = s.replace(/(^|[^_])_([^_\n]+)_/g, '$1<em>$2</em>');
|
||||
|
||||
// 8. 删除线 ~~text~~
|
||||
s = s.replace(/~~([^~]+)~~/g, '<del>$1</del>');
|
||||
// 8. 删除线 ~~text~~(非贪婪匹配,支持内含单个 ~ 字符)
|
||||
s = s.replace(/~~(.+?)~~/g, '<del>$1</del>');
|
||||
|
||||
// 9. 还原行内代码
|
||||
s = s.replace(/\u0000(\d+)\u0000/g, (m, idx) => `<code>${escapeHTML(codes[+idx])}</code>`);
|
||||
|
||||
Reference in New Issue
Block a user