import { Fragment, type ReactNode } from "react";
// The plan files' inline marks, for a page that quotes one (the channel context notes' evidence). Server-safe.
/** `**bold**` and `` `code` `` -- all the plan's evidence lines use. */
export function inline(s: string): ReactNode {
const out: ReactNode[] = [];
const re = /\*\*(.+?)\*\*|`([^`]+)`/g;
let at = 0;
let k = 0;
for (let m = re.exec(s); m; m = re.exec(s)) {
if (m.index > at) out.push({s.slice(at, m.index)});
out.push(m[1] !== undefined ? {inline(m[1])} : {m[2]});
at = m.index + m[0].length;
}
if (at < s.length) out.push({s.slice(at)});
return out;
}