[openstreetmap/openstreetmap-website] Provide a truncated view of recent diaries (PR #5121)
David Tsiklauri
notifications at github.com
Fri Jan 31 12:44:23 UTC 2025
@nertc commented on this pull request.
> @@ -65,6 +65,32 @@ def description
protected
+ def truncate_html(html_doc, max_length = nil, empty_tag_length = 1000)
+ return html_doc if max_length.nil?
+
+ doc = Nokogiri::HTML::DocumentFragment.parse(html_doc)
+ accumulated_length = 0
+ last_child = nil
+
+ doc.traverse do |node|
>Let's say you have a link, any if that link happens to go over the truncation threshold, the rest of the paragraph gets thrown out. That can make it unreadable.
What do you suggest in this situation instead of removing whole paragraph, should it be done like it was before (like this `This is long paragraph` -> `This is lon...`)?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5121#discussion_r1937216074
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5121/review/2586546982 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250131/5b494014/attachment.htm>
More information about the rails-dev
mailing list