-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Trix adds newline after list #1085
Comments
This problem is not limited to lists, it's the same with <code>, quoted Text and Links. |
We ran into this too, where an extra newline was being added here.
We were using Nokogiri to process the HTML before storage. Nokogiri can add newline characters by default because of the For example, if the HTML that Trix passes down to the server is something like this: html = "<div>X:<br><br></div><ul><li>Y</li><li>Z</li></ul>" Running it through Nokogiri will add newlines: doc = Nokogiri::HTML::DocumentFragment.parse(html)
# (Do other stuff to the doc here)
doc.to_html
=> "<div>X:<br><br>\n</div><ul>\n<li>Y</li>\n<li>Z</li>\n</ul>" Then passing that to Trix will cause an extra "<div>X:<br><br><br></div><ul><li>Y</li><li>Z</li></ul>" In our case, we were able to work around this by stripping out the doc.to_html(save_with: Nokogiri::XML::Node::SaveOptions::AS_HTML)
=> "<div>X:<br><br></div><ul><li>Y</li><li>Z</li></ul>" |
If there is a list (ordered or unordered) at the end of the data, trix adds another
<div><br></div>
to the end. So if you submit the data and reopen the editor three times you have 3 extra lines in the data.Steps to Reproduce
Details
The text was updated successfully, but these errors were encountered: