Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 237x 1x 236x 236x 236x 210x | // based in part on this SO answer: https://codereview.stackexchange.com/a/211511 export default function Plaintext({text}) { if (text==null) { return (<pre data-testid="plaintext-empty"></pre>) } const textToRender = typeof text === "string" ? text : JSON.stringify(text, null, 2); const [firstLine, ...rest] = textToRender.split('\n') return ( <pre data-testid="plaintext"> <span>{ firstLine }</span> { rest.map((line) => ( <> <br /> <span>{ line }</span> </> )) } </pre> ); } |