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

Optimize tight/loose list parsing (new algorithm from commonmark-java)

Đang mở
#151 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách đọc commit commonmark-java được liên kết và xác định các phương thức parser của list-item và list-block được nêu trong issue: continue và canContain. Theo dõi cách các dòng trống hiện đang ảnh hưởng đến tính tightness, sau đó so sánh việc theo dõi trạng thái được đề xuất với triển khai hiện có. Chạy các bài kiểm thử đặc tả CommonMark và xác nhận rằng hành vi list-tightness không thay đổi trong khi hiệu năng được cải thiện.

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

Mô tả

Hey! The commonmark-java implementation was using the same algorithm as commonmark.js and cmark for determining whether a list is tight or loose. I recently re-implemented it because it showed up in a profiling session.

The results for the new algorithm are pretty good: a 10% performance improvement! See details here: https://github.com/atlassian/commonmark-java/commit/cfd28faa221056a1a28ce402ed8a278afe9e527d

I'm opening this issue because you might be interested in porting it back to the reference implementations :). I don't know if the improvement will be as significant, but it's worth a try.

It works like this (but see the commit above for details):

  • In the parser for list items:
    • in continue, remember when there was a blank line (except when a code block is being parsed)
    • in canContain (which is called when a new child will be added), set tight to false if we saw a blank line before
  • In the parser for list blocks:
    • in continue, remember when we had a blank line (and how many lines back it was)
    • in canContain, set tight to false if the previous line was blank

(The new algorithm also feels simpler, hopefully there's no holes in it. It passes all the spec tests and some extra ones.)

Ngôn ngữ chính
JavaScript
Star
1.6k
Fork
231
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
2

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 commonmark/commonmark.js

Tất cả issue của commonmark/commonmark.js

Issue tương tự

Thêm issue về JavaScript

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.