Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Line breaking in a code span can break the block structure

Đang mở
#323 1 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
c
Lĩnh vực
tooling

Hướng nghiên cứu

Tái hiện các trường hợp được báo cáo bằng các lệnh cmark trong issue, đặc biệt là các đầu vào code span được render bằng --width 3. Đọc các quy tắc ngắt dòng được đề xuất và so sánh chúng với hành vi parsing và rendering của CommonMark. Được xem là hoàn tất khi việc ngắt dòng bên trong code span không còn làm thay đổi heading, paragraph, fenced code block hoặc cấu trúc danh sách.

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

Mô tả

In CommonMark rendering, line breaking in a code span can break the block structure. Here are just a few examples:

$ printf '`xx --- xx`' | cmark -t commonmark --width 3 | cmark -t html
<h2>`xx</h2>
<p>xx`</p>
$ printf '`xx ``` xx`' | cmark -t commonmark --width 3 | cmark -t html
<p>`xx</p>
<pre><code>xx`
</code></pre>
$ printf '`xx + x xx`' | cmark -t commonmark --width 3 | cmark -t html
<p>`xx</p>
<ul>
<li>x
xx`</li>
</ul>

In case anyone wants to discuss, here is my attempt to specify how I think CommonMark rendering should work:

Line breaking is only implemented inside a paragraph, not inside a heading or an HTML block.

Except inside raw HTML (which I've not thought about), any group of consecutive whitespace characters will turn into a single space or a newline followed by the current line prefix.

Break each line at the last breakable space that doesn't make the line too long. So a line will be wider than the specified width only if it contains no breakable spaces.

In code spans a space is breakable if and only if the following group of non-space characters does not match any of the following Perl regular expressions:

/^[#*-=_]+$/      thematic break, heading
/^(```|~~~)/      fenced code block
/^[<>]/           HTML block, block quote
/^[*+-]$/         list item
/^[0-9]+[).]$/    list item

In textual content all spaces are breakable. A backslash is inserted for the following groups of characters:

/[*<[\\_`]/       escape, code, emphasis, links, images, raw HTML
/[&][#A-Za-z]/    entity or numeric character reference
/^[#*-=_]+$/      thematic break, heading
/^(```|~~~)/      fenced code block
/^[<>]/           HTML block, block quote
/^[*+-]$/         list item
/^[0-9]+[).]$/    list item

In these expressions, ^ means the start of a line (perhaps following a line prefix) and $ means space or the end of the line.

The backslash is inserted in front of each group, except in the last case, where it is inserted in front of the parenthesis or dot.

I've almost certainly forgotten something in there.

Ngôn ngữ chính
C
Star
2k
Fork
698
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 commonmark/cmark

Tất cả issue của commonmark/cmark

Issue tương tự

Thêm issue về C

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.