def write_frame_to_html_file(mov, appState, frame, file_path, gzipped=False):
    """ Writes a single frame to an HTML file
    """
    colorMode = appState.colorMode
    if gzipped:
        opener = gzip.open
    else:
        opener = open
    with opener(file_path, 'wt') as f:
        movieDataHeader = '<!DOCTYPE html>\n'
        movieDataHeader += '<html lang="en">\n'
        movieDataHeader += ''
        movieDataHeader += '    <head>\n'
        movieDataHeader += '        <meta charset="utf-8">\n'
        movieDataHeader += '        <meta name="viewport" content="width=device-width, initial-scale=1">\n'
        movieDataHeader += '        <title>DurDraw Generated Output</title>\n'
        movieDataHeader += '        <style>\n'
        movieDataHeader += '            body {\n'
        movieDataHeader += '                color: #FFFFFF;\n'
        movieDataHeader += '                background-color: #000000;\n'
        movieDataHeader += '            }\n'
        movieDataHeader += '            #duroutput {\n'
        movieDataHeader += '                font-size:12pt;\n'
        movieDataHeader += '                font-family: "Courier New", monospace;\n'
        # movieDataHeader += '              font-family: monospace,monospace;\n'
        movieDataHeader += '                line-height:13pt;\n'
        movieDataHeader += '                color: #FFFFFF;\n'
        movieDataHeader += '            }\n'
        movieDataHeader += '        </style>\n'
        movieDataHeader += '    </head>\n'
        movieDataHeader += '    <body>\n'
        movieDataHeader += '        <pre id="duroutput">\n'

        fileContent = movieDataHeader
        #lineNum = 0
        #colNum = 0
        newColorMap = []
        for posY in range(0, mov.sizeY):
            #newColorMap.append(list())
            for posX in range(0, mov.sizeX):
                #newColorMap[posX].append(list(frame.colorMap[posY, posX]))
                #newColorMap[posX].append(frame.newColorMap[posY][posX])
                durDolor = frame.newColorMap[posY][posX]
                fgColor = frame.newColorMap[posY][posX][0]
                bgColor = frame.newColorMap[posY][posX][1]
                c = frame.content[posY][posX]
        #for line in frame.content:
        #    for c in line: 
                try:
                    #fgColor = frame.newColorMap[colNum][lineNum][0]
                    #bgColor = frame.newColorMap[colNum][lineNum][1]
                    if appState.colorMode == "16":
                        bgColor += 1
                        if bgColor == 9:    # black duplicate
                            bgColor = 0
                    if appState.colorMode == "256":
                        fgColor += 1
                        bgColor += 1
                    if fgColor in colors_to_html.keys():
                        fgHtmlColor = colors_to_html[fgColor]
                    else:
                        fgHtmlColor = '#AAAAAA'
                    if bgColor in colors_to_html.keys():
                        bgHtmlColor = colors_to_html[bgColor]
                    else:
                        bgHtmlColor = '#000000'
                    #fileContent += f"<div style=\"color: {fgHtmlColor}; background-color: {bgHtmlColor}; display: inline;\">"
                    fileContent += f"<span style=\"color: {fgHtmlColor}; background-color: {bgHtmlColor};\">"
                    #fileContent += f"<font color={fgHtmlColor} style=\"background-color: {bgHtmlColor};\">"
                    #fileContent += f"<font color={fgHtmlColor} background-color={bgHtmlColor}>"
                    fileContent += str(c)
                    fileContent += "</span>"
                    #fileContent += "</div>"
                    #colNum += 1
                except Exception as e:
                    print(str(e))
                    pdb.set_trace()
            fileContent += '\n'
            #lineNum += 1
        
        fileContent += '        </pre>\n'
        fileContent += '    </body>\n'
        fileContent += '</html>\n'
        f.write(fileContent)
    f.close()
 Writes a single frame to an HTML file
    
durdraw/durdraw_file.py