<span style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">
  <h3 dir="auto">URL</h3>
<p dir="auto"><a href="https://www.openstreetmap.org/changeset/163401189" rel="nofollow">https://www.openstreetmap.org/changeset/163401189</a></p>
<h3 dir="auto">How to reproduce the issue?</h3>
<p dir="auto">This is a sub-issue of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1108345241" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/3428" data-hovercard-type="issue" data-hovercard-url="/openstreetmap/openstreetmap-website/issues/3428/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/issues/3428">#3428</a>.</p>
<p dir="auto">Some keywords for search: RTL bidi bidirectional LTR</p>
<p dir="auto">Comments inherit the directionality of the entire website instead of the directionality of their content. Example screenshot:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/db2127c5-cb13-436b-969c-1a9e095bc1a3">image.png (view on web)</a></p>
<p dir="auto">Each comment should have <code class="notranslate">dir="auto"</code> in its HTML. Poking around the source (which I have never worked with before, so this may be wrong), I think I've found the relevant code:</p>
<p dir="auto"><a href="https://github.com/openstreetmap/openstreetmap-website/blob/a0768a4d04d3eb5afa9e8864b8fc73a64286bf2c/app/views/changesets/show.html.erb#L62-L64">https://github.com/openstreetmap/openstreetmap-website/blob/a0768a4d04d3eb5afa9e8864b8fc73a64286bf2c/app/views/changesets/show.html.erb#L62-L64</a></p>
<p dir="auto">So there is a "band-aid" solution and a more involved "full" solution that would produce better results.</p>
<p dir="auto">Band-aid solution takes two steps:</p>
<ol dir="auto">
<li>Add <code class="notranslate">dir="auto"</code> to the above snippet:
<div class="highlight highlight-text-html-erb" dir="auto"><pre class="notranslate">      <span class="pl-kos"><</span><span class="pl-ent">div</span> <span class="pl-c1">class</span>="<span class="pl-s">mx-2</span>" <span class="pl-c1">dir</span>="<span class="pl-s">auto</span>"<span class="pl-kos">></span>
        <span class="pl-k"><%=</span> <span class="pl-en">comment</span><span class="pl-kos">.</span><span class="pl-en">body</span><span class="pl-kos">.</span><span class="pl-en">to_html</span> <span class="pl-k">%></span>
      <span class="pl-kos"></</span><span class="pl-ent">div</span><span class="pl-kos">></span></pre></div>
</li>
<li>Add <code class="notranslate">text-align: start;</code> to the <code class="notranslate">mx-2</code> class CSS.</li>
</ol>
<p dir="auto">Result:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/4cf22bf6-d99a-473a-b8b3-e907fe35fdc8">image.png (view on web)</a></p>
<p dir="auto">Perfect.</p>
<p dir="auto">The full solution would take into account the fact that different paragraphs should have different directionality. For example, if I write:</p>
<pre class="notranslate"><code class="notranslate">This line is English and should be LTR.

השורה הזאת בעברית וצריכה להיות מימין לשמאל.

השורה הזאת מערבבת LTR ו-RTL אבל מתחילה ב-RTL ולכן צריכה להיות מימין לשמאל.
</code></pre>
<p dir="auto">Github would render it correctly:</p>
<blockquote>
<p dir="auto">This line is English and should be LTR.</p>
<p dir="auto">השורה הזאת בעברית וצריכה להיות מימין לשמאל.</p>
<p dir="auto">השורה הזאת מערבבת LTR ו-RTL אבל מתחילה ב-RTL ולכן צריכה להיות מימין לשמאל.</p>
</blockquote>
<p dir="auto">Each of these lines is <code class="notranslate"><p dir="auto"></code> so behaves correctly.</p>
<p dir="auto">However it seems that <code class="notranslate">comment.body.to_html</code> <em>does not</em> split the text into different <code class="notranslate"><p></code> elements, it's instead a single <code class="notranslate"><p></code> with a single text block containing <code class="notranslate"><br /></code> for line splits. <strong>This is not usable for expected formatting.</strong> You would have to replace this function with one that produces separate elements (preferably <code class="notranslate"><p></code>), each with <code class="notranslate">dir="auto"</code>. Couple with appropriate <code class="notranslate">text-align</code> CSS property, and the result would be ideal.</p>
<p dir="auto">I know that changeset comments are not Markdown and should not be parsed as such, but for acceptable results they have to at least be split into <code class="notranslate"><p></code> elements instead of using <code class="notranslate"><br /</code>>. You can use styling to make it appear visually the same as before.</p>
<h3 dir="auto">Screenshot(s) or anything else?</h3>
<p dir="auto"><em>No response</em></p><p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5785">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMEENYENKIKM36GR3D2TVSUXAVCNFSM6AAAAABYVXRPBOVHI2DSMVQWIX3LMV43ASLTON2WKOZSHEYDMNZZGUYDQNA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLNTUFW44QW67CXUPI32TVSUXA5CNFSM6AAAAABYVXRPBOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHK2QRMJQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/5785</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
</span>


<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img alt="NeatNit" height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/2400026?s=20&v=4" /><strong>NeatNit</strong> created an issue <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5785">(openstreetmap/openstreetmap-website#5785)</a></div>
<h3 dir="auto">URL</h3>
<p dir="auto"><a href="https://www.openstreetmap.org/changeset/163401189" rel="nofollow">https://www.openstreetmap.org/changeset/163401189</a></p>
<h3 dir="auto">How to reproduce the issue?</h3>
<p dir="auto">This is a sub-issue of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1108345241" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/3428" data-hovercard-type="issue" data-hovercard-url="/openstreetmap/openstreetmap-website/issues/3428/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/issues/3428">#3428</a>.</p>
<p dir="auto">Some keywords for search: RTL bidi bidirectional LTR</p>
<p dir="auto">Comments inherit the directionality of the entire website instead of the directionality of their content. Example screenshot:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/db2127c5-cb13-436b-969c-1a9e095bc1a3">image.png (view on web)</a></p>
<p dir="auto">Each comment should have <code class="notranslate">dir="auto"</code> in its HTML. Poking around the source (which I have never worked with before, so this may be wrong), I think I've found the relevant code:</p>
<p dir="auto"><a href="https://github.com/openstreetmap/openstreetmap-website/blob/a0768a4d04d3eb5afa9e8864b8fc73a64286bf2c/app/views/changesets/show.html.erb#L62-L64">https://github.com/openstreetmap/openstreetmap-website/blob/a0768a4d04d3eb5afa9e8864b8fc73a64286bf2c/app/views/changesets/show.html.erb#L62-L64</a></p>
<p dir="auto">So there is a "band-aid" solution and a more involved "full" solution that would produce better results.</p>
<p dir="auto">Band-aid solution takes two steps:</p>
<ol dir="auto">
<li>Add <code class="notranslate">dir="auto"</code> to the above snippet:
<div class="highlight highlight-text-html-erb" dir="auto"><pre class="notranslate">      <span class="pl-kos"><</span><span class="pl-ent">div</span> <span class="pl-c1">class</span>="<span class="pl-s">mx-2</span>" <span class="pl-c1">dir</span>="<span class="pl-s">auto</span>"<span class="pl-kos">></span>
        <span class="pl-k"><%=</span> <span class="pl-en">comment</span><span class="pl-kos">.</span><span class="pl-en">body</span><span class="pl-kos">.</span><span class="pl-en">to_html</span> <span class="pl-k">%></span>
      <span class="pl-kos"></</span><span class="pl-ent">div</span><span class="pl-kos">></span></pre></div>
</li>
<li>Add <code class="notranslate">text-align: start;</code> to the <code class="notranslate">mx-2</code> class CSS.</li>
</ol>
<p dir="auto">Result:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/4cf22bf6-d99a-473a-b8b3-e907fe35fdc8">image.png (view on web)</a></p>
<p dir="auto">Perfect.</p>
<p dir="auto">The full solution would take into account the fact that different paragraphs should have different directionality. For example, if I write:</p>
<pre class="notranslate"><code class="notranslate">This line is English and should be LTR.

השורה הזאת בעברית וצריכה להיות מימין לשמאל.

השורה הזאת מערבבת LTR ו-RTL אבל מתחילה ב-RTL ולכן צריכה להיות מימין לשמאל.
</code></pre>
<p dir="auto">Github would render it correctly:</p>
<blockquote>
<p dir="auto">This line is English and should be LTR.</p>
<p dir="auto">השורה הזאת בעברית וצריכה להיות מימין לשמאל.</p>
<p dir="auto">השורה הזאת מערבבת LTR ו-RTL אבל מתחילה ב-RTL ולכן צריכה להיות מימין לשמאל.</p>
</blockquote>
<p dir="auto">Each of these lines is <code class="notranslate"><p dir="auto"></code> so behaves correctly.</p>
<p dir="auto">However it seems that <code class="notranslate">comment.body.to_html</code> <em>does not</em> split the text into different <code class="notranslate"><p></code> elements, it's instead a single <code class="notranslate"><p></code> with a single text block containing <code class="notranslate"><br /></code> for line splits. <strong>This is not usable for expected formatting.</strong> You would have to replace this function with one that produces separate elements (preferably <code class="notranslate"><p></code>), each with <code class="notranslate">dir="auto"</code>. Couple with appropriate <code class="notranslate">text-align</code> CSS property, and the result would be ideal.</p>
<p dir="auto">I know that changeset comments are not Markdown and should not be parsed as such, but for acceptable results they have to at least be split into <code class="notranslate"><p></code> elements instead of using <code class="notranslate"><br /</code>>. You can use styling to make it appear visually the same as before.</p>
<h3 dir="auto">Screenshot(s) or anything else?</h3>
<p dir="auto"><em>No response</em></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5785">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMEENYENKIKM36GR3D2TVSUXAVCNFSM6AAAAABYVXRPBOVHI2DSMVQWIX3LMV43ASLTON2WKOZSHEYDMNZZGUYDQNA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLNTUFW44QW67CXUPI32TVSUXA5CNFSM6AAAAABYVXRPBOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHK2QRMJQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/5785</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>

<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/5785",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/5785",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>