gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.27k stars 382 forks source link

alt Attribute for Emoji Images Should Use Unicode #272

Closed Crissov closed 1 year ago

Crissov commented 7 years ago

Copying emojis from Github and pasting them into Unicode-aware applications that do not support (proprietary) short codes with colons is currently broken.

In emoji_filter.rb:

      # Default attributes for img tag
      def default_img_attrs(name)
        {
          "class" => "emoji".freeze,
          "title" => ":#{name}:",
          "alt" => ":#{name}:",
          "src" => "#{emoji_url(name)}",
          "height" => "20".freeze,
          "width" => "20".freeze,
          "align" => "absmiddle".freeze,
        }
      end

The alternative textual representation of an image of a Unicode emoji is of course the emoji itself! Therefore, line 90 should read something like this: "alt" => "#{code}", or "alt" => "#{emoji_code(name)}",, probably using unicode_aliases.first from gemoji.

Custom "emojis" should probably use `#{name} without colons.

My ruby-fu is sadly not up for the task, so I'm not providing a PR.

gjtorikian commented 1 year ago

Thanks for the report. I believe as of https://github.com/gjtorikian/html-pipeline/pull/373 this is moot for v3.0+.