Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 FIX: Task list item marker can be followed by any GFM whitespace #42

Merged

Conversation

hukkin
Copy link
Member

@hukkin hukkin commented Mar 2, 2022

Closes #41

This issue was discovered by @mdeweerd in hukkin/mdformat-gfm#23

We should probably upstream this to https://github.com/revin/markdown-it-task-lists if it's still maintained.

@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Base: 92.36% // Head: 93.20% // Increases project coverage by +0.83% 🎉

Coverage data is based on head (edec998) compared to base (277229c).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head edec998 differs from pull request most recent head f36de50. Consider uploading reports for the commit f36de50 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
+ Coverage   92.36%   93.20%   +0.83%     
==========================================
  Files          27       25       -2     
  Lines        1572     1353     -219     
==========================================
- Hits         1452     1261     -191     
+ Misses        120       92      -28     
Flag Coverage Δ
pytests 93.20% <100.00%> (+0.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mdit_py_plugins/tasklists/__init__.py 73.52% <100.00%> (+0.80%) ⬆️
mdit_py_plugins/anchors/index.py 100.00% <0.00%> (ø)
mdit_py_plugins/attrs/parse.py
mdit_py_plugins/attrs/__init__.py
mdit_py_plugins/attrs/index.py
mdit_py_plugins/__init__.py 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

or token.content.startswith("[x] ")
or token.content.startswith("[X] ")
)
return re.match(r"\[[ xX]][ \t\n\v\f\r]+", token.content)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use \s here, to match whitespace? (see https://docs.python.org/3/library/re.html)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that, but then have to set the re.ASCII flag, else we match too much. I listed all the chars so that they are easy check the against the GFM spec which does so too: https://github.github.com/gfm/#whitespace-character

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CommonMark specification (because that is the reference here!) does the same: https://spec.commonmark.org/0.29/#whitespace-character .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 can you a link to this white space definition in a comment or the docstring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest CM spec is 0.30 and that doesn't have the same character set. The latest spec only has "unicode whitespace".

I would recommend only referring to the latest GFM spec here, since task lists have nothing to do with CM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you a link to this white space definition in a comment or the docstring

Sure. I think I'll make it a private variable or something.

Copy link

@mdeweerd mdeweerd Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the new CM spec is not fully updated then - it still refers to whitespace in the examples without defining it: https://spec.commonmark.org/0.30/#example-350 .

I was actually thinking why this should not defined as a constant because it has just proven to change over time... . GFM_WHITESPACE, CM_WHITESPACE.

Edit: which you did 😃

@hukkin hukkin changed the title 🐛 FIX: Task list item marker can be followed by any CommonMark whitespace 🐛 FIX: Task list item marker can be followed by any GFM whitespace Mar 2, 2022
@chrisjsewell chrisjsewell merged commit 3f90276 into executablebooks:master Dec 5, 2022
@hukkin hukkin deleted the task-list-gfm-compliancy branch December 5, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handing of tabs
3 participants