Skip to content

Add singleParagraphBreak property #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HTMLView.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class HtmlView extends Component {

const opts = {
addLineBreaks: this.props.addLineBreaks,
singleParagraphBreak: this.props.singleParagraphBreak,
linkHandler: this.props.onLinkPress,
styles: Object.assign({}, baseStyles, this.props.stylesheet),
customRenderer: this.props.renderNode,
Expand Down Expand Up @@ -91,10 +92,12 @@ HtmlView.propTypes = {
onLinkPress: PropTypes.func,
onError: PropTypes.func,
renderNode: PropTypes.func,
singleParagraphBreak: PropTypes.bool,
};

HtmlView.defaultProps = {
addLineBreaks: true,
singleParagraphBreak: false,
onLinkPress: url => Linking.openURL(url),
onError: console.error.bind(console),
};
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ props:
- `defaultRenderer` the default rendering implementation, so you can use the normal rendering logic for some subtree. `defaultRenderer` takes the following arguments:
- `node` the node to render with the default rendering logic
- `parent` the parent of node of `node`
- `singleParagraphBreak`: changes the paragraph break from the defualt of two lines to one line.

### Example

Expand Down
2 changes: 1 addition & 1 deletion htmlToElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function htmlToElement(rawHtml, opts, done) {
break;
case 'p':
if (index < list.length - 1) {
linebreakAfter = PARAGRAPH_BREAK;
linebreakAfter = opts.singleParagraphBreak ? LINE_BREAK : PARAGRAPH_BREAK;
}
break;
case 'br':
Expand Down