Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Links with nested HTML or \n confuse the markdown converter

オープン
#53 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
tooling

調査の方向性

この issue ではファイルもテストも指定されていません。まず、レポートにある3つの HTML リンクのケースを Markdown コンバーターで再現し、次に、そこで説明されているアンカーテキストのマッチングと node textContent の処理を調べてください。リンク内のネストされた要素と改行によって期待される Markdown リンクが生成され、報告された例に対するリグレッションカバレッジがある状態を完了とします。

索引モデルが issue の本文から書いたものです。

説明

A couple cases that generate the wrong markup.

1. nested html elements in link
<a href="http://example.com/"><span>foo</span></a> <a href="http://example.com/">bar</a> foo bar

gets converted to

[foo](http://example.com/) bar foo [bar](http://example.com/)

when I would expect

[foo](http://example.com/) [bar](http://example.com/) foo bar

What happens: the walker enters the a and then enters the span again, finding the same text twice. But the proper label text was already consumed, so it consumes until it finds another match. In some cases (like above) it even linkifies the wrong text.

2. line breaks in link
<a href="https://example.com/">foo
bar</a>

(notice the line break) gets converted to

foo bar

when I would expect

[foo bar](https://example.com/)

What happens: the node textContent is 'foo\nbar' which doesn't match any text in the plaintext.

2b. <br> in link

Another similar (but possibly harder to fix) case is

<a href="https://example.com/">foo<br>bar</a>

which like 2 doesn't create a link:

foo
bar

In general, since the code can't rely on the browser to properly deal with HTML content, some of these corner cases will probably keep popping up. But this happened in the real world (try copying and pasting the first news entry in the deprecated section here) and it seemed to be significant enough to report.

I will follow up with a PR that suggests potential fixes for 1 and 2 (but not 2b), but this is not my field so it might be far from good.

主要言語
JavaScript
スター
234
フォーク
47
平均マージ
1日 12時間
マージ済み PR(30日)
5

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/paste-markdown のほかの issue

github/paste-markdown の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。