[openstreetmap/openstreetmap-website] Provide a truncated view of recent diaries (PR #5121)

Anton Khorev notifications at github.com
Sat Mar 22 11:53:25 UTC 2025


@AntonKhorev commented on this pull request.



> @@ -65,6 +65,42 @@ def description
 
     protected
 
+    def truncate_html(html_doc, max_length = nil, img_length = 1000)
+      return html_doc if max_length.nil?
+
+      doc = Nokogiri::HTML::DocumentFragment.parse(html_doc)
+      keep_or_discards = %w[p h1 h2 h3 h4 h5 h6 pre a table ul ol dl]
+      accumulated_length = 0
+      parent = nil

If you had to describe the possible values of `parent`, what would you say? It's not a parent of every traversed node.

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

Message ID: <openstreetmap/openstreetmap-website/pull/5121/review/2708013338 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250322/3b58ea9a/attachment.htm>


More information about the rails-dev mailing list