<p></p>
<p><b>@tomhughes</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5840#discussion_r2014816161">lib/rich_text.rb</a>:</p>
<pre style='color:#555'>> + # "li", # child; sometimes container
+
+ "table", # similar to Discourse, where the <div> parent of <table> gets dir="auto" (no parent div in kramdown)
+ # "td", # child
+ # "th", # child; not actually a thing in kramdown but hypothetically might be in the future
+
+ "dl",
+ # "dd", "dt", # child - since it's similar to a list, it has the same behavior as a list
+
+ "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
</pre>
<p dir="auto">What happens if we don't restore the original attributes? Does the element get reused in a way that breaks things?</p>
<p dir="auto">I can't say for sure as I couldn't find anything that broke when that restore was removed but would just doing <code class="notranslate">el = el.dup</code> as the first thing to duplicate the element be a workable alternative?</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#pullrequestreview-2718316456">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMWGTVNQ7LYYWAARM32WLSFHAVCNFSM6AAAAABZTMJBMKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDOMJYGMYTMNBVGY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMLMHYDQY72YQ4QROL2WLSFHA5CNFSM6AAAAABZTMJBMKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTVCAY32Q.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/2718316456</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#pullrequestreview-2718316456",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5840#pullrequestreview-2718316456",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>