Something went wrong. Try again.
leaflet fork for copy edit / bug fixes forked from leaflet.pub/leaflet
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748export type TierDescriptionMark = { type: string; attrs?: { href?: string };};
export type TierDescriptionInline = { type: string; text?: string; marks?: TierDescriptionMark[];};
export type TierDescriptionParagraph = { type: string; content?: TierDescriptionInline[];};
export type TierDescriptionDoc = { type: "doc"; content: TierDescriptionParagraph[];};
export function parseTierDescriptionDoc( description: string | null | undefined,): TierDescriptionDoc | null { if (!description || description[0] !== "{") return null; try { let doc = JSON.parse(description); if (doc && doc.type === "doc" && Array.isArray(doc.content)) return doc as TierDescriptionDoc; } catch {} return null;}
export function tierDescriptionPlainText( description: string | null | undefined,): string { let doc = parseTierDescriptionDoc(description); if (!doc) return description ?? ""; return doc.content .map((p) => (p.content ?? []) .map((n) => (n.type === "hard_break" ? "\n" : n.text ?? "")) .join(""), ) .join("\n") .trim();}