All files / scripts/validators/executive-brief-translations/counters code-fences.ts

100% Statements 4/4
75% Branches 3/4
100% Functions 1/1
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                            24x 24x   22x    
/**
 * @module scripts/validators/executive-brief-translations/counters/code-fences
 * @description Count fenced code blocks (any info string).
 *
 *              Rule census: extracted from
 *              `scripts/validate-executive-brief-translations.ts` lines
 *              149–155. Logic is byte-identical to the original.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
/** Count fenced code blocks (any info string). */
export function countCodeFences(md: string): number {
  const matches = md.match(/^```/gm) ?? [];
  if (matches.length % 2 !== 0) return Number.NaN;
  // Each fence is one of opening/closing; divide by 2.
  return matches.length / 2;
}