Optimize tight/loose list parsing (new algorithm from commonmark-java)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 42/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- tooling
调研方向
首先阅读链接的 commonmark-java 提交,并找到 issue 中提到的 list-item 和 list-block 解析器方法:continue 和 canContain。跟踪空行当前如何影响 tightness,然后将提议的状态跟踪与现有实现进行比较。运行 CommonMark 规范测试,并确认列表的 tightness 行为保持不变,同时性能得到提升。
由索引模型根据 Issue 内容生成。
描述
Hey! The commonmark-java implementation was using the same algorithm as commonmark.js and cmark for determining whether a list is tight or loose. I recently re-implemented it because it showed up in a profiling session.
The results for the new algorithm are pretty good: a 10% performance improvement! See details here: https://github.com/atlassian/commonmark-java/commit/cfd28faa221056a1a28ce402ed8a278afe9e527d
I'm opening this issue because you might be interested in porting it back to the reference implementations :). I don't know if the improvement will be as significant, but it's worth a try.
It works like this (but see the commit above for details):
- In the parser for list items:
- in
continue, remember when there was a blank line (except when a code block is being parsed) - in
canContain(which is called when a new child will be added), settighttofalseif we saw a blank line before
- in
- In the parser for list blocks:
- in
continue, remember when we had a blank line (and how many lines back it was) - in
canContain, settighttofalseif the previous line was blank
- in
(The new algorithm also feels simpler, hopefully there's no holes in it. It passes all the spec tests and some extra ones.)
- 主要语言
- JavaScript
- 星标
- 1.6k
- 派生
- 234
- 平均合并
- 1 天 27 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
commonmark/commonmark.js 的其他 Issue
-
White space handling looks inconsistent between HTML block element vs HTML inline element可能已有人在做 @mamicicekel 于 19 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
commonmark/commonmark.js#303 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
commonmark/commonmark.js#287 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 20/100
commonmark/commonmark.js#275 ·
-
难度 5/5 一周以上 新手友好度 25/100
commonmark/commonmark.js#267 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 42/100
commonmark/commonmark.js#264 · 1 个 reaction ·
查看 commonmark/commonmark.js 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
AOSSIE-Org/BabyNest#284 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
seek4science/seek#2762 ·
维护者通常 5 天内回复
-
feedback simulation workshop
难度 2/5 1-3 小时 新手友好度 64/100
githubnext/gh-aw-workshop#5009 ·
维护者通常 1 天内回复
-
Clinic sharing: fast sync refusal message suggests Delete Data, which only developer builds have未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
avniproject/avni-client#2228 ·
-
check:passed logos:add
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 6 天内回复