syntax-tree / mdast-util-to-markdown

mdast utility to serialize markdown
http://unifiedjs.com
MIT License
100 stars 20 forks source link

Don't escape plus not followed by a whitespace #57

Closed ocavue closed 1 year ago

ocavue commented 1 year ago

Initial checklist

Description of changes

This PR improves the escape unsafe rule for +. If a + is not followed by [\ \t\r\n], then it won't turn into a list item, thus we don't need to escape it.

github-actions[bot] commented 1 year ago

Hi! It seems some of the things asked in the template are missing? Please edit your post to fill out everything.

You won’t get any more notifications from me, but I’ll keep on updating this comment, and remove it when done!

If you need it, here’s the original template ```markdown ### Initial checklist * [ ] I read the support docs * [ ] I read the contributing guide * [ ] I agree to follow the code of conduct * [ ] I searched issues and couldn’t find anything (or linked relevant results below) * [ ] If applicable, I’ve added docs and tests ### Description of changes TODO ```

Thanks, — bb

ocavue commented 1 year ago

Some issues about the CI:

  1. There is a typing error. It seems that it's not caused by this PR. I added a @ts-expect-error.
  2. The type coverage rate from the npm run test is lower than 100%. However I could not find the uncovered code in mdast-util-to-markdown/coverage/lcov-report/index.html, which shows 100%. image
wooorm commented 1 year ago

type-coverage is not coverage, it’s something else.

I’ve updated the internal types for zwitch and TS 4.9: https://github.com/syntax-tree/mdast-util-to-markdown/commits/main.

ocavue commented 1 year ago

The CI is green after rebasing the latest main branch. Thanks for your helping.


If I improve the - case and * case by adding after to these two rules, I cannot pass the test should prevent breaking out of code (-). It seems that inline-code.js is reusing these unsafe patterns to transform EOL into whitespace. I'm not sure what's the best way to fix it. Should I create a separate pattern list for inline-code.js (instead of reusing existed atBreak: true patterns in unsafe.js)?

github-actions[bot] commented 1 year ago

Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the no/* labels.

wooorm commented 1 year ago

I'm not sure what's the best way to fix it

These test check for something that was being escaped, but did not strictly need to be escaped. See https://github.com/syntax-tree/mdast-util-to-markdown/commit/2f3eeb7a5a258f21942c82ba47c47edb6b3284f6

wooorm commented 1 year ago

Released, thanks! https://github.com/syntax-tree/mdast-util-to-markdown/releases/tag/1.4.0