Rule - MD049#
| Property | Value |
|---|---|
| Aliases | md049, emphasis-style |
| Autofix Available | Pending |
| Enabled By Default | Yes |
Summary#
Ensure consistent emphasis style across the document.
Reasoning#
Readability#
To maintain a uniform appearance and improve readability, the character sequence used for inline emphasis (e.g., asterisks vs. underscores) should remain consistent throughout a document or set of documents.
Examples#
Failure Scenarios#
This rule triggers when the document mixes asterisks (*) and underscores (_)
for inline emphasis under the default consistent style.
Explanation: This example fails because the first line uses asterisks (
*) for emphasis while the second line uses underscores (_). With the defaultconsistentstyle, the first emphasis block sets the expected style to asterisks. The subsequent use of underscores violates this consistency requirement.
Unlike the previous example, which relies on the default consistent style, this
scenario violates the rule when the style configuration is explicitly set to asterisk.
All emphasis blocks use underscores, but underscores are not permitted in this strict
mode.
Explanation: This example fails because the configuration
styleis set toasterisk, which mandates that only asterisks (*) may be used for emphasis. Although both blocks use underscores consistently, underscores are prohibited in this mode.
Unlike the previous example, which demonstrated a violation of the asterisk configuration,
this scenario violates the rule when the style configuration is explicitly set
to underscore. Even if all emphasis blocks use asterisks consistently among themselves,
they fail the rule because asterisks are not permitted in this strict mode.
Explanation: This example fails because the
styleconfiguration is set tounderscore, which mandates that only underscores (_) may be used for emphasis. Although both blocks use asterisks consistently, asterisks are prohibited in this mode.
Correct Scenarios#
This rule does not trigger when all inline emphasis blocks use the same delimiter
character under the default consistent style.
Explanation: This example passes because both emphasis blocks use asterisks (
*). This is consistent with the defaultconsistentstyle, which adopts the style of the first emphasis block encountered.
Unlike the previous example, which relied on the default consistent style, this
scenario demonstrates compliance when the style configuration is explicitly set
to underscore. All emphasis blocks use underscores, satisfying the strict configuration
requirement.
Explanation: This example passes because the configuration
styleis set tounderscore, which mandates that only underscores (_) may be used for emphasis. Both blocks use underscores, satisfying this requirement.
Unlike the previous example, which satisfied the underscore style, this scenario
demonstrates compliance when the style configuration is explicitly set to asterisk.
All emphasis blocks use asterisks, satisfying the strict configuration requirement.
Explanation: This example passes because the configuration
styleis set toasterisk, which mandates that only asterisks (*) may be used for emphasis. Both blocks use asterisks, satisfying this requirement.
Fix Description#
The implementation for this feature is tracked with this issue.
Configuration#
| Prefixes |
|---|
plugins.md049. |
plugins.emphasis-style. |
| Value Name | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
True |
Whether the Rule Plugin is enabled. |
style |
string |
consistent |
Style of emphasis block characters expected in the document. |
Valid Styles#
| Style | Description |
|---|---|
consistent |
The first emphasis block in the document specifies the style for the rest of the document. |
asterisk |
Only asterisks are to be used for inline emphasis block elements. |
underscore |
Only underscores are to be used for inline emphasis block elements. |
Origination of Rule#
This rule is largely inspired by the MarkdownLint rule MD049.