Parse a string to produce a map from property to attribute string.  Example: "color:red; foo:12px" produces a token {color: "color:red", foo:"foo:12px"}
508640
function (attrString) {
    var tokens = {};

    // Regex for parsing a css attribute declaration, taken from css-parse:
    // https://github.com/reworkcss/css-parse/blob/7cef3658d0bba872cde05a85339034b187cb3397/index.js#L219
    var regex = /(\*?[-#\/\*\\\w]+(?:\[[0-9a-z_-]+\])?)\s*:\s*(?:\'(?:\\\'|.)*?\'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+[;\s]*/g;
    var match = regex.exec(attrString);
    while (match) {
      // match[0] = entire matching string
      // match[1] = css property
      // Prefix the token to prevent conflicts with existing properties.

      // XXX No `String.trim` on Safari 4. Swap out $.trim if we want to
      // remove strong dep on jquery.
      tokens[' ' + match[1]] = match[0].trim ?
        match[0].trim() : $.trim(match[0]);

      match = regex.exec(attrString);
    }

    return tokens;
  }
1116294
function parseAttributes(attrStr) {
    var reAttributes = /([^=<>\"\'\s]+)\s*(?:=\s*["']?([^"']*)["']?)?/g;
    var result = {};
    var match;

    if (attrStr) {
        while (match = reAttributes.exec(attrStr)) {
            result[match[1]] = match[2] || true;
        }
    }

    return result;
}
1371006
def _parse(data, obj_name, attr_map):
    """"""
    parsed_xml = minidom.parseString(data)
    parsed_objects = []
    for obj in parsed_xml.getElementsByTagName(obj_name):
        parsed_obj = {}
        for (py_name, xml_name) in attr_map.items():
            parsed_obj[py_name] = _get_minidom_tag_value(obj, xml_name)
        parsed_objects.append(parsed_obj)
    return parsed_objects
38809
private AttributeDescr stringAttribute(AttributeSupportBuilder<?> as,
            String[] key) throws RecognitionException {
        AttributeDescrBuilder<?> attribute = null;
        try {
            StringBuilder builder = new StringBuilder();
            for (String k : key) {
                if ("-".equals(k)) {
                    match(input,
                            DRL6Lexer.MINUS,
                            k,
                            null,
                            DroolsEditorType.KEYWORD); // part of the keyword
                    if (state.failed)
                        return null;
                } else {
                    match(input,
                            DRL6Lexer.ID,
                            k,
                            null,
                            DroolsEditorType.KEYWORD);
                    if (state.failed)
                        return null;
                }
                builder.append(k);
            }
            if (state.backtracking == 0) {
                attribute = helper.start((DescrBuilder<?, ?>) as,
                        AttributeDescrBuilder.class,
                        builder.toString());
            }

            Token value = match(input,
                    DRL6Lexer.STRING,
                    null,
                    null,
                    DroolsEditorType.STRING_CONST);
            if (state.failed)
                return null;
            if (state.backtracking == 0) {
                attribute.value(StringUtils.unescapeJava(safeStripStringDelimiters(value.getText())));
                attribute.type(AttributeDescr.Type.STRING);
            }
        } finally {
            if (attribute != null) {
                helper.end(AttributeDescrBuilder.class,
                        attribute);
            }
        }
        return attribute != null ? attribute.getDescr() : null;
    }
560386
function (str, parserOptions) {
  parserOptions = parserOptions || {};
  // Do a naive test whether this is a string or an object
  var mapFn = parserOptions.map ? str.trim().charAt(0) === '[' ? underscore.map : underscore.mapObject : identity;
  var jsonParser = JSON.parse;
  return mapFn(jsonParser(str, parserOptions.reviver, parserOptions.filename), parserOptions.map);
}
1110093
public static StringValueMap fromString(String line) {
		StringValueMap result = new StringValueMap();
		if (line == null || line.length() == 0)
			return result;

		// Todo: User tokenizer / decoder
		String[] tokens = line.split(";", -1);

		for (String token : tokens) {
			if (token.length() == 0)
				continue;
			int index = token.indexOf('=');
			String key = index > 0 ? token.substring(0, index).trim() : token.trim();
			String val = index > 0 ? token.substring(index + 1).trim() : null;
			result.put(key, val);
		}

		return result;
	}
1270087
function attrsToString(attrs) {
  return Object.keys(attrs)
    .map(key => `${key}="${attrs[key]}"`)
    .join(' ');
}
681098
function parseProps(attributes, prefix) {
  prefix += '-';

  const props = {};

  for (const prop in attributes) {
    // Strip 'inline-' and store
    if (prop.indexOf(prefix) == 0) {
      let value = attributes[prop];

      if (value === 'false') {
        value = false;
      }
      if (value === 'true') {
        value = true;
      }
      props[prop.slice(prefix.length)] = value;
    }
  }

  return props;
}
805430
function nameToHex(color: string): string {
  if (typeof color !== 'string') return color
  const normalizedColorName = color.toLowerCase()
  return namedColorMap[normalizedColorName]
    ? `#${namedColorMap[normalizedColorName]}`
    : color
}
88183
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'fillcolor'
          @fill_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
        when 'opacity'
          @opacity = value.value.to_f
        when 'strokecolor'
          @stroke_color = Color.new(parent: self).parse_hex_string(value.value.delete('#'))
        when 'strokeweight'
          @stroke_weight = value.value.to_f
        end
      end
      self
    end
468371
function parseAttributes(attributes) {
  for (const prop in attributes) {
    // Parse boolean values
    if (attributes[prop] === '') {
      attributes[prop] = true;
    }
  }

  return attributes;
}
1343587
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'val'
          @value = value.value.to_sym
        when 'color'
          @color = value.value.to_sym
        when 'fill'
          @fill = Color.new(parent: self).parse_hex_string(value.value.to_s)
        end
      end
      self
    end
1177951
protected void parseAttribute(Token token) {
        // TODO this is a monster copy/paste - would be nicer to fix in the underlying library! :)
        token.setType(Type.ATTRIBUTE);

        parseName("attribute");

        if (pos == token.getStartOffset())
            throw new XMLParseException("Expected attribute name", source, pos);

        skipWhiteSpace();
        expect('=');
        skipWhiteSpace();

        char c = 0;
        if (pos < source.length())
            c = source.charAt(pos);
        if (c != '\'' && c != '"')
            throw new XMLParseException("Expected single or double quotes", source, pos);

        char endChar = c;
        boolean insideEntity = false;
        int errorPos = pos;

        while (true) {
            pos++;
            if (pos >= source.length()) {
                int i = Math.min(20, source.length() - token.getStartOffset());
                throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: "
                        + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
            }

            c = source.charAt(pos);
            if (c == endChar)
                break;

            if (c == '<')
                throw new XMLParseException("Illegal character in attribute value: '" + c + "'", source, pos);

            if (c == '&') {
                insideEntity = true;
                errorPos = pos;
            } else if (c == ';') {
                verifyEntity(errorPos, pos + 1);
                insideEntity = false;
            } else {
                String msg = charValidator.isValid(source, pos);
                if (msg != null)
                    throw new XMLParseException("Illegal character found in attribute value. " + msg, source, pos);

                skipChar(c);
                pos--;
            }
        }

        if (insideEntity) {
            throw new XMLParseException("Missing ';' after '&': " + lookAheadForErrorMessage(null, errorPos, 20), source, errorPos);
        }

        // Skip end-char
        pos++;
    }
1074906
def attribute(string)

      attribute_name = ""
      attribute_value = ""

      length = string.length
      position = 0

      return [nil, nil] if length == 0 

      while position < (length)

        # If character matches 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x2F (ASCII /) then advance position
        if string[position] =~ /[\u{09}\u{0A}\u{0C}\u{0D}\u{20}\u{2f}]/
          
          position += 1
        
        elsif string[position] == '>'

          attribute_name = nil
          break

        else

          while position < length
          
            if string[position] == '=' && attribute_name != ''

              attribute_value, position_increment = attribute_value(string[position + 1, length])

              position += position_increment + 1

              break

            elsif string[position] =~ /[\>\/]/
              
              break
            
            elsif string[position] =~ /[A-Z]/

              attribute_name += string[position].downcase
              position += 1

            else
              attribute_name += string[position]
              position += 1
            end

          end

          break

        end

      end

      if attribute_name
        [{attribute_name: attribute_name, attribute_value: attribute_value}, position]
      else
        [nil, position]
      end

    end
781192
function (attributes) {
            var self = this;
            var retVal = {};
            var ctxMappings = {};
             _.each(attributes, function (attribute, k) {
                var isCtxMapping = _.isString(attribute) && !attribute.indexOf('$');
                if (isCtxMapping) {
                    ctxMappings[k] = attribute;
                } else {
                    retVal[k] = attribute;
                }

                return isCtxMapping;
            });

            _.each(ctxMappings, function (val, k) {
                self._resolveCtxVal(retVal, val, k);
            });

            return retVal;
        }
1042762
def parse_color(color):
    
    r = g = b = a = type = None
    if color.startswith('#'):
        color = color[1:]
        if len(color) == 3:
            type = '#rgb'
            color = color + 'f'
        if len(color) == 4:
            type = type or '#rgba'
            color = ''.join([c * 2 for c in color])
        if len(color) == 6:
            type = type or '#rrggbb'
            color = color + 'ff'
        assert len(color) == 8
        type = type or '#rrggbbaa'
        r, g, b, a = [
            int(''.join(c), 16) for c in zip(color[::2], color[1::2])
        ]
        a /= 255
    elif color.startswith('rgb('):
        type = 'rgb'
        color = color[4:-1]
        r, g, b, a = [int(c) for c in color.split(',')] + [1]
    elif color.startswith('rgba('):
        type = 'rgba'
        color = color[5:-1]
        r, g, b, a = [int(c) for c in color.split(',')[:-1]
                      ] + [float(color.split(',')[-1])]
    return r, g, b, a, type
70124
def parse_color(color):
    '''

    '''
    
    # Let's parse the color string
    if isinstance(color, str):
        # Try dvi names
        try:
            col = get(color)
        except ValueError:
            # String is not present
            pass

        # Try html names
        try:
            col = html_to_rgb(color)
        except ValueError:
            raise ValueError("Can't parse color string: {}'".format(color))
        
    return col