def table_function(nl):
    with tag('table'):
        with tag('tr'):
            with tag('th'): 
                #text(string_collection.get(nl[1]))              
                doc.asis(string_collection.get(nl[1]))
                for row_index in range(2, len(nl)):
                    with tag('tr'):
                        row = array_collection[nl[row_index]]
                        for item in row:
                            with tag('td'):
                                #text(item)
                                doc.asis(item)
def list_function(nl):
    list_items = array_collection.get(nl[2])  
    print(list_items)
    
    if (nl[1] == "ordered"):
        with tag('ol'): 
            for i in range(0, len(list_items)): 
                with tag('li'):     
                    #text(list_items[i])
                    doc.asis(list_items[i])
               
    elif (nl[1] == "unordered"): 
        with tag('ul'):
            for i in range(0, len(list_items)): 
                with tag('li'):
                    #text(list_items[i])
                    doc.asis(list_items[i])
            
    else : print("WHAT KIND OF LIST ARE YOU TRYING TO DO?!")
def main():
    doc.asis('<!DOCTYPE html>')
    with tag('html'): 
        doc.asis('<style>')
        text('table, th, td {border: 1px solid black;}')   
        doc.asis('</style>')   
        with tag ('body'):
            load_tokens('source.txt')
            section_id = []

            for i in range(0, len(token_stack)):
                token = token_stack[i]
                if token[0] == 'iziSection':
                    section = [ ]
                    id = token[1]
                    print(id)
                
                    for j in range(i+1, (len(token_stack))):
                        temp_token = token_stack[j]
                        if(temp_token[0] != 'iziSection'):
                            section.append(temp_token)
                        else:
                            break
                    
                    section_stack.append(section)
                    section_id.append(id)
                    print(section_id)

            counter = 0
            for j in range(0, len(section_stack)):
                section_class = token_stack[j]
            
                if (section_id[counter] not in string_collection) : print("stop bullshitting!")
                else :
                    print(string_collection.get(section_id[counter]))
                    with tag ('section', klass = string_collection.get(section_id[counter])):
                        text('\n')
                        for element in section_stack[j]:
                    
                            instruction_checker(element)                         
                    counter = counter + 1
            
    result = indent(doc.getvalue(), indentation = '', newline = '\r\n')
    
    outpath = "index.html"

    with open (outpath, "wt") as outfile:
        outfile.write(result)
        outfile.close()   
def paragraph_function(nl):  
    with tag('p'):
        #text(string_collection.get(nl[1]))
        doc.asis(string_collection.get(nl[1]))