Exemple #1
0
def parse_tabbed_list(last_count, current_count, last_type, last_line, line, next_line):
    # Determine the type of the current list
    this_type = ""
    if line[0].isdigit():
        this_type = "ol"
    else:
        this_type = "ul"
        
    if last_count != current_count:
        print("Last line and current line are different lists")
        return_string = "<" + this_type + ">\n" + constructHTML.construct_list_item(line)
        if current_count != count_whitespace("\t", next_line):
            # This line and the next line don't have the same indentation
            return_string += "</" + this_type + ">\n"
        elif line[0].isdigit():
            if next_line[count_whitespace("\t", next_line)].isdigit() == False:
                return_string += "</" + this_type + ">\n"
        return this_type, return_string
    else:
        # The current list item and the last line/list item have the same
        # identation.
        if last_type != this_type:
            print("COMPILE ERROR: You cannot have two different types", end='')
            print("               in the same list.", end='')
            print("AT LINE:", line)
            exit("")
        else:
            print("Last line and current line are same lists")
            return this_type, constructHTML.construct_list_item(line)
Exemple #2
0
def parse_list(last_type, list_type, line, next_line):
    # Check to see if list and last type are the same
    return_string = ""
    if last_type != list_type:
        if list_type == "ol":
            return_string = "<ol>\n" + constructHTML.construct_list_item(line)
            return "ol", return_string
        elif list_type == "ul":
            return_string = "<ul>\n" + constructHTML.construct_list_item(line)
            return "ul", return_string
    else:
        if next_line == "EOF":
            if list_type == "ol":
                return_string = constructHTML.construct_list_item(line) + "</ol>\n"
                return "ol", return_string
            else:
                return_string = constructHTML.construct_list_item(line) + "</ul>\n"
                return "ul", return_string
        elif list_type == "ul":
            if next_line[0] == "*":
                # next thing is still an unordered list so we don't care
                # about closing this off
                return_string = constructHTML.construct_list_item(line)
                return "ul", return_string
            else:
                # next thing ISN'T an unordered list so we need to close 
                return_string = constructHTML.construct_list_item(line) + "</ul>\n"
                return "ul", return_string
        elif list_type == "ol":
            if next_line[0].isdigit():
                # next thing is still an ordered list so we don't care about
                # closing this off
                return_string = constructHTML.construct_list_item(line)
                return "ol", return_string
            else:
                # next thing ISN'T an ordered list so we need to close
                return_string = constructHTML.construct_list_item(line) + "</ol>\n"
                return "ol", return_string