Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 2.31 KB

File metadata and controls

69 lines (47 loc) · 2.31 KB

MD013 - Line length

Tags: line_length

Aliases: line-length

This rule checks for lines exceeding a specified maximum length (default 80 characters).

Incorrect code example

This is a very long line that exceeds the maximum allowed length and will trigger the MD013 rule violation

Correct code example

This is a properly formatted line that stays within the maximum
allowed length and will not trigger the MD013 rule violation

Configuration

This rule has the following configuration options:

  • line_length - Maximum characters per line (default: 80)
  • heading_line_length - Maximum characters for headings (default: 80)
  • code_block_line_length - Maximum characters in code blocks (default: 80)
  • code_blocks - Include code blocks in check (default: true)
  • headings - Include headings in check (default: true)
  • tables - Include tables in check (default: true)
  • strict - Enforce strict length checking (default: false)
  • stern - Warn about potentially fixable long lines (default: false)

Mode Behaviors

  • Default mode: Lines without spaces beyond the limit are allowed
  • Stern mode: Warns about lines with spaces beyond limit that could be wrapped
  • Strict mode: All lines must be under the limit regardless of spaces

Exceptions

The following types of lines are automatically exempted from length checking:

  • Link reference definitions (e.g., [label]: https://example.com)
  • Standalone links (e.g., [Example Link](https://example.com))
  • Standalone images (e.g., ![Alt Text](image.jpg))

Examples

Lines that would be allowed in default mode:

This-line-has-no-spaces-beyond-the-limit-so-it-is-allowed-even-if-very-long
[Link reference]: https://example.com/very/long/url/that/exceeds/normal/limits
![Image](https://example.com/path/to/very/long/image/url.jpg)

Lines that would trigger violations:

This line has spaces beyond the configured limit and will trigger a violation

Rationale

Extremely long lines can be difficult to work with in some editors and can harm readability. Many style guides recommend keeping line lengths reasonable to improve code and documentation maintainability.

Recommendation

Split long lines into multiple lines or adjust the configuration to match your project's style guidelines.