Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Optimize tight/loose list parsing (new algorithm from commonmark-java)

未关闭
#151 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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), set tight to false if we saw a blank line before
  • In the parser for list blocks:
    • in continue, remember when we had a blank line (and how many lines back it was)
    • in canContain, set tight to false if the previous line was blank

(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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

commonmark/commonmark.js 的其他 Issue

查看 commonmark/commonmark.js 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。