lib/html2wt/separators.js
function mergeConstraints(env, oldConstraints, newConstraints) {
	const res = {
		min: Math.max(oldConstraints.min || 0, newConstraints.min || 0),
		max: Math.min(
			oldConstraints.max !== undefined ? oldConstraints.max : 2,
			newConstraints.max !== undefined ? newConstraints.max : 2
		),
		force: oldConstraints.force || newConstraints.force,
	};

	if (res.min > res.max) {
		// If oldConstraints.force is set, older constraints win
		if (!oldConstraints.force) {
			// let newConstraints win, but complain
			if (newConstraints.max !== undefined && newConstraints.max > res.min) {
				res.max = newConstraints.max;
			} else if (newConstraints.min && newConstraints.min < res.min) {
				res.min = newConstraints.min;
			}
		}
		res.max = res.min;
		env.log("info/html2wt", 'Incompatible constraints (merge):', res,
			loggableConstraints(oldConstraints), loggableConstraints(newConstraints));
	}

	return res;
}
function mergeConstraints(env, oldConstraints, newConstraints) {
	const res = {
		min: Math.max(oldConstraints.min || 0, newConstraints.min || 0),
		max: Math.min(
			oldConstraints.max !== undefined ? oldConstraints.max : 2,
			newConstraints.max !== undefined ? newConstraints.max : 2
		),
		force: oldConstraints.force || newConstraints.force,
	};

	if (res.min > res.max) {
		// If oldConstraints.force is set, older constraints win
		if (!oldConstraints.force) {
			// let newConstraints win, but complain
			if (newConstraints.max !== undefined && newConstraints.max > res.min) {
				res.max = newConstraints.max;
			} else if (newConstraints.min && newConstraints.min < res.min) {
				res.min = newConstraints.min;
			}
		}
		res.max = res.min;
		env.log("info/html2wt", 'Incompatible constraints (merge):', res,
			loggableConstraints(oldConstraints), loggableConstraints(newConstraints));
	}

	return res;
}
function mergeConstraints ( env , oldConstraints , newConstraints ) { const res = { min : Math . max ( oldConstraints . min || 0 , newConstraints . min || 0 ) , max : Math . min ( oldConstraints . max !== undefined ? oldConstraints . max : 2 , newConstraints . max !== undefined ? newConstraints . max : 2 ) , force : oldConstraints . force || newConstraints . force , } ; if ( res . min > res . max ) { // If oldConstraints.force is set, older constraints win if ( ! oldConstraints . force ) { // let newConstraints win, but complain if ( newConstraints . max !== undefined && newConstraints . max > res . min ) { res . max = newConstraints . max ; } else if ( newConstraints . min && newConstraints . min < res . min ) { res . min = newConstraints . min ; } } res . max = res . min ; env . log ( "info/html2wt" , 'Incompatible constraints (merge):' , res , loggableConstraints ( oldConstraints ) , loggableConstraints ( newConstraints ) ) ; } return res ; }
Merge two constraints.

@private
Merge two constraints .