Replaces partial content with given attributes

@param {Object|undefined} file - through2's file object
@param {Array.<Object>} attributes - tag
@returns {String}
420437
function replaceAttributes(file, attributes) {
        return (attributes || []).reduce((html, attrObj) =>
            html.replace(options.variablePrefix + attrObj.key, attrObj.value), file && file.toString() || '');
    }
777543
function replace(content, filename) {
    var dirname = nps.dirname(filename)

    return content.replace(
      new RegExp(
        '(^\\s*)' + prefix + '\\s*(.+?)\\s*' + suffix + '(\\s*\\n?)$',
        'gm'
      ),
      // /@\s*(.+?)\s*@/g,
      function(m, preappend, path, newlineOrNull) {
        var currLink = path.trim()
        var fullpath = ''

        // link::[why-need-require]../refs/why-need-require.md
        if (disableValue !== 'link' && currLink.startsWith('link::')) {
          var title = ''
          path = ''

          if (/^link::\[(.+?)\](.+)/.test(currLink)) {
            title = RegExp.$1
            path = RegExp.$2
            title = title && title.trim() ? title.trim() : path
          } else if (/^link::(.+)/.test(currLink)) {
            title = RegExp.$1
            path = RegExp.$1
          }

          fullpath = checkPath(path, dirname, selfFilename, true, alias)

          if (fullpath) {
            var link = findLink(filesMap, fullpath)
            if (link !== false) {
              return preappend + '[' + title + '](' + link + ')' + newlineOrNull
            }
          }
        }

        if (disableValue !== 'file-content') {
          fullpath = checkPath(currLink, dirname, filename, false, alias)
          if (fullpath) {
            var fileContent = fs.readFileSync(fullpath).toString()
            if (deep) {
              fileContent = replace(fileContent, fullpath)
            }

            return fileContent + newlineOrNull
          }
        }

        return m
      }
    )
  }
157426
function(keypath, content, attributes) {
      var attrs = {'for': this._attributesForKeyPath(keypath).name};
      return simple_element('label', $.extend(attrs, attributes), content);
    }
968505
function inlineLocalContent() {
      // inline local javascript
      filecontent = filecontent.replace(sre, function(matched, src) {
        if (!incfiles[src]) {
          return matched; // This file wasn't available
        }
        return matched.replace(srcre, '') + '\n' + incfiles[src];
      });
      // now inline local css
      filecontent = filecontent.replace(cre, function(matched, src) {
        var tag;
        if (!incfiles[src]) {
          return matched;
        }
        if (matched.toLowerCase().search('stylesheet') === -1) {
          return matched;
        }
        tag = matched.replace(hrefre, ''); // remove href attribute
        tag = tag.replace(crerel, ''); // remove rel attribute
        tag = tag.replace(cretag, '<style'); // change link to style
        tag = tag.replace(creend, '>'); // remove possible self-closing in style tag
        return tag + '\n' + incfiles[src] + '\n</style>';
      });
      //console.log(filecontent);
      resolve(filecontent);
    }
800820
function replaceK(s) {
  if (/-/.test(s)) {
    if (/attr/.test(s)) { return 'Attributes Plugin'}
    if (/svg/.test(s)) { return 'SVG Plugin'}
    if (/css/.test(s)) { return 'CSS Plugin'}
    if (/text/.test(s)) { return 'Text Plugin'}
  } else {
    return 'Core Engine';
  }
}
10817
function(attributes) {
  this.attributes = attributes;

  // Pull off preserved properties from attributes
  // --------

  this.tagName = attributes.tag;
  this.children = attributes.children || [];
  this.text = attributes.text || "";
  this.html = attributes.html;

  delete attributes.children;
  delete attributes.text;
  delete attributes.html;
  delete attributes.tag;

  return this.render();
}
70881
function (file) {
    if (file.substr(file.length - 1) === '/') {
        file = file + 'index.html';
    }
    if (fss.exists(file + '.html')) {
        return file + '.html';
    } else if (fss.exists(file.replace(/\.html$/, ''))) {
        return file.replace(/\.html$/, '');
    } else if (fss.filename(file).indexOf('.') === -1 && fss.exists(file + '/index.html')) {
        return file + '/index.html';
    } else {
        return file;
    }
}
710658
function makeAttributesString(node, profile) {
		var attrQuote = profile.attributeQuote();
		var cursor = profile.cursor();
		
		return node.attributeList().map(function(a) {
			var isBoolean = profile.isBoolean(a.name, a.value);
			var attrName = profile.attributeName(a.name);
			var attrValue = isBoolean ? attrName : a.value;
			if (isBoolean && profile.allowCompactBoolean()) {
				return ' ' + attrName;
			}
			return ' ' + attrName + '=' + attrQuote + (attrValue || cursor) + attrQuote;
		}).join('');
	}
523381
function( attributes ) {
		var result = {},
			$element = this;
		$.each(attributes.split(/\s/), function( index, value ) {
			result[value] = $element.attr(value);
			$element.removeAttr(value);
		});
		return result;
	}
893525
def replace_in_file(filename: str, text_from: str, text_to: str) -> None:
    
    log.info("Amending {}: {} -> {}",
             filename, repr(text_from), repr(text_to))
    with open(filename) as infile:
        contents = infile.read()
    contents = contents.replace(text_from, text_to)
    with open(filename, 'w') as outfile:
        outfile.write(contents)
1141456
function insertContentIntoPlaceholder(node, content) {
	const state = {replaced: false};

	node.value = replacePlaceholder(node.value, content, state);
	node.attributes.forEach(attr => {
		if (attr.value) {
			node.setAttribute(attr.name, replacePlaceholder(attr.value, content, state));
		}
	});

	return state.replaced;
}
1262747
function( element )
					{
						var attrs = element.attributes;
						if ( attrs && !attrs.href && attrs.name )
							delete element.name;
						else if ( CKEDITOR.env.webkit && attrs.href && attrs.href.match( /file:\/\/\/[\S]+#/i ) )
							attrs.href = attrs.href.replace( /file:\/\/\/[^#]+/i,'' );
					}
73254
function makeAttributes(attrs) {
		let attributes = '{';
		let attr;

		while ((attr = attrRegExp.exec(attrs))) {
			if (attributes !== '{') attributes += ', ';
			attributes += '"' + attr[1].toLowerCase() + '": ' + handleText(attr[2] || attr[3] || '', true).replace(/\s*[,+]\s*$/g, '');
		}
		return attributes + '}';
	}
597940
function syncContents(file, val) {
  switch (utils.typeOf(val)) {
    case 'buffer':
      file._contents = val;
      file._content = val.toString();
      break;
    case 'string':
      file._contents = new Buffer(val);
      file._content = val;
      break;
    case 'stream':
      file._contents = val;
      file._content = val;
      break;
    case 'undefined':
    case 'null':
    default: {
      file._contents = null;
      file._content = null;
      break;
    }
  }
}
106099
function stripify(file) {
  if (/\.json$/.test(file)) return through();

  var code = '';

  function transform(chunk, encoding, next) {
    code += chunk;
    next();
  }

  function flush(done) {
    /* jshint validthis: true */
    var ast = rocambole.parse(code);

    code = rocambole.moonwalk(ast, function strip(node) {
      if (( // var debug = function() {};
          'VariableDeclaration' === node.type
        && 'debug' === node.declarations[0].id.name
      ) || ( // if (process.env.NODE_ENV !== 'production') { debug = ... }
          'IfStatement' === node.type
        && 'BinaryExpression' === node.test.type
        && 'production' === node.test.right.value
      ) || ( // debug( ... );
          'ExpressionStatement' === node.type
        && 'CallExpression' === node.expression.type
        && 'debug' === node.expression.callee.name
      )) {
        return remove(node);
      }
    });

    this.push(code.toString());
    done();
  }

  return through(transform, flush);
}
397236
function attributesToString(obj, prevObj, level) {
            var attrs = '',
                prefix,
                tab;
            level = level || 1;
            tab = getTabs(level, true);
            _.forEach(obj, function (v, k) {
                if(excludeAttrs.indexOf(k) === -1){
                    var prev = prevObj && prevObj[k] !== undefined ? prevObj[k] : undefined;
                    prefix = attrs.length ? ',\n' : '';
                    if(_.isPlainObject(v)){
                        var subAttr = attributesToString(v, prev, level +1);
                        if(subAttr && subAttr.length)
                            attrs += (prefix + tab + k + ': {\n' + subAttr + '\n' + tab + '}');
                    } else {
                        if(prev !== v){
                            var val = k === 'type' ? 'types.' + v : v;
                            if(_.isArray(val))
                                val = arrayToString(val);
                            if(_.isFunction(val)){
                                val = funcToString(val.toString(), 2);
                            }
                            attrs += (prefix + tab + k + ': ' + val);
                        }
                    }
                }
            });

            return attrs;
        }
420083
function getAttributes(tag) {
        let running = true;
        const attributes = [];
        const regexp = /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/g;

        while (running) {
            const match = regexp.exec(tag);

            if (match) {
                attributes.push({
                    key: match[1],
                    value: match[2]
                })
            } else {
                running = false;
            }
        }

        return attributes;
    }