tasks/bake.js
function extractSection( content ) {
			var depth = 0;			// tracks how difference between found opening and closing tags
			var start = 0;			// character position in `content` where inner-content starts
			var position = 0;		// current character position within _original_ content
			var length = 0;			// length section (= spacing plus bake-tag) we currently evaluate
			var remain = content;	// content left for further extraction
			var section = {};

			do {

				var result = remain.match( regex );

				if( ! result ) break;

				length = result[ 0 ].length;
				position += result.index;

				if( depth === 0 ) {

					start = position + length;

					section = mout.object.merge( section, parseSignature( result[ 4 ] ), {
						before: content.slice( 0, position ),
						linebreak: result[ 1 ],
						indent: result[ 2 ]
					} );
				}

				remain = remain.slice( result.index + length );

				depth += ( result[ 3 ] === "-start" );
				depth -= ( result[ 3 ] === "-end" );

				if( depth === 0 ) {
					return mout.object.merge( section, {
						inner: content.slice( start, position ),
						after: content.slice( position + length )
					} );
				}

				position += length;

			} while( true );

			return null;
		}
function extractSection( content ) {
			var depth = 0;			// tracks how difference between found opening and closing tags
			var start = 0;			// character position in `content` where inner-content starts
			var position = 0;		// current character position within _original_ content
			var length = 0;			// length section (= spacing plus bake-tag) we currently evaluate
			var remain = content;	// content left for further extraction
			var section = {};

			do {

				var result = remain.match( regex );

				if( ! result ) break;

				length = result[ 0 ].length;
				position += result.index;

				if( depth === 0 ) {

					start = position + length;

					section = mout.object.merge( section, parseSignature( result[ 4 ] ), {
						before: content.slice( 0, position ),
						linebreak: result[ 1 ],
						indent: result[ 2 ]
					} );
				}

				remain = remain.slice( result.index + length );

				depth += ( result[ 3 ] === "-start" );
				depth -= ( result[ 3 ] === "-end" );

				if( depth === 0 ) {
					return mout.object.merge( section, {
						inner: content.slice( start, position ),
						after: content.slice( position + length )
					} );
				}

				position += length;

			} while( true );

			return null;
		}
extract bake sections. For inline-bake it searches for matching closing tags and returns inline content and other information