Setext Heading LRDs take precedence over Paragraph LRDs
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- compilers
調査の方向性
2つの例を再現し、Parser.refmap、inline.js、およびドキュメントの最終処理ステップを調べて、Setext と段落の LRD がいつ記録されるかを追跡します。inline.js のミューテーションを壊さずに、提案された順序を適用する方法を確認します。重複するラベルが、Setext 見出しの場合も含め、ドキュメント順で最初の LRD に一貫して解決されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The only reference to precedence I could find in the spec is this:
If there are multiple matching reference link definitions, the one that comes first in the document is used. (It is desirable in such cases to emit a warning.)
The issue is that when you define a LRD (link reference definition) in a Setext heading (or a probable Setext heading*), this link will populate the refmap before any paragraph LRDs are parsed, which occurs at the document finalization step.
*A paragraph interrupted by a setext heading underline that only contains links, thus creating an empty <p>, which is immediately unlinked from the AST.
Example inputs:
[x]: fizz
[x]: buzz
===
[x]
has an href=buzz,
Whereas
[x]: fizz
[x]: buzz
[x]
has an href=fizz.
My interpretation of the spec is that both should result in href=fizz as that is the first LRD.
Assuming this is a bug, my idea of a fix would be to use a modified Parser.refmap where it has an Map<number, Array<LRD>> and the key would be the line number of the containing paragraph (sourcepos[0][0]), as the exact lines don't matter as long as the array is populated in-order.
So if this was the input
[line1]: a
[line2]: b
rest of paragraph
[line5]: e
===
would have the map
{
5: [e],
1: [a, b]
}
(where a, b, e are objects of typedef LRD {destination: string, title: string, label: string} with map def
Map<number, Array<LRD>>)
Then setext headings' block start and document finalization can occur in the order they do, but could add another step after document finalization. E.g.
/**
* @param {Map<number, Array<{destination: string, title: string, label: string}>>} unorderedRefmap
*/
function getFinalRefmap(unorderedRefmap) {
const sortedKeys = [...unorderedRefmap.keys()].sort((a, b) => a - b);
const finalRefmap = {};
for (const k of sortedKeys) {
const values = unorderedRefmap.get(k);
for (const v of values) {
if (!finalRefmap[v.label]) {
finalRefmap[v.label] = {destination: v.destination, title: v.title};
}
}
}
return finalRefmap ;
}
Something like that should work, its just a matter of adding to the placeholder refmap correctly, which is a bit trickier since inline.js needs a reference to it and mutates it.
- 主要言語
- JavaScript
- スター
- 1.6k
- フォーク
- 234
- 平均マージ
- 1日 27分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
commonmark/commonmark.js のほかの issue
-
White space handling looks inconsistent between HTML block element vs HTML inline element対応中かも @mamicicekel が 20 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
commonmark/commonmark.js#303 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
commonmark/commonmark.js#287 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 20/100
commonmark/commonmark.js#275 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
commonmark/commonmark.js#267 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
commonmark/commonmark.js#264 · リアクション 1 件 ·
commonmark/commonmark.js の issue をすべて見る
似ている issue
-
external-plugin ready-for-review third party
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/awesome-copilot#5713 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
carbon-design-system/carbon-react-router-starter#1005 ·
メンテナーはふだん 1 日以内に返信
-
enhancement p2 setup
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Query Log shows "Upstream" for CNAME cloaking, schedule, NXDOMAIN hijack and response IP blocksオープンbug good first issue query-log web
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
ferrous-networking/ferrous-dns#326 ·
メンテナーはふだん 1 日以内に返信