import { HEADING_TWO, ORDERED_ITEM } from "#configuration/constants/readme.constants"; import { LINK_CLOSE, LINK_MIDDLE, LINK_OPEN, LIST_ITEM, MARKDOWN_EXTENSION, PARAGRAPH_BREAK, } from "#configuration/constants/chapter.constants"; import { ATTRIBUTION_SEPARATOR } from "#configuration/strings/chapter.strings"; import type { Attribution } from "#types/chapter.types"; import { LINE_END } from "#configuration/constants/inventory.constants"; const ITALIC = "_"; export const link = function link(label: string, file: string): string { return LINK_OPEN + label + LINK_MIDDLE + file + LINK_CLOSE; }; export const tabFileOf = function tabFileOf(tab: string): string { return tab.toUpperCase() + MARKDOWN_EXTENSION; }; export const attributionLine = function attributionLine(held: Attribution): string { const owner = held.copyright + held.author + held.work; const licence = held.coveredBy + link(held.licenseName, held.licenseUrl); return owner + ATTRIBUTION_SEPARATOR + licence; }; export const image = function image(src: string, size: string, alt: string): string { return `${alt}`; }; export const note = function note(label: string, href: string): string { return ITALIC + link(label, href) + ITALIC; }; export const section = function section(title: string, ...parts: readonly string[]): string { return [HEADING_TWO + title, ...parts].join(PARAGRAPH_BREAK); }; export const bullets = function bullets(items: readonly string[]): string { return items.map((item) => LIST_ITEM + item).join(LINE_END); }; export const numbered = function numbered(items: readonly string[]): string { return items.map((item, index) => String(index + 1) + ORDERED_ITEM + item).join(LINE_END); };