Sha256: b30152879fc476daeb4a43cc029ae02b6662068a4f4f5b9e9e171a51462db5f8

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

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

      # @see http://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
        self.class.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

1 entries across 1 versions & 1 rubygems

Version Path
micromicro-1.0.0 lib/micro_micro/parsers/plain_text_property_parser.rb