UNPKG

@render-props/paragraphs

Version:

A function as child component which provides an interface for creating paragraphs with line breaks from raw text with `\n` new lines. The default render child is: ```js const defaultParagraph = props => <p key={props.key} children={props.text}/> ```

5 lines (4 loc) 163 B
export default function (str, n = 2) { const _multiBreakRe = new RegExp(`(\n{${n + 1},})`, 'g') return str.replace(str._multiBreakRe, '\n'.repeat(n)).trim() }