/** Small helpers for writing HTML by hand, and the design's drawn marks. */
export const esc = (s: string): string =>
s.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """);
/** The design's drawings (site-v2 build.py), unchanged. */
export const ARROW = '';
export const RING =
'';
export const THREAD =
'';
export const QUOTE =
'';
export const LOOSE =
'';
/**
* A hyphenated word never splits at its hyphen (to-dos, one-time): text only, never inside a tag, a title or a
* style. The design's keep_together, as it is.
*/
export function keepTogether(page: string): string {
const parts = page.split(/(<[^>]+>)/);
let skip = false;
for (let i = 0; i < parts.length; i++) {
const part = parts[i]!;
if (part.startsWith("<")) {
if (/^<(title|style)\b/.test(part)) skip = true;
if (/^<\/(title|style)>/.test(part)) skip = false;
continue;
}
if (!skip) parts[i] = part.replace(/(?$1');
}
return parts.join("");
}