[openstreetmap/openstreetmap-website] Add dir="auto" to Markdown content for bidi (PR #5840)

Anton Khorev notifications at github.com
Thu Mar 27 02:33:28 UTC 2025


AntonKhorev left a comment (openstreetmap/openstreetmap-website#5840)

This is a version that modifies the document, consisting of replaced `document` method, assuming we don't need to add `dir` on inline elements:

```ruby
    def document
      return @document if @document

      @document = Kramdown::Document.new(self)

      add_dir = lambda do |element|
        target_types = %w[p header pre codeblock ul ol table dl math]
        element.attr["dir"] ||= "auto" if target_types.include?(element.type == :html_element ? element.value : element.type.to_s)
        element.children.each(&add_dir)
      end
      add_dir.call(@document.root)

      @document
    end
```

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

Message ID: <openstreetmap/openstreetmap-website/pull/5840/c2756304298 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250326/7a02938b/attachment-0001.htm>


More information about the rails-dev mailing list