README.md in draftjs_html-0.7.0 vs README.md in draftjs_html-0.8.0
- old
+ new
@@ -75,10 +75,21 @@
#### `:encoding`
Specify the HTML generation encoding.
Defaults to `UTF-8`.
+#### `squeeze_newlines`
+
+Often times, we'll get text in our blocks that will generate unexpected HTML.
+Most of this is caused by whitespace.
+You can use the `squeeze_newlines` option to collapse consecutive newline/CRLF characters to one, resulting in a single `<br>` tag.
+Defaults to `false`.
+
+```ruby
+
+```
+
#### `:entity_style_mappings`
Allows the author to specify special mapping functions for entities.
By default, we render `LINK` and `IMAGE` entities using the standard `<a>` and `<img>` tags, respectively.
The author may supply a `call`-able object that returns a `DraftjsHtml::Node`-able (or similar).
@@ -91,15 +102,14 @@
By default, we convert block types to tags as defined by `DraftjsHtml::ToHtml::BLOCK_TYPE_TO_HTML`.
These may be overridden and appended to, like so:
```ruby
DraftjsHtml.to_html(raw_draftjs, options: {
- block_type_mapping: {
- 'unstyled' => 'span',
- },
+ squeeze_newlines: true,
})
-# This would generate <span> tags instead of <p> tags for "unstyled" DraftJS blocks.
+# Given a DraftJS block like: `{ text: 'Hi!\n\n\nWelcome to Westeros!\n\n\n'}`
+# This would generate `<p>Hi!<br>Welcome to Westeros!<br></p>`
```
#### `:inline_style_mapping`
You may wish to override the default HTML tags used to render DraftJS `inlineStyleRanges`.