Number Range En Dash Rule

This rule enforces the proper usage of en dashes (–) instead of hyphens (-) in numerical ranges. The rule is designed to maintain consistency with professional typographic standards and the Microsoft Style Guide, which specifies that en dashes should be used to indicate ranges of numbers.

Using the correct dash for numerical ranges is important for several reasons:

  • It follows standard typographic conventions
  • It improves readability by clearly indicating a range relationship
  • It maintains professional formatting standards in your documentation
  • It ensures consistency across your content

Examples

Will flag:

  • "Pages 1-10" (hyphen)
  • "2000 - 2023" (hyphen with spaces)
  • "5-6" (hyphen)

Should be:

  • "Pages 1–10" (en dash)
  • "2000–2023" (en dash)
  • "5–6" (en dash)

The rule uses a regular expression pattern to identify any instance where numbers are connected by a hyphen (with or without spaces) and suggests replacing it with an en dash. The rule is set as a suggestion rather than an error, allowing writers to make informed decisions about its application.

Rule Source

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

Rule Definition

extends: existence
message: "Use an en dash in a range of numbers."
link: https://docs.microsoft.com/en-us/style-guide/numbers
nonword: true
level: suggestion
action:
  name: edit
  params:
    - replace
    - '-'
    - '–'
tokens:
  - '\b\d+\s?[-]\s?\d+\b'