format/html.js
/**
 * Check if given inline node should be formatted as well, e.g. it contains
 * enough adjacent siblings that should force formatting
 * @param  {Node} node
 * @param  {Profile} profile
 * @return {Boolean}
 */
Check if given inline node should be formatted as well, e.g. it contains
enough adjacent siblings that should force formatting
@param  {Node} node
@param  {Profile} profile
@return {Boolean}
Check if given inline node should be formatted as well e . g . it contains enough adjacent siblings that should force formatting @param { Node } node @param { Profile } profile @return { Boolean }
function shouldFormatInline(node, profile) {
	if (!isInline(node, profile)) {
		return false;
	}
	if (isPseudoSnippet(node)) {
		return true;
	}
	if (node.childIndex === 0) {
		let next = node;
		while (next = next.nextSibling) {
			if (!isInline(next, profile)) {
				return true;
			}
		}
	} else if (!isInline(node.previousSibling, profile)) {
		return true;
	}
	if (profile.get('inlineBreak')) {
		let adjacentInline = 1;
		let before = node, after = node;
		while (isInlineElement((before = before.previousSibling), profile)) {
			adjacentInline++;
		}
		while (isInlineElement((after = after.nextSibling), profile)) {
			adjacentInline++;
		}
		if (adjacentInline >= profile.get('inlineBreak')) {
			return true;
		}
	}
	for (let i = 0, il = node.children.length; i < il; i++) {
		if (shouldFormatNode(node.children[i], profile)) {
			return true;
		}
	}
	return false;
}
function shouldFormatInline ( node , profile ) { if ( ! isInline ( node , profile ) ) { return false ; } if ( isPseudoSnippet ( node ) ) { return true ; } if ( node . childIndex === 0 ) { let next = node ; while ( next = next . nextSibling ) { if ( ! isInline ( next , profile ) ) { return true ; } } } else if ( ! isInline ( node . previousSibling , profile ) ) { return true ; } if ( profile . get ( 'inlineBreak' ) ) { let adjacentInline = 1 ; let before = node , after = node ; while ( isInlineElement ( ( before = before . previousSibling ) , profile ) ) { adjacentInline ++ ; } while ( isInlineElement ( ( after = after . nextSibling ) , profile ) ) { adjacentInline ++ ; } if ( adjacentInline >= profile . get ( 'inlineBreak' ) ) { return true ; } } for ( let i = 0 , il = node . children . length ; i < il ; i ++ ) { if ( shouldFormatNode ( node . children [ i ] , profile ) ) { return true ; } } return false ; }
Check if given inline node should be formatted as well, e.g.
Check if given inline node should be formatted as well e . g .
// check if inline node is the next sibling of block-level node // first node in parent: format if it’s followed by a block-level element // node is right after block-level element // check for adjacent inline elements before and after current element // Another edge case: inline node contains node that should receive foramtting