-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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(theme): Fix code block magic comments with CRLF line breaks bug #11046
Conversation
…highlight-end at end of code blocks See: facebook#11036
Hi @coder-xiaomo! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
LGTM thanks Can you add a unit test for it in (if you don't know how, tell me and I can do it for you) |
@slorber Okay, I've written the following test case with reference to other test cases. However, this issue requires both code block highlighting comment // add to `describe('parseLines')` part
it('handles CRLF line breaks with highlight comments correctly', () => {
const defaultMagicComments: MagicCommentConfig[] = [
{
className: 'theme-code-block-highlighted-line',
line: 'highlight-next-line',
block: { start: 'highlight-start', end: 'highlight-end' }
}
];
expect(
parseLines(`// highlight-start aaaaa\r\nbbbbb\r\n// highlight-end`, {
metastring: '',
language: 'js',
magicComments: defaultMagicComments
})
).toMatchSnapshot();
}); |
Yes it should be fine. I've added the tests needed based on your proposal above, also adding one for the highlight metastring range Good to merge thanks 👍 |
Pre-flight checklist
Motivation
fix: with CRLF line breaks, an extra empty line was rendered with // highlight-end at end of code blocks
Test Plan
Related issues/PRs
See: #11036