source/index.js
function parse_children(lines, parent_node_names)
{
	// preprocess the lines (filter out comments, blank lines, etc)
	lines = filter_lines_for_parsing(lines)

	// return empty object if there are no lines to parse
	if (lines.length === 0)
	{
		return {}
	}

	// parse each child node's lines
	return split_lines_by_child_nodes(lines).map(function(lines)
	{
		// the first line is this child node's name (or names)
		const declaration_line = lines.shift()

		// check for excessive indentation of the first child style class
		if (declaration_line.tabs !== 0)
		{
			throw new Error(`Excessive indentation (${declaration_line.tabs} more "tabs" than needed) at line ${declaration_line.index}: "${declaration_line.original_line}"`)
		}

		// style class name declaration
		const declaration = declaration_line.line

		// child nodes' names
		const names = declaration.split(',').map(name => name.trim())

		// style class nesting validation
		validate_child_style_class_types(parent_node_names, names)

		// parse own CSS styles and recursively parse all child nodes
		const style_json = parse_style_class(lines, names)

		// generate style json for this child node (or child nodes)
		return names.map(function(node_declaration)
		{
			// parse this child node name
			const { name, is_a_modifier } = parse_node_name(node_declaration)

			// clone the style JSON object for this child node
			const json = extend({}, style_json)

			// set the modifier flag if it's the case
			if (is_a_modifier)
			{
				json._is_a_modifier = true
			}

			// this child node's style JSON object
			return { name, json }
		})
	})
	// convert an array of arrays to a flat array
	.reduce(function(array, child_array)
	{
		return array.concat(child_array);
	}, 
	[])
	// combine all the child nodes into a single JSON object
	.reduce(function(nodes, node)
	{
		// if style already exists for this child node, extend it
		if (nodes[node.name])
		{
			extend(nodes[node.name], node.json)
		}
		else
		{
			nodes[node.name] = node.json
		}
		
		return nodes
	}, 
	{})
}
function parse_children(lines, parent_node_names)
{
	// preprocess the lines (filter out comments, blank lines, etc)
	lines = filter_lines_for_parsing(lines)

	// return empty object if there are no lines to parse
	if (lines.length === 0)
	{
		return {}
	}

	// parse each child node's lines
	return split_lines_by_child_nodes(lines).map(function(lines)
	{
		// the first line is this child node's name (or names)
		const declaration_line = lines.shift()

		// check for excessive indentation of the first child style class
		if (declaration_line.tabs !== 0)
		{
			throw new Error(`Excessive indentation (${declaration_line.tabs} more "tabs" than needed) at line ${declaration_line.index}: "${declaration_line.original_line}"`)
		}

		// style class name declaration
		const declaration = declaration_line.line

		// child nodes' names
		const names = declaration.split(',').map(name => name.trim())

		// style class nesting validation
		validate_child_style_class_types(parent_node_names, names)

		// parse own CSS styles and recursively parse all child nodes
		const style_json = parse_style_class(lines, names)

		// generate style json for this child node (or child nodes)
		return names.map(function(node_declaration)
		{
			// parse this child node name
			const { name, is_a_modifier } = parse_node_name(node_declaration)

			// clone the style JSON object for this child node
			const json = extend({}, style_json)

			// set the modifier flag if it's the case
			if (is_a_modifier)
			{
				json._is_a_modifier = true
			}

			// this child node's style JSON object
			return { name, json }
		})
	})
	// convert an array of arrays to a flat array
	.reduce(function(array, child_array)
	{
		return array.concat(child_array);
	}, 
	[])
	// combine all the child nodes into a single JSON object
	.reduce(function(nodes, node)
	{
		// if style already exists for this child node, extend it
		if (nodes[node.name])
		{
			extend(nodes[node.name], node.json)
		}
		else
		{
			nodes[node.name] = node.json
		}
		
		return nodes
	}, 
	{})
}
function parse_children ( lines , parent_node_names ) { // preprocess the lines (filter out comments, blank lines, etc) lines = filter_lines_for_parsing ( lines ) // return empty object if there are no lines to parse if ( lines . length === 0 ) { return { } } // parse each child node's lines return split_lines_by_child_nodes ( lines ) . map ( function ( lines ) { // the first line is this child node's name (or names) const declaration_line = lines . shift ( ) // check for excessive indentation of the first child style class if ( declaration_line . tabs !== 0 ) { throw new Error ( ` ${ declaration_line . tabs } ${ declaration_line . index } ${ declaration_line . original_line } ` ) } // style class name declaration const declaration = declaration_line . line // child nodes' names const names = declaration . split ( ',' ) . map ( name => name . trim ( ) ) // style class nesting validation validate_child_style_class_types ( parent_node_names , names ) // parse own CSS styles and recursively parse all child nodes const style_json = parse_style_class ( lines , names ) // generate style json for this child node (or child nodes) return names . map ( function ( node_declaration ) { // parse this child node name const { name , is_a_modifier } = parse_node_name ( node_declaration ) // clone the style JSON object for this child node const json = extend ( { } , style_json ) // set the modifier flag if it's the case if ( is_a_modifier ) { json . _is_a_modifier = true } // this child node's style JSON object return { name , json } } ) } ) // convert an array of arrays to a flat array . reduce ( function ( array , child_array ) { return array . concat ( child_array ) ; } , [ ] ) // combine all the child nodes into a single JSON object . reduce ( function ( nodes , node ) { // if style already exists for this child node, extend it if ( nodes [ node . name ] ) { extend ( nodes [ node . name ] , node . json ) } else { nodes [ node . name ] = node . json } return nodes } , { } ) }
parses child nodes' lines of text into the corresponding child node JSON objects
parses child nodes lines of text into the corresponding child node JSON objects