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

Đang mở
#42 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

@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

Ngôn ngữ chính
TypeScript
Star
433
Fork
12
Merge trung bình
29 phút
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/markdown

Tất cả issue của TanStack/markdown

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.