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

Extra leading spaces when wrapping list to fixed width

Đang mở
#348 2 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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c
Lĩnh vực
cli

Hướng nghiên cứu

Tái hiện đầu ra bao dòng của danh sách bằng entry point dòng lệnh cmark và độ rộng được báo cáo là 80. Kiểm tra hành vi kết xuất và bao dòng của danh sách, sau đó thêm hoặc cập nhật coverage cho ví dụ; hoàn thành khi các mục danh sách được bao dòng không có thêm hai khoảng trắng ở đầu, trong khi các dòng tiếp nối vẫn được thụt lề chính xác.

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

Mô tả

Here is a simple Markdown list:

❯ cat ./list.md
- [Link 1](#link-1) - Description of line 1.
- [Link 2](#link-2) - A very long description for the second link in the list. That description is more than 80 characters wide.
- [This is a very long title, pointing to an awesome article on incredible stuff we're not used to see everyday](#link-3) - Line #3's description.

Re-wrapping this to a maximum length of 80 characters introduces 2 spaces before each lines:

❯ /System/Volumes/Data/usr/local/opt/cmark/bin/cmark --to commonmark --width 80 ./list.md
  - [Link 1](#link-1) - Description of line 1.
  - [Link 2](#link-2) - A very long description for the second link in the list.
    That description is more than 80 characters wide.
  - [This is a very long title, pointing to an awesome article on incredible
    stuff we're not used to see everyday](#link-3) - Line \#3's description.

Here I expect cmark to get rid of these leading spaces and render as such:

- [Link 1](#link-1) - Description of line 1.
- [Link 2](#link-2) - A very long description for the second link in the list.
  That description is more than 80 characters wide.
- [This is a very long title, pointing to an awesome article on incredible stuff
  we're not used to see everyday](#link-3) - Line \#3's description.

Why? So we can fix a regression in pandoc. See how the previous flavor (markdown_github) behaved in that situation compared to the new one (gfm, based on cmark):

❯ pandoc --version
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2

❯ pandoc ./list.md --to=markdown_github
[WARNING] Deprecated: markdown_github. Use gfm instead.
-   [Link 1](#link-1) - Description of line 1.
-   [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
-   [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.

❯ pandoc ./list.md --to=gfm
  - [Link 1](#link-1) - Description of line 1.
  - [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
  - [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.

I guess this behaviour should be somewhat configurable in cmark as pandoc does with the --tab-stop parameter:

❯ pandoc ./list.md --to=markdown_github --tab-stop=2
[WARNING] Deprecated: markdown_github. Use gfm instead.
- [Link 1](#link-1) - Description of line 1.
- [Link 2](#link-2) - A very long description for the second link in the
  list. That description is more than 80 characters wide.
- [This is a very long title, pointing to an awesome article on
  incredible stuff we’re not used to see everyday](#link-3) - Line \#3’s
  description.

For reference, here the version of cmark I'm using, installed with brew on macOS Catalina:

❯ brew install cmark
(...)
==> Downloading https://homebrew.bintray.com/bottles/cmark-0.29.0_1.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3a/3af95418f96f4b0cec4bd76abaab312f3caf4cea591f38d3b725f15068d06491?__gda__=exp=1593691219~hmac=7f6c15036b995f36438e934f5bd44ec8
######################################################################## 100.0%
==> Pouring cmark-0.29.0_1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/cmark/0.29.0_1: 17 files, 724.9KB
❯ /System/Volumes/Data/usr/local/opt/cmark/bin/cmark --version
cmark 0.29.0 - CommonMark converter
(C) 2014-2016 John MacFarlane
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.