Sha256: e6801ea3e8bb5e1ccd1558197c260c78368eca692216d70565d1695a2c801ebb

Contents?: true

Size: 532 Bytes

Versions: 6

Compression:

Stored size: 532 Bytes

Contents

module SpecHelpers
  class << self
    def styling_of_node(node)
      if node and node['style'].present?
        parse_styling(node['style'])
      else
        []
      end
    end

    def parse_styling(styles)
      styles.split(';').map { |style| parse_style(style) }
    end

    private
      def parse_style(style)
        rule, value = style.split(':', 2).map(&:strip)
        [rule, normalize_escaped_quotes(value)]
      end

      def normalize_escaped_quotes(string)
        string.gsub('%22', '"')
      end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
roadie-2.4.3 spec/support/parse_styling.rb
md-roadie-2.4.2.md.1 spec/support/parse_styling.rb
roadie-2.4.2 spec/support/parse_styling.rb
roadie-2.4.1 spec/support/parse_styling.rb
roadie-2.4.0 spec/support/parse_styling.rb
roadie-2.3.4 spec/support/parse_styling.rb