markdown/no-space-in-emphasis
Disallow spaces around emphasis markers
fixable
** bold ** is not bold. A * or _ only starts emphasis if no space follows it, and only ends emphasis if no space comes before it. Otherwise the markers show up in the text.
--fix removes the space.
Configure#
Off by default. It needs an ESLint config that says which files are in the language:
eslint.config.js
import markdown from "@eslint/markdown";
export default [
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/commonmark",
rules: { "markdown/no-space-in-emphasis": "error" },
},
];It also works with markdown/gfm.
Examples#
example.md3 problems
This is ** iUnexpected space around emphasis marker.mportant**.
This is _important _Unexpected space around emphasis marker..
This is *** vUnexpected space around emphasis marker.ery important***.example.mdNo problems
This is **important** and _this_ too.
2 * 3 is 6.Options#
| Option | Default | What it does |
|---|---|---|
checkStrikethrough | false | Also check ~ and ~~. |
example.mdwith
{ "checkStrikethrough": true }1 problemThis is ~~ gUnexpected space around emphasis marker.one~~.example.mdwith
{ "checkStrikethrough": true }No problemsThis is ~~gone~~.