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

reMaybeSpecial and custom syntax

Đang mở
#189 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tính năng
Độ 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

Đọc dist/commonmark.js quanh dòng 8683 và các dòng 9438-9444, sau đó truy vết cách reMaybeSpecial kiểm soát việc nhận diện cú pháp block tùy chỉnh tiềm năng. Xác nhận hành vi hiện có của tiện ích mở rộng phía client với các dấu phân cách ::: và xác định một giải pháp thay thế bên ngoài hoặc một mẫu có thể cấu hình phải hỗ trợ những gì mà không thay đổi parser được đóng gói.

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

Mô tả

I'm upgrading the Markdown parsers on a client's site using CommonMark parsers on both the server and client side. The parser on the server side (in PHP) is the "official" one but we're doing previews on the client side and there were some inconsistencies with the previous scripts.

In the site's markup, there's some "custom" syntax elements which I'm trying to replicate under the CommonMark parsers/renderers as custom syntax/nodes (the previous scripts just did post-processing on the HTML after converting the Markdown). I've got this working on the PHP side, but I'm stuck on the JS side because the custom syntax uses the : character (specifically :::) to denote the start and end of a block similar to backtick fences, but there's an optimization which is stopping the parsing of custom blocks if they don't have a character in the reMaybeSpecial pattern:

https://github.com/commonmark/commonmark.js/blob/8c698a295f7cea58597769ccfaab2219add45e44/dist/commonmark.js#L8683

https://github.com/commonmark/commonmark.js/blob/8c698a295f7cea58597769ccfaab2219add45e44/dist/commonmark.js#L9438-L9444

If I use a debugger and set a breakpoint before line 9438 and then change reMaybeSpecial to include the : character, the rest of my code works more or less as expected…

Is there a way to work around this? I can't find a way to alter reMaybeSpecial from external code. It would be great if it were alterable somehow. (I'd try patching it myself, but I don't understand this newfangled JavaScript where require() is being used all over the place.)

Ngôn ngữ chính
JavaScript
Star
1.6k
Fork
233
Merge trung bình
1 ngày 27 phút
Pull request đã merge (30 ngày)
1

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.