-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add no-space-in-emphasis rule #403
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
base: main
Are you sure you want to change the base?
Conversation
@Pixel998 Make sure to mark it as ready for review once done, the team doesn't pay attention to draft PRs. |
@Pixel998 Are you still working on this? |
|
||
## Background | ||
|
||
In Markdown, emphasis (bold and italic) is created using asterisks (`*`) or underscores (`_`), and strikethrough is created using tildes (`~`). The emphasis markers must be directly adjacent to the text they're emphasizing, with no spaces between the markers and the text. When spaces are present, the emphasis is not rendered correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Markdown, emphasis (bold and italic) is created using asterisks (`*`) or underscores (`_`), and strikethrough is created using tildes (`~`). The emphasis markers must be directly adjacent to the text they're emphasizing, with no spaces between the markers and the text. When spaces are present, the emphasis is not rendered correctly. | |
In Markdown, emphasis (bold and italic) is created using asterisks (`*`) or underscores (`_`), and a strikethrough is created using tildes (`~`). The emphasis markers must be directly adjacent to the text they're emphasizing, with no spaces between the markers and the text. When spaces are present, the emphasis is not rendered correctly. |
We have false negatives in case of nested emphasis: <!-- eslint markdown/no-space-in-emphasis: "error" -->
_ **bold** _ // no error
This is * italic with __ bold __ markdown * // No error reported
This is *italic with __ bold __ markdown* // Reports error for bold emphasis as expected |
{ | ||
code: "Broken * emphasis * with spaces", | ||
output: "Broken *emphasis* with spaces", | ||
errors: [ | ||
{ | ||
messageId: "spaceInEmphasis", | ||
line: 1, | ||
column: 8, | ||
endLine: 1, | ||
endColumn: 20, | ||
}, | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following is an edge case, I'm not sure if we want to solve for it in the initial version. **** bold **** // No error, |
/** | ||
* @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} | ||
* NoSpaceInEmphasisRuleDefinition | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} | |
* NoSpaceInEmphasisRuleDefinition | |
*/ | |
/** | |
* @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} | |
* NoSpaceInEmphasisRuleDefinition | |
*/ |
Could you merge the main
branch and update the code to use the @import
JSDoc syntax as shown in the ongoing changes in https://github.com/eslint/markdown/pull/367/files?
You can refer to the following image as a guide:
Prerequisites checklist
What is the purpose of this pull request?
This PR implements the no-space-in-emphasis rule to disallow spaces around emphasis markers.
What changes did you make? (Give an overview)
Implemented the no-space-in-emphasis rule, along with documentation and tests.
Related Issues
Fixes #378
Is there anything you'd like reviewers to focus on?