function insertEquations( node, index, parent ) {
	var mathNode;
	var divNode;
	var label;
	var html;
	var opts;
	var alt;
	var raw;

	if ( EQN_START.test( node.value ) === true ) {
		debug( 'Found an equation...' );

		label = LABEL.exec( node.value );
		if ( label === null ) {
			debug( 'Invalid node: %s', node.value );
			throw new Error( format( 'invalid node. Equation comments must have a valid label. Node: `%s`.', node.value ) );
		}
		label = label[ 1 ];
		debug( 'Label: %s', label );

		alt = ALT.exec( node.value );
		if ( alt === null ) {
			debug( 'Invalid node: %s', node.value );
			throw new Error( format( 'invalid node. Equation comments must have valid alternate text. Node: `%s`.', node.value ) );
		}
		alt = alt[ 1 ];
		debug( 'Alternate text: %s', alt );

		raw = RAW.exec( node.value );
		if ( raw === null ) {
			debug( 'Invalid node: %s', node.value );
			throw new Error( format( 'invalid node. Equation comments must have valid raw equation text. Node: `%s`.', node.value ) );
		}
		raw = raw[ 1 ];
		debug( 'Raw equation: %s', raw );

		opts = {
			'label': label,
			'raw': raw,
			'alt': alt
		};
		html = createElement( opts );
		debug( 'Generated HTML: %s', html );

		mathNode = {
			'type': 'html',
			'value': '```math\n'+substitute(raw)+'\n```'
		};
		divNode = {
			'type': 'html',
			'value': '<!-- '+html+' -->'
		};

		// Case 1: insert new node between equation tags...
		if ( EQN_END.test( parent.children[ index+1 ].value ) ) {
			debug( 'Inserting new node...' );
			parent.children.splice( index+1, 0, mathNode );
			parent.children.splice( index+2, 0, divNode );
		}
		// Case 2: replace existing single node...
		else if (
			EQN_END.test( parent.children[ index+2 ].value )
		) {
			debug( 'Replacing existing div node...' );
			parent.children[ index+1 ] = mathNode;
			parent.children.splice( index+2, 0, divNode );
		}
		// Case 3: replace existing math and div nodes...
		else if (
			EQN_END.test( parent.children[ index+3 ].value )
		) {
			debug( 'Replacing existing math and div nodes...' );
			parent.children[ index+1 ] = mathNode;
			parent.children[ index+2 ] = divNode;
		}
		else {
			debug( 'Invalid node: %s', node.value );
			throw new Error( format( 'invalid node. Invalid equation comment. Ensure that the Markdown file includes both starting and ending equation comments. Node: `%s`.', node.value ) );
		}
	}
}
Inserts an image equation element into a Markdown AST.

@private
@param {Node} node - reference node
@param {number} index - position of `node` in `parent`
@param {Node} parent - parent of `node`
@throws {Error} equation comments must have a valid label
@throws {Error} equation comments must have valid alternate text
@throws {Error} equation comments must have valid raw equation text
@throws {Error} equation comments must have starting and ending comments