Skip to main content

Markdown Table Suite

Require documentation tables to match canonical MarkdownTable output with registerMarkdownTableSuite.

Summary

  • Extracts every Markdown table from the configured content directories.
  • Renders each table through the MarkdownTable formatter and compares it byte-for-byte against the original.
  • Skips tables inside code fences and tables that use alignment markers, and handles escaped pipes.

Why Use This Suite?

  1. Keeps every table consistently padded and aligned without hand-formatting each one.
  2. Catches a hand-edited table that no longer matches the canonical output during the test run.
  3. Reuses the real formatter as the source of truth so docs and tooling never disagree.

Examples

Usage

src/tests/markdown-table.test.ts
ts
import { registerMarkdownTableSuite } from '@cbnventures/nova/rules/vitest';
import * as vitest from 'vitest';

registerMarkdownTableSuite({
  vitest,
  enable: 'all',
});

The suite has a single check, so toggling is all-or-nothing. The defaults scan docs and blog for .md and .mdx files.

Configuration

FieldTypeDefaultDescription
contentDirsstring[]['docs', 'blog']Directories, relative to rootDir, scanned recursively for tables.
rootDirstringprocess.cwd()Base directory the contentDirs resolve against.
fileExtensionsstring[]['.md', '.mdx']Extensions that count as Markdown content.
enable'all' | ToggleKey[]requiredWhich checks run. Use 'all' for every check, or a list to freeze a set.

Toggle Keys

Toggle KeyDescription
tables-match-markdowntable-outputRequires each table to match the canonical MarkdownTable render.

Troubleshooting

  • A missing content directory throws — The suite skips directories that do not exist. Confirm the path is correct if a configured directory is expected to be present.
  • A table fails the comparison — Re-render it through the MarkdownTable formatter and replace the hand-edited version with the canonical output.
  • A pipe inside a cell breaks the table — Escape the pipe so it is treated as content rather than a column separator.