react icon indicating copy to clipboard operation
react copied to clipboard

🐛 `MarkdownViewer` incorrectly parses task items in `1. - [ ]` format

Open iansan5653 opened this issue 3 years ago • 1 comments

This issue was originally reported as https://github.com/github/memex/issues/11844

When a Markdown task list has items delimited with both a number and a dash or asterisk, the MarkdownViewer component fails to recognize the items and thus incorrectly checks the wrong list items:

https://user-images.githubusercontent.com/1062491/188623750-56d3a607-b7f5-4b2f-b8be-233a85e96bc5.mov

This is a draft component and a pretty uncommon edge case so I wouldn't prioritize this at the moment unless we start seeing more reports.


The problem is the list-item parsing regular expression:

https://github.com/primer/react/blob/679e699d2fa864a505251e07b0c2dd19ed4ad231/src/drafts/MarkdownEditor/_useListEditing.ts#L32

The ([*-]|(\d+)\.) group assumes that a list item will start with a bullet (- or *) or a number (1.). These list items start with a number and a bullet. I'm surprised the Markdown pipeline renders this list at all, but because it does, we should probably handle this case.

iansan5653 avatar Sep 06 '22 18:09 iansan5653

A note from our FR from the original issue:

I couldn't replicate this outside of the non-standard edgecase of 1. - [ ] prefixed items, which seemed unconventional.

iansan5653 avatar Sep 09 '22 15:09 iansan5653

Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.

github-actions[bot] avatar Mar 22 '23 01:03 github-actions[bot]