Skip to content

fix: リストアイテムを <p> でラップして note.com の正規化後もテキストを保持する#1

Open
suwa-sh wants to merge 1 commit intoshimayuz:mainfrom
suwa-sh:fix/list-item-text-loss
Open

fix: リストアイテムを <p> でラップして note.com の正規化後もテキストを保持する#1
suwa-sh wants to merge 1 commit intoshimayuz:mainfrom
suwa-sh:fix/list-item-text-loss

Conversation

@suwa-sh
Copy link
Copy Markdown

@suwa-sh suwa-sh commented Apr 30, 2026

概要

convertMarkdownToNoteHtml<li>${item}</li> を出力していますが、note.com の editor ブロックパーサはこれを <li><p name=\"UUID\" id=\"UUID\"></p></li> に正規化する際に内部テキストを捨ててしまいます。API 呼び出しは success を返し、get-note も投稿した HTML body をそのまま返すのに、公開プレビューでは bullet だけが表示されてテキストが空になります。

各リストアイテムの中身を <p> でラップする(<li><p>${item}</p></li>)ことで、note.com 正規化後の構造と一致させ、addUUIDAttributes<p>name/id を付与してブロックパーサがテキストを保持できるようにします。

再現(修正前)

markdown リストを含む下書きを投稿し、プレビュー URL を開くと bullet は描画されるが中身のテキストが空になります。

  • get-note<li>text</li>(送信した body)を返す
  • しかし実際に保存された body(プレビュー HTML 上で確認可能)は <li><p name=\"UUID\" id=\"UUID\"></p></li>

get-note の結果だけを見る検証ではこのバグに気づけません。

修正後

convertMarkdownToNoteHtml<li><p>${item}</p></li> を出力するようになり、後段の addUUIDAttributes<p>name/id を付与することで note.com が期待する構造になります。複数の下書きで再投稿して検証済み — プレビュー HTML には <li><p name=\"UUID\">text</p></li> が含まれ、レンダリング後の記事でも bullet のテキストが正しく表示されることを確認しました。

変更内容

src/utils/markdown-converter.ts の 11 箇所(リストを flush している全ての箇所)で <li>${item}</li><li><p>${item}</p></li>

補足

  • 自動テスト基盤がリポジトリ内に見つからなかったため、実際の note.com の下書きに対するハンドテストで検証しました(unordered/ordered の混在リスト、見出しに隣接するリスト、インラインコードを含むリスト等の複数パターン)
  • このラッパは note.com のブロックパーサ正規化を通過する構造に合わせています。これがないとリストアイテムのテキストは静かに失われます — API は success を返すので、外部の呼び出し側はレンダリング後のプレビューを scrape しない限り欠落を検知できません

🤖 Generated with Claude Code

note.com's editor block parser normalizes <li>text</li> to
<li><p name="UUID" id="UUID"></p></li>, discarding the inner text.
The published preview shows empty bullets even though the API call
returns success and get-note reflects the inbound HTML body intact.

Wrapping each list item's content in a <p> tag matches the structure
note.com keeps after normalization, so addUUIDAttributes assigns the
required name/id to the <p> and the text is preserved through the
block parser.

Verified by re-submitting drafts containing markdown lists; preview
HTML now contains <li><p name="UUID">text</p></li> and the rendered
article shows bullet text correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@suwa-sh suwa-sh changed the title fix: wrap list item content in <p> so note.com preserves text after server normalization fix: リストアイテムを <p> でラップして note.com の正規化後もテキストを保持する Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant