Sha256: 2761bc8090623f26778b9ef38535be6f10fa1cd5ea391fe712a6e184953302e1

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

module MicroMicro
  module Parsers
    class PlainTextPropertyParser < BasePropertyParser
      HTML_ATTRIBUTES_MAP = {
        'title' => %w[abbr link],
        'value' => %w[data input],
        'alt'   => %w[area img]
      }.freeze

      # @see https://microformats.org/wiki/microformats2-parsing#parsing_a_p-_property
      #
      # @return [String]
      def value
        @value ||= value_class_pattern_value || attribute_value || super
      end

      private

      # @return [String, nil]
      def attribute_value
        Helpers.attribute_value_from(node, HTML_ATTRIBUTES_MAP)
      end

      # @return [String, nil]
      def value_class_pattern_value
        ValueClassPatternParser.new(node).value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
micromicro-2.0.1 lib/micro_micro/parsers/plain_text_property_parser.rb
micromicro-2.0.0 lib/micro_micro/parsers/plain_text_property_parser.rb