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}/> ```

11 lines (7 loc) 232 B
'use strict' exports.__esModule = true exports.default = _default function _default(str, n = 2) { const _multiBreakRe = new RegExp('(\n{' + (n + 1) + ',})', 'g') return str.replace(str._multiBreakRe, '\n'.repeat(n)).trim() }