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

Restrict content after shortcut reference

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

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
documentation

调研方向

Start with the CommonMark shortcut reference and link label sections cited in the issue, then compare the supplied Markdown and HTML examples. The work is done when one of the proposed rules is decided and the specification and corresponding examples consistently document that behavior.

由索引模型根据 Issue 内容生成。

描述

Proposal

The spec has this to say on shortcut references:

A shortcut reference link consists of a link label that matches a link reference definition elsewhere in the document and is not followed by [] or a link label.

…and a link label is defined as:

A link label begins with a left bracket ([) and ends with the first right bracket (]) that is not backslash-escaped. Between these brackets there must be at least one non-whitespace character.

(emphasis mine)

I propose tightening what can follow a shortcut reference, to:

-followed by `[]` or a link label.
+followed by `[`.
Problem

The reason for that is that while this restriction has been there since roughly the start (GH-322), almost all CM parsers, including commonmark.js, do not implement this rule correctly, as when given:

[x]: /url

[x][ ], [x][	], [x][
], [x][]

They (normalized) produce:

<p>
  [x][ ], [x][	], [x][ ], <a href="/url">x</a>
</p>

Whereas, according to the current rules, the following should be produced:

<p>
  <a href="/url">x</a>[ ], <a href="/url">x</a>[	], <a href="/url">x</a>[ ], <a href="/url">x</a>
</p>

I kinda like the actual behavior, I think it makes more sense, changing the spec would match it.

Solutions
  1. Implement this proposal in the spec
  2. Alternatively, allow whitespace in collapsed references.
  3. Alternatively, fix commonmark.js / other implementations
主要语言
Python
星标
5.2k
派生
360
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

commonmark/commonmark-spec 的其他 Issue

查看 commonmark/commonmark-spec 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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