Skip to content

markdown-preferences/custom-container-marker-spacing

require or disallow spacing between opening custom container marker and info

  • ⚙️ 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 consistent spacing between the opening custom container marker (:::) and the info string in custom containers. You can require a space ("always") or disallow it ("never"). By default, spaces are required.

Note: Custom containers are non-standard Markdown syntax. To use this rule with these extended syntaxes, you need to configure the "markdown-preferences/extended-syntax" language option in your ESLint configuration.

md
<!-- eslint markdown-preferences/custom-container-marker-spacing: 'error' -->

<!-- ✓ GOOD -->

::: warning
This is a warning.
:::

<!-- ✗ BAD -->

:::
warning
This is a warning. :::

🔧 Options

json
{
  "markdown-preferences/custom-container-marker-spacing": [
    "error",
    {
      "space": "always"
    }
  ]
}
  • space (string, default: "always")
    • "always" requires a space between the opening custom container marker and the info string.
    • "never" disallows spaces between the opening custom container marker and the info string.

Configuration for Extended Syntax

To check custom containers (which are non-standard Markdown syntax), you need to configure the "markdown-preferences/extended-syntax" language option:

js
// eslint.config.js
import { defineConfig } from "eslint/config";
import markdownPreferences from "eslint-plugin-markdown-preferences";

export default defineConfig([
  {
    extends: [markdownPreferences.configs.recommended],
    language: "markdown-preferences/extended-syntax",
    rules: {
      "markdown-preferences/custom-container-marker-spacing": "error",
    },
  },
]);

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-markdown-preferences v0.30.0

🔍 Implementation