A line ending with two spaces does not produce a hard line break

未關閉
#42 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
72/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

Start by tracing how @tanstack/markdown parses newline and backslash hard breaks; the issue does not name parser files or tests. Reproduce the two trailing spaces case with LF and CRLF, then compare the generated nodes with the working backslash case. Done when both inputs produce a hard break and plain newlines remain soft breaks.

由索引模型根據 Issue 內容生成。

描述

@tanstack/markdown 1.2.0 does not produce a hard line break when a line ends with two or more spaces. CommonMark requires one, and react-markdown 9.1.0 renders it. Only the backslash form (\ before the newline) produces a break node.

Reproduction
import { renderToStaticMarkup } from "react-dom/server";
import { Markdown } from "@tanstack/markdown/react";

renderToStaticMarkup(<Markdown>{"a  \nb"}</Markdown>);
// actual:   <p>a\nb</p>
// expected: <p>a<br/>\nb</p>

Tested with React 19 renderToStaticMarkup and no options. · marks a space in the input column.

Input @tanstack/markdown 1.2.0 react-markdown 9.1.0
a··\nb (2 trailing spaces) <p>a\nb</p> <p>a<br/>\nb</p>
a···\nb (3 trailing spaces) <p>a\nb</p> <p>a<br/>\nb</p>
a··\r\nb (CRLF) <p>a\nb</p> <p>a<br/>\nb</p>
a\ + newline + b (backslash) <p>a<br/>b</p> <p>a<br/>\nb</p>
a\nb (plain newline) <p>a\nb</p> <p>a\nb</p>
  • Two or more trailing spaces before a newline are never turned into a hard break. This holds for LF and CRLF line endings.
  • The backslash hard break works, and a plain newline correctly stays a soft break.
  • CommonMark (spec: hard line breaks) says two or more spaces at the end of a line, with more text after it in the same paragraph, are a hard line break.

I only checked @tanstack/markdown/react, not @tanstack/markdown/html, and only version 1.2.0.

Edit: And yes, I understand that full CommonMark compliance is not in the project scope, but this seems like a relatively easy addition

主要語言
TypeScript
星號
433
分支
12
平均合併
29 分鐘
30 天內合併 PR
7

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/markdown 的其他 Issue

查看 TanStack/markdown 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。