Sha256: 0f9c5ad4d8039ced859bf34ec4ad21f558b3a9add0d33cb19ea4e1fd909b82b0
Contents?: true
Size: 1013 Bytes
Versions: 3
Compression:
Stored size: 1013 Bytes
Contents
# frozen_string_literal: true module MicroMicro module Parsers class ImpliedNamePropertyParser < BaseImpliedPropertyParser HTML_ELEMENTS_MAP = { 'img' => 'alt', 'area' => 'alt', 'abbr' => 'title' }.freeze # @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties # microformats.org: microformats2 parsing specification ยง Parsing for implied properties # # @return [String] def value @value ||= attribute_value || text_content end private # @return [Array] def child_nodes [ node.at_css('> :only-child'), node.at_css('> :only-child > :only-child') ].compact.reject { |child_node| Helpers.item_node?(child_node) } end # @return [String] def text_content Helpers.text_content_from(node) do |context| context.css('img').each { |img| img.content = img['alt'] } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems