All files / scripts/validators/executive-brief-translations/counters table-rows.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                  23x 23x 575x    
/**
 * @module scripts/validators/executive-brief-translations/counters/table-rows
 * @description Count Markdown table rows (lines starting with `|`
 *              outside fenced blocks).
 *
 *              Rule census: extracted from
 *              `scripts/validate-executive-brief-translations.ts` lines
 *              163–168. Logic is byte-identical to the original.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { stripFencesAndComments } from '../strippers.js';
 
/** Count Markdown table rows (lines starting with `|` outside fenced blocks). */
export function countTableRows(md: string): number {
  const stripped = stripFencesAndComments(md);
  const lines = stripped.split('\n');
  return lines.filter((l) => /^\s*\|.*\|\s*$/.test(l)).length;
}