ifrs9-ecl-copilot / app /ui /src /numText.jsx
Preetomsorkar's picture
UI v3: fintech-direction design pass (5 grafts), waterfall historical-mode fix, explain-strip placement + shared hook, palette contrast fix
20abf65 verified
Raw
History Blame Contribute Delete
559 Bytes
/** Wrap every numeric token in agent-answer prose in a `.num` span
* (tabular-nums, `--ink` — FINAL_SPEC §2 "numbers quoted inline in agent
* answers"). Display-only formatting; never re-parses/re-computes the
* number, just re-wraps the substring the answer already contains. */
const NUM_RE = /([+\-−]?\$?\d[\d,]*\.?\d*(?:pp|%|x|m)?\b)/g;
export function renderWithNums(text) {
if (!text) return text;
const parts = String(text).split(NUM_RE);
return parts.map((part, i) => (i % 2 === 1 ? <span class="num" key={i}>{part}</span> : part));
}