master @ 19 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ // Shared math for the framed code block: label seat and width checks. │
│ import { checkGrid, len } from "../../lib/ascii"; │
│ │
│ export interface Props { │
│ code: string; │
│ /** Frame label: a language tag or a file path. */ │
│ label: string; │
│ /** Apply diff line colors. */ │
│ diff?: boolean; │
│ } │
│ │
│ /** Label truncated so the top border always seats " LABEL " plus the │
│ * copy button at the narrow frame. */ │
│ export function frameLabel(label: string, width: number): string { │
│ const max = width - 16; │
│ const cut = len(label) > max ? "..." + [...label].slice(-(max - 3)).join("") : l │
│ abel; │
│ return checkGrid(cut, max, "code frame label"); │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ // Shared math for the framed code block: la │
│ bel seat and width checks. │
│ import { checkGrid, len } from "../../lib/as │
│ cii"; │
│ │
│ export interface Props { │
│ code: string; │
│ /** Frame label: a language tag or a file │
│ path. */ │
│ label: string; │
│ /** Apply diff line colors. */ │
│ diff?: boolean; │
│ } │
│ │
│ /** Label truncated so the top border always │
│ seats " LABEL " plus the │
│ * copy button at the narrow frame. */ │
│ export function frameLabel(label: string, wi │
│ dth: number): string { │
│ const max = width - 16; │
│ const cut = len(label) > max ? "..." + [.. │
│ .label].slice(-(max - 3)).join("") : label; │
│ return checkGrid(cut, max, "code frame lab │
│ el"); │
│ } │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET