All files / scripts/validators/executive-brief-translations/counters headings.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/headings
 * @description Count `#`-style headings (any depth) outside fenced
 *              code blocks.
 *
 *              Rule census: extracted from
 *              `scripts/validate-executive-brief-translations.ts` lines
 *              142–147. Logic is byte-identical to the original.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { stripFencesAndComments } from '../strippers.js';
 
/** Count `#`-style headings in markdown (any depth). Ignores headings inside fenced blocks. */
export function countHeadings(md: string): number {
  const stripped = stripFencesAndComments(md);
  const lines = stripped.split('\n');
  return lines.filter((l) => /^#{1,6}\s+\S/.test(l)).length;
}