Something went wrong. Try again.
🌿 Collaborative wiki on ATProto lichen.wiki
atmosphere social atproto app
Something went wrong. Try again.
682 B · 22 lines
TypeScript
at main
1234567891011121314151617181920212223const blank = (text: string): string => " ".repeat(text.length);
// Code renders no tag or wikilink; offsets are kept so a match maps back. Indented// code stays: telling it from a list continuation needs a block parse.export function maskCode(content: string): string { let fence: string | null = null; return content .split("\n") .map((line) => { const marker = /^[ \t]*(`{3,}|~{3,})/.exec(line); if (fence !== null) { if (marker && line.trimStart().startsWith(fence)) fence = null; return blank(line); } if (marker) { fence = marker[1] as string; return blank(line); } return line.replace(/(`+)[^`]*?\1/g, blank); }) .join("\n");}