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

Anton Khorev notifications at github.com
Mon Nov 11 11:11:45 UTC 2024


@AntonKhorev commented on this pull request.



> @@ -2,7 +2,7 @@
   <%= render :partial => "diary_entry_heading", :object => diary_entry, :as => "diary_entry" %>
 
   <div class="richtext text-break" xml:lang="<%= diary_entry.language_code %>" lang="<%= diary_entry.language_code %>">
-    <%= diary_entry.body.to_html %>
+    <%= truncated ? diary_entry.truncated_body(1000).to_html : diary_entry.body.to_html %>

First markdown from the RichText object is converted to html. Then html is processed by `truncated_body` and a new RichText object is constructed. Then html is again extracted from that object. And if the html is nontrivial it may get mangled in the process, turning, for example, this

```
There's a table below:

| thing | 42 | an important thing |
| thing | 43 | an important thing |
```

![image](https://github.com/user-attachments/assets/06149a10-3199-4881-bf89-091ec8842dc6)

into this

![image](https://github.com/user-attachments/assets/0661fb58-0bc4-414c-b850-476c6621873a)


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

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


More information about the rails-dev mailing list