markdown-preferences/emphasis-delimiters-style
enforce a consistent delimiter style for emphasis and strong emphasis
- ⚙️ This rule is included in
plugin.configs.standard
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule enforces a consistent delimiter style for emphasis (*text*
/_text_
), strong emphasis (**text**
/__text__
), and strong+emphasis (***text***
/___text___
) in Markdown documents.
You can configure which delimiter to use for each type:
emphasis
:*
or_
(default:*
)strong
:**
or__
(default:**
)strongEmphasis
: You can specify allowed styles as a string (for***text***
or___text___
) or as an object{ outer, inner }
for mixed delimiters. See Options below for details.
Any usage of a different delimiter will be reported as an error and can be automatically fixed.
<!-- eslint markdown-preferences/emphasis-delimiters-style: 'error' -->
<!-- ✓ GOOD -->
_emphasis_
**strong**
**_strongEmph_**
a*c*b <!-- remains as-is, not converted to a_c_b -->
<!-- ✗ BAD -->
*emphasis*
__strong__
***strongEmph***
___strongEmph___
_**strongEmph**_
__*strongEmph*__
**_strongEmph_**
🔧 Options
You can specify the preferred delimiter for each type using the options below. All options are optional.
{
"markdown-preferences/emphasis-delimiters-style": [
"error",
{
"emphasis": "_", // "*" or "_" (default: "_")
"strong": "**", // "**" or "__" (default: "**")
// If omitted, strongEmphasis is automatically determined from the combination of emphasis/strong
// To specify explicitly:
"strongEmphasis": "***" // ***text***
// or
// "strongEmphasis": "___" // ___text___
// "strongEmphasis": { "outer": "*", "inner": "__" } // *__text__*
// "strongEmphasis": { "outer": "**", "inner": "_" } // **_text_**
// "strongEmphasis": { "outer": "_", "inner": "**" } // _**text**_
// "strongEmphasis": { "outer": "__", "inner": "*" } // __*text*__
}
]
}
If no options are provided:
emphasis
defaults to underscore (_
)strong
defaults to asterisk (**
)strongEmphasis
is automatically determined from theemphasis
andstrong
options as follows:- If either option contains
*
, then*
is used as the outer delimiter and the other as the inner. In other words:emphasis: "_", strong: "**"
→{ outer: "**", inner: "_" }
→**_text_**
emphasis: "*", strong: "__"
→{ outer: "*", inner: "__" }
→*__text__*
emphasis: "*", strong: "**"
→***
→***text***
emphasis: "_", strong: "__"
→___
→___text___
- If
strongEmphasis
is explicitly specified, that value takes precedence.
- If either option contains
Note: If you specify _
or __
as a delimiter in any of the options (emphasis
, strong
, or strongEmphasis
), intra-word emphasis (such as a*c*b
) will not be converted to underscores. According to the CommonMark specification, underscores do not create emphasis inside words. Only valid emphasis patterns will be checked and fixed.
Details for the strongEmphasis
Option
The strongEmphasis
option specifies the style for combined emphasis and strong emphasis (e.g., ***text***
or *__text__*
).
There are two ways to specify this option:
- As a string, such as
"***"
or"___"
, to require the same delimiter for both outer and inner (e.g.,***text***
,___text___
). - As an object
{ "outer": string, "inner": string }
to require different delimiters for outer and inner (e.g.,*__text__*
,**_text_**
,_**text**_
,__*text*__
).
Only one style can be specified; you cannot allow multiple styles at once.
Examples:
"***"
→***text***
"___"
→___text___
{ "outer": "*", "inner": "__" }
→*__text__*
{ "outer": "**", "inner": "_" }
→**_text_**
{ "outer": "_", "inner": "**" }
→_**text**_
{ "outer": "__", "inner": "*" }
→__*text*__
📚 Further Reading
👫 Related Rules
- markdown-preferences/strikethrough-delimiters-style - enforce consistent strikethrough delimiters
🚀 Version
This rule was introduced in eslint-plugin-markdown-preferences v0.19.0