Commit 0a2c03ff authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Bug 262 - Handling of newline character and end of text block

parent efd233d6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -29,11 +29,18 @@ def is_body_of_example(line: str):
    Returns true if the line is part of the body of an example.
    '''
    return line == "" or \
            line.startswith("\n") or \
            line.startswith(".") or \
            line.startswith("#") or \
            line.startswith(" ") or \
            bool(re.match(r'^[a-zA-Z_]*:',line))
            
def is_last_line(line: str, txt):
    '''
    Returns true if it is the last line of the text.
    '''
    return line == txt[len(txt)-1]

def get_example_file_name(line: str):
    '''
    Looks for the YAML filename in the line of text
@@ -88,6 +95,8 @@ def parse_all_examples(txt):
            new_example = "# " + filename + "\n" + linetext
        elif new_example != "" and is_body_of_example(linetext):
            new_example = new_example + "\n" + linetext
            if is_last_line(line, txt):
                res.append(Example(filename, new_example))
        elif len(new_example) > 0:
            res.append(Example(filename, new_example))
            new_example = ""