Combine two HtmlParser2 DOMs
@param  {<Object>} dest Destination HtmlParser2 DOM
@param  {<Object>} src Source HtmlParser2 DOM
@return {Object}
162691
function combine( dest, src ) {
	var destChildren = dest.children;

	function find( collection, name ) {
		return _.where( collection, {
			name: name
		} )[ 0 ];
	}

	/**
	 * Append a tag to the destination or destination's <body> element if found
	 * @param {Object} elem Element to append
	 */
	function appendTag( elem ) {
		var parent;
		// no parent or parent is a root = we're at the top level -> try to add to body
		if ( !elem.parent || elem.parent.type === 'root' ) {
			parent = find( destChildren, 'html' );

			if ( parent ) {
				parent = find( parent.children, 'body' );
			}

			if ( parent ) {
				utils.appendChild( parent, elem );
			} else {
				// append the element to the destination
				utils.append( destChildren[ destChildren.length - 1 ], elem );
			}
			// append the element to the destination
		} else {
			utils.append( destChildren[ destChildren.length - 1 ], elem );
		}
	}

	/**
	 * Merge element with equivalent found in destination
	 * @param {Object}   elem     Source element
	 * @param {Function} callback Callback called when equivalent found
	 */
	function merge( elem, callback ) {
		var old = find( destChildren, elem.name ),
			nl;

		// merge with old element
		if ( old ) {
			if ( typeof callback == 'function' ) {
				return callback( old );
			}

			_.merge( old.attribs, elem.attribs );

			if ( elem.children ) {
				combine( old, elem );
			}
			// append new element
		} else {
			if ( dest.children ) {
				utils.appendChild( dest, elem );
			} else {
				utils.prepend( destChildren[ 0 ], elem );
				// fix for domutils issue
				elem.parent = destChildren[ 0 ].parent;
				destChildren.unshift( elem );
				destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl );
			}
		}
	}

	/**
	 * Merge doctype directives
	 * @param {Object} elem New doctype directive
	 */
	function mergeDoctype( elem ) {
		merge( elem, function( old ) {
			utils.replaceElement( old, elem );
			destChildren[ destChildren.indexOf( old ) ] = elem;
		} );
	}

	/**
	 * Merge <head> and <body> tags that are directly in the source
	 * @param {Object} elem New head/body element
	 */
	function mergeHeadBody( elem ) {
		var old = find( destChildren, elem.name ),
			html;

		if ( old ) {
			merge( elem );
		} else {
			html = find( destChildren, 'html' );
			combine( html.children, elem );
		}
	}

	/**
	 * Merge <title> tags
	 * @param {Object} elem New title tag
	 */
	function mergeTitle( elem ) {
		merge( elem, function( old ) {
			var text = elem.children[ 0 ];

			utils.replaceElement( old.children[ 0 ], text );
			old.children[ 0 ] = text;
		} );
	}

	/**
	 * Merge <meta> tags
	 * @param  {Object} elem New meta tag
	 * @return {Boolean} True if merged
	 */
	function mergeMeta( elem ) {
		var attr = elem.attribs,
			old = _.where( destChildren, {
				name: 'meta'
			} ),
			merged = false;

		[ 'charset', 'name', 'http-equiv' ].forEach( function( meta ) {
			if ( !attr[ meta ] ) {
				return;
			}

			old.forEach( function( el ) {
				var idx;

				if ( ( el.attribs[ meta ] === attr[ meta ] ) ||
					( meta === 'charset' && el.attribs[ meta ] ) ) {
					idx = destChildren.indexOf( el );
					utils.replaceElement( el, elem );
					destChildren[ idx ] = elem;
					merged = true;
				}
			} );
		} );

		return merged;
	}

	// iterate over all source elements
	src.children.forEach( function( elem ) {
		var name = elem.name;

		// ignore plain text and comments ?
		if ( elem.type === 'text' || elem.type === 'comment' ) {
			return appendTag( elem );
		}

		if ( name === '!doctype' ) {
			mergeDoctype( elem );
		} else if ( name === 'html' ) {
			merge( elem );
		} else if ( name === 'head' || name === 'body' ) {
			mergeHeadBody( elem );
		} else if ( name === 'title' ) {
			mergeTitle( elem );
		} else if ( name === 'meta' && mergeMeta( elem ) ) {
			return;
		} else {
			appendTag( elem );
		}
	} );

	return dest;
}
704196
public function addMapping(string $src, string $dest): void
	{
		$this->mapper[$src] = $dest;
	}
706210
function(context, descriptor, args) {
		var path = args[0],
			template = args[1];
		var ctx = new Context(typeof path === 'string' ? context.get(path) : path, context, path);
		template.toHTMLString(ctx, descriptor);
	}
142143
function (target, src) {
    var array = Array.isArray(src);
    var dst = array && [] || {};

    if (array) {
      target = target || [];
      dst = dst.concat(target);
      src.forEach(function(e, i) {
        if (typeof dst[i] === 'undefined') {
          dst[i] = e;
        } else if (typeof e === 'object') {
          dst[i] = Utils.merge(target[i], e);
        } else {
          if (target.indexOf(e) === -1) {
            dst.push(e);
          }
        }
      });
    } else {
      if (target && typeof target === 'object') {
        Object.keys(target).forEach(function (key) {
          dst[key] = target[key];
        })
      }
      Object.keys(src).forEach(function (key) {
        if (typeof src[key] !== 'object' || !src[key]) {
          dst[key] = src[key];
        }
        else {
          if (!target[key]) {
            dst[key] = src[key];
          } else {
            dst[key] = Utils.merge(target[key], src[key]);
          }
        }
      });
    }

    return dst;
  }
295137
function mdAstToHtml(ast, lines) {
    if (lines == undefined)
        lines = [];

    // Adds each element of the array as markdown 
    function addArray(ast) {
        for (let child of ast)
            mdAstToHtml(child, lines);
        return lines;
    }

    // Adds tagged content 
    function addTag(tag, ast, newLine) {
        lines.push(startTag(tag));
        if (ast instanceof Array)
            addArray(ast); 
        else
            mdAstToHtml(ast, lines);
        lines.push(endTag(tag));
        if (newLine)
            lines.push('\r\n');
        return lines;
    }

    function addLink(url, astOrText) {
        lines.push(startTag('a', { href:url }));
        if (astOrText) {
            if (astOrText.children)
                addArray(astOrText.children);
            else
               lines.push(astOrText);
        }        
        
        lines.push(endTag('a')) ;
        return lines;
    }

    function addImg(url) {
        lines.push(startTag('img', { src:url }));
        lines.push(endTag('img')) ;
        return lines;
    }

    switch (ast.name)
    {
        case "heading": 
            {
                let headingLevel = ast.children[0];
                let restOfLine = ast.children[1];
                let h = headingLevel.allText.length;
                switch (h)
                {
                    case 1: return addTag("h1", restOfLine, true); 
                    case 2: return addTag("h2", restOfLine, true); 
                    case 3: return addTag("h3", restOfLine, true); 
                    case 4: return addTag("h4", restOfLine, true); 
                    case 5: return addTag("h5", restOfLine, true); 
                    case 6: return addTag("h6", restOfLine, true); 
                    default: throw "Heading level must be from 1 to 6"
                }
            }
        case "paragraph":   
            return addTag("p", ast.children, true);
        case "unorderedList":
            return addTag("ul", ast.children, true);
        case "orderedList":
            return addTag("ol", ast.children, true);
        case "unorderedListItem":
            return addTag("li", ast.children, true);
        case "orderedListItem":
            return addTag("li", ast.children, true);
        case "inlineUrl":
            return addLink(ast.allText, ast.allText);
        case "bold":
            return addTag("b", ast.children);
        case "italic":
            return addTag("i", ast.children);
        case "code":
            return addTag("code", ast.children);
        case "codeBlock":
            return addTag("pre", ast.children);
        case "quote":
            return addTag("blockquote", ast.children, true);
        case "link":
            return addLink(ast.children[1].allText, ast.children[0]);
        case "image":
            return addImg(ast.children[0]);
        default:
            if (ast.isLeaf)
                lines.push(ast.allText);
            else 
                ast.children.forEach(function(c) { mdAstToHtml(c, lines); });
    }
    return lines;
}
1367370
function(dest, ptr, src, srcptr, len) {
        var i;
        for (i=0;i<len;i++) {
            dest[ptr+i]=src[srcptr+i];
        }
        return true;
    }
629690
public Sftp get(String src, String dest) {
		try {
			channel.get(src, dest);
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		return this;
	}
490830
public void serialize(Node src, net.oneandone.sushi.fs.Node dest, boolean format) throws IOException {
        // don't use Saver to allow transformer to decide about encoding */
        try (OutputStream out = dest.newOutputStream()) {
            serialize(new DOMSource(src), new StreamResult(out), dest.getWorld().getSettings().encoding, format);
        }
    }
409912
function(src, dest, transform) {
        if (typeof src !== 'string' || src.length === 0) {
            throw 'Invalid source file path (arg #1)';
        }
        if (typeof dest !== 'string' || dest.length === 0) {
            throw 'Invalid destination file path (arg #2)';
        }
        if (typeof transform !== 'function') {
            transform = function(data) {
                return data;
            };
        }

        var def = _promise.deferred();
        _fs.readFile(src, function(err, data) {
            if (err) {
                def.reject(err);
            } else {
                var data = transform(data.toString());
                _fs.writeFile(dest, data, function(err, data) {
                    if (err) {
                        def.reject(err);
                    } else {
                        def.resolve();
                    }
                });
            }
        });

        return def.promise();
    }
692223
function merge(dest) {
  if (dest) {
    Array.prototype.slice.call(arguments, 1).forEach(function(arg) {
      Object.keys(arg).forEach(function(key) {
        dest[key] = arg[key]
      })
    })
  }

  return dest
}
1079155
function(src, dest) {
    var contents,
        srcExists = fs.existsSync(src),
        destExists = fs.existsSync(dest),
        stats = srcExists && fs.statSync(src),
        isDirectory = srcExists && stats.isDirectory();

    if (srcExists) {
        if (isDirectory) {
            if (!destExists) {
                fs.mkdirSync(dest);
            }
            fs.readdirSync(src).forEach(function(childItemName) {
                copyRecursiveSync(path.join(src, childItemName),
                    path.join(dest, childItemName));
            });
        } else {
            contents = fs.readFileSync(src);
            fs.writeFileSync(dest, contents);
        }
    }
}
444525
function (dest, src, recursive) {
  for (var prop in src) {
    if (recursive && dest[prop] instanceof Object && src[prop] instanceof Object) {
      dest[prop] = defaults(dest[prop], src[prop], true);
    } else if (! (prop in dest)) {
      dest[prop] = src[prop];
    }
  }

  return dest;
}
983838
function(context, descriptor, originalArgs) {
		var name = originalArgs[0],
			template = originalArgs[1];
		var newDescriptor = new SOD();
		template.toHTMLString(context, newDescriptor);
		tagOutput(descriptor, newDescriptor, name);
	}
115924
function(src, dest) {
    var i = 0;
    var len = Math.min(src.length, dest.length);
    while(i < len) {
      dest[i] = src[i];
      i++;
    }
    return dest;
  }
217754
function(descriptor, options) {
  var options = options  || {};

  // Extract tagName, defaults to 'div'
  var tagName = /^([a-zA-Z0-9]*)/.exec(descriptor);
  options.tag = tagName && tagName[1] ? tagName[1] : 'div';

  // Any occurence of #some_chars
  var id = /#([a-zA-Z0-9_]*)/.exec(descriptor);
  if (id && id[1]) options.id = id[1];

  // Any occurence of .some-chars
  // if (!options.class) {
  //   var re = new RegExp(/\.([a-zA-Z0-9_-]*)/g);
  //   var classes = [];
  //   var classMatch;
  //   while (classMatch = re.exec(descriptor)) {
  //     classes.push(classMatch[1]);
  //   }
  //   options.class = classes.join(' ');
  // }

  // Any occurence of .some-chars
  var matchClasses = new SRegExp(/\.([a-zA-Z0-9_-]*)/g);
  // options.class = options.class ? options.class+' ' : '';
  if (!options.class) {
    options.class = matchClasses.match(descriptor).map(function(m) {
      return m.match[1];
    }).join(' ');
  }

  return new ElementRenderer(options);
}
510756
protected void mergeExistedElement(XmlElement src, XmlElement dest) {

    // 合并属性
    List<Attribute> srcAttributes = src.getAttributes();
    List<Attribute> destAttributes = dest.getAttributes();
    for (Attribute srcAttr : srcAttributes) {
      Attribute matched = null;
      for (Attribute destAttr : destAttributes) {
        if (StringUtils.equals(srcAttr.getName(), destAttr.getName()) &&
            StringUtils.equals(srcAttr.getValue(), destAttr.getValue())) {
          matched = destAttr;
        }
      }
      // 不存在则添加到目标元素的属性列表中
      if (matched == null) {
        destAttributes.add(srcAttributes.indexOf(srcAttr), srcAttr);
      }
    }

    // 重组子节点
    // reformationTheElementChilds(src);
    // reformationTheElementChilds(dest);

    // 暂时不做处理 ---留待后续添加
  }
982932
private void copyAttributes(ElementBase src, LayoutElement dest) {
        for (PropertyInfo propInfo : src.getDefinition().getProperties()) {
            Object value = propInfo.isSerializable() ? propInfo.getPropertyValue(src) : null;
            String val = value == null ? null : propInfo.getPropertyType().getSerializer().serialize(value);
            
            if (!ObjectUtils.equals(value, propInfo.getDefault())) {
                dest.getAttributes().put(propInfo.getId(), val);
            }
        }
    }