Em Dash Space Checker

Description

This rule enforces proper em dash usage by checking for and flagging incorrect spacing around em dashes and en dashes. According to Microsoft's style guide, em dashes should not have spaces on either side. Proper em dash formatting improves readability and maintains professional consistency in your documentation.

The rule is configured to automatically suggest removing spaces around these dashes, making it easier to maintain consistent formatting across your documents.

Examples

❌ Incorrect usage:

  • "The project — still in development — continues."
  • "The meeting was canceled — everyone went home."

✅ Correct usage:

  • "The project—still in development—continues."
  • "The meeting was canceled—everyone went home."

The rule will flag any instance where there are spaces before and after an em dash (—) or en dash (–) and suggest removing them. It operates case-insensitively and is set as an error-level rule, indicating its importance in maintaining consistent formatting.

Rule Source

This rule comes from: https://github.com/mesosphere/dcos-docs-site

Rule Definition

extends: existence
message: "Remove the spaces around '%s'."
link: https://docs.microsoft.com/en-us/style-guide/punctuation/dashes-hyphens/emes
ignorecase: true
nonword: true
level: error
action:
  name: edit
  params:
    - remove
    - ' '
tokens:
  - '\s[—–]\s'