@nertc commented on this pull request.


> +  def truncate_html(html, max_length, empty_tag_length = 500)
+    doc = Nokogiri::HTML::DocumentFragment.parse(html)
+    accumulated_length = 0
+    truncated_node = nil
+
+    doc.traverse do |node|
+      if accumulated_length >= max_length
+        node.remove unless truncated_node.ancestors.include?(node)
+        next
+      end
+
+      next unless node.children.empty?
+
+      content_length = node.text? ? node.text.length : empty_tag_length
+      if accumulated_length + content_length >= max_length
+        node.content = node.text.truncate(max_length - accumulated_length) if 
node.text?

Truncation was removed and character limit was increased to 2000. Thanks for 
reviewing.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5121#discussion_r1847067632
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/5121/review/2443395...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to