def convert_lines_to_block(lines, block_map, link_stack, source_path, block_name=ALL_BLOCK_NAME):
found_closing_block = False<EOL>segments = []<EOL>while lines:<EOL><INDENT>line = lines.pop(<NUM_LIT:0>)<EOL>close_tag_match = BLOCK_CLOSE_REGEX.match(line)<EOL>if close_tag_match:<EOL><INDENT>if close_tag_match.group(<NUM_LIT:1>) != block_name:<EOL><INDENT>raise InvalidBlockName('<STR_LIT>' + block_name +'<STR_LIT>' + block_tag_match.group(<NUM_LIT:1>) + '<STR_LIT>' + source_path)<EOL><DEDENT>found_closing_block = True<EOL>break<EOL><DEDENT>open_tag_match = BLOCK_OPEN_REGEX.match(line)<EOL>if open_tag_match:<EOL><INDENT>inner_block_name = open_tag_match.group(<NUM_LIT:1>)<EOL>if inner_block_name == ALL_BLOCK_NAME:<EOL><INDENT>raise InvalidBlockName(<EOL>'<STR_LIT>'.format(<EOL>ALL_BLOCK_NAME, source_path))<EOL><DEDENT>inner_block = convert_lines_to_block(<EOL>lines,<EOL>block_map,<EOL>link_stack,<EOL>source_path,<EOL>inner_block_name)<EOL>segments.append(inner_block)<EOL>continue<EOL><DEDENT>variable_match = VARIABLE_REGEX.match(line)<EOL>if variable_match:<EOL><INDENT>process_variable(variable_match, block_map)<EOL>continue<EOL><DEDENT>include_match = INCLUDE_REGEX.match(line)<EOL>if include_match:<EOL><INDENT>included_content = process_links(include_match, block_map, link_stack, source_path)<EOL>if included_content != '<STR_LIT>':<EOL><INDENT>append_text_to_segments(segments, included_content)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>append_text_to_segments(segments, line)<EOL><DEDENT><DEDENT>if block_name != ALL_BLOCK_NAME and not found_closing_block:<EOL><INDENT>raise InvalidBlockName(<EOL>'<STR_LIT>'.format(block_name, source_path))<EOL><DEDENT>block = Block(source_path, block_name, segments)<EOL>block_map.add_block(block)<EOL>return block<EOL>
Converts the specified block content lines (list of strings) into a Block object.

    Nested blocks are recursively converted into strings and cached in the block_map. Include tags
    are processed as well. The resulting block string is also added to the block_map, along with any
    nested blocks.

    PARAMETERS:
    lines       -- str; content lines to be converted into a Block.
    block_map   -- BlockMap
    link_stack  -- LinkStack
    source_path -- str; the path of the file from which this content came, relative to the current
                   working directory.
    block_name  -- str; the name of the block that contains this content. By default, the name is
                  'all'

    RETURNS:
    Block; the result of converting the block content.