<p></p>
<p><b>@NeatNit</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5840#discussion_r2017676461">lib/rich_text.rb</a>:</p>
<pre style='color:#555'>> +
+ "math" # don't know how this ends up, but dir="auto" is probably correct
+ ].each do |name|
+ define_method :"convert_#{name}" do |el, indent|
+ attr_bak = el.attr.dup # can't avoid mutating the attr hash, so make a backup
+ el.attr["dir"] = "auto" unless el.attr.key?("dir") # if by some miracle dir is already defined, don't override it
+ ret = super(el, indent)
+ el.attr.replace(attr_bak) # restore backup
+ ret
+ end
+ end
+
+ # only add dir="auto" to bare links
+ def convert_a(el, indent)
+ attr_bak = el.attr.dup
+ el.attr["dir"] = "auto" if !el.attr.key?("dir") && el.attr["href"] == inner(el, indent)
</pre>
<p dir="auto">You're right, the autolinker needs to apply <code class="notranslate">dir="auto"</code> or <code class="notranslate">dir="ltr"</code> too. My code will pretty much only affect links made with the syntax <code class="notranslate"><https://example.com/></code> which is pretty obscure IMHO.</p>
<p dir="auto">Links with custom text (<code class="notranslate">[text](url)</code>) <em>should not</em> have <code class="notranslate">dir</code>. Links made with linkify need <code class="notranslate">dir="auto"</code> to handle cases like these:</p>
<p dir="auto">מילים <a href="https://example.com/%D7%9E%D7%A9%D7%94%D7%95/%D7%9B%D7%9C%D7%A9%D7%94%D7%95" rel="nofollow">https://example.com/משהו/כלשהו</a></p>
<p dir="auto">מילים <a href="https://example.com/%D7%9E%D7%A9%D7%94%D7%95/%D7%9B%D7%9C%D7%A9%D7%94%D7%95/index.html" rel="nofollow">https://example.com/משהו/כלשהו/index.html</a> מילים</p>
<p dir="auto">מילים <a href="https://example.com/" rel="nofollow">https://example.com/</a> מילים</p>
<p dir="auto">all of those links should render as isolated LTR. Note that GitHub falls here. Whereas:</p>
<p dir="auto">מספרים <a href="https://example.com/numbers/" rel="nofollow">one וגם two</a> ועוד</p>
<p dir="auto">the link direction should not be isolated - the word "one" should appear to the right of "two". Result on GitHub is correct.</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/pull/5840#discussion_r2017676461">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLKGIXGD76WPI72CPA32WRUXBAVCNFSM6AAAAABZTMJBMKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDOMRTGU4DANBSGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMZTOXAYSS3HF7AKKD2WRUXBA5CNFSM6AAAAABZTMJBMKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTVCK2FAM.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/pull/5840/review/2723580422</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/pull/5840#discussion_r2017676461",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5840#discussion_r2017676461",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>