Repository navigation
Use markdown-it for chat and note Markdown rendering - #178
Open
Excelius-Wang wants to merge 1 commit into
Open
Excelius-Wang wants to merge 1 commit into
Excelius-Wang wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue 与改动
将
easyread/web/js/common/markup.js中的手写块级 / 行内 Markdown 解析替换为markdown-it(^14.3.3),解决 AI 对话、边注卡片与笔记预览中嵌套列表、缩进续行段落、分隔线与代码块渲染异常的问题,同时完整保留 EasyRead 原有的公式、代码、论文内链、参考文献、脚注保护与 XSS 安全策略。原有手写解析的缺陷
para()通过lines.slice(k).every(isItem)判断列表块,当有序列表项包含缩进介绍段、嵌套子列表和结尾续行时,整块回退为普通<p>...<br>...</p>,字面显示2.、-和**...**。---水平分隔线;.cm.ai .body、.card .body、.inline-note、.np-ai-body、.np-preview缺少<pre>/<pre><code>、<hr>、多级嵌套列表及任务列表样式。这是**“重要”**、见**(第 1 节)**)会判定为不构成强调边界。渲染流水线
影响范围
package.json/package-lock.json:将markdown-it(^14.3.3,原本已随markmap-lib存在于 lockfile)显式加入devDependencies。easyread/web/src/markdown-it.js、scripts/build_note_editor.cjs:通过npm run build:editor打包easyread/web/vendor/markdown-it.js并将依赖许可证汇总到easyread/web/vendor/note-libraries.LICENSE.txt(统一 LF 换行)。easyread/web/reader.html、easyread/web/library.html:在markup.js前引入/web/vendor/markdown-it.js;easyread/export/build.py的单文件/手机版离线导出会自动内联该脚本;最小 Node VM 测试环境仍保留fallbackInline()兜底。markup.js由原 392 行增至 449 行,暂留在单文件内以减少额外<script>并兼容只加载markup.js的旧测试夹具;如维护者更倾向按 400 行阈值将markdown-it初始化拆出,可按意见再拆。easyread/web/css/reader-chat.css、reader.css、reader-panels.css,补齐<hr>、<pre>/<pre><code>、嵌套ol/ul与li > p间距、.task-list-item、.md-h标题层级及多段blockquote p排版。paper.json/chat.json/reader.json。PR.md、PR.mdBlocks、PR.plain、PR.titleHtml、PR.webMathHtml、PR.unlink、PR.tex等)签名不变,可通过回退本次引入直接恢复旧实现;主要影响调用PR.md/PR.mdBlocks的 AI 对话、边注卡片与笔记预览渲染。验证结果
2. **...**\n 说明:\n - **子项**...\n\n---)中,整段退化为<p>...<br>...</p>,序号/项目符号/粗体星号与---原样外露。node --test tests/web/test_*.cjs tests/desktop/test_*.cjs— 311 passed, 0 failed(含tests/web/test_reader_navigation.cjs、tests/desktop/test_desktop.cjs,并更新tests/web/test_markup.cjs与tests/web/test_chat_ui.cjs,覆盖嵌套列表与缩进续行、列表/引用内代码块与公式块、---分隔线、中文标点加粗、删除线、任务列表及 HTML/javascript:XSS 拦截;跨空行编号列表断言同步为语义化的单一<ol>)。.venv/bin/python -u -m unittest discover tests -v(macOS arm64, Python 3.12)— 676 passed(1 skipped,非 Windows 固有跳过)。.venv/bin/python scripts/i18n_check.py退出码0(缺英文0,没套PR.t/tr的中文0);git diff --check通过。uv pip install --target ... --no-deps --no-build-isolation .构建并安装 wheel 至隔离目录,在仓库目录之外启动服务,确认/web/vendor/markdown-it.js(149,683 bytes)、/web/js/common/markup.js(22,802 bytes)及文献库首页/均可正常访问。1440×900):从/点击论文进入/read/0045da470eed,划选段落新建包含嵌套列表、中文标点加粗、---分隔线与 Python 代码块的页边注,保存后.card[data-note] .body全部结构正确渲染(残留**为0);打开#notespanel、页面滚离锚点后点击卡片,成功回跳至原段落#b-p1-1。1440×900):右侧问 AI侧栏渲染真实 ReDiST 长回答(嵌套列表/子列表/缩进续行/---/引用块/15 个 KaTeX 公式与交叉引用),并按每 3 字符增量切片模拟流式PR.mdBlocks调用,未闭合语法阶段无异常,结束后完整结构零残留**。420×840):阅读页与侧栏内容document.documentElement.scrollWidth <= window.innerWidth,<pre>与.tbl-wrap无横向撑破。easyread.export.build生成的离线 HTML 可正常加载PR.MarkdownIt并解析嵌套列表与分隔线。/跳转到阅读页时观察到 1 条既有@view-transition(library.css)在非聚焦窗口取消导航过渡的AbortError: Transition was skipped,与本次改动无关,其余业务与渲染脚本零报错;Playwright 专项脚本(tests/browser/fixture-smoke.cjs、tests/e2e_web_offline.py)待仓库 CI 批准后执行。