[openstreetmap/openstreetmap-website] Provide a truncated view of recent diaries (PR #5121)
David Tsiklauri
notifications at github.com
Tue Dec 24 07:25:48 UTC 2024
@nertc commented on this pull request.
> + if accumulated_length >= max_length
+ node.remove unless !last_child.nil? && last_child.ancestors.include?(node)
+ next
+ end
+
+ next unless node.children.empty?
+
+ accumulated_length += node.text? ? node.text.length : empty_tag_length
+ if accumulated_length < max_length
+ last_child = node
+ else
+ node.remove
+ end
+ end
+
+ RichText::SimpleFormat.new.sanitize(doc)
Sorry for the late answer. As HTML was truncated and, therefore, changed, Ruby required additional sanitization to ensure that everything was still okay. I'll move truncation method in the `RichText::Base`. I think, it will solve most of problems and additional complexities introduced by adding this method to the concern.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5121#discussion_r1896487537
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5121/review/2521592592 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241223/61968fa3/attachment.htm>
More information about the rails-dev
mailing list