create pretty formatted HTML from a things dictionary.

def htmlFromThing(thing,title):
    """create pretty formatted HTML from a things dictionary."""
    try:
        thing2 = copy.copy(thing)
    except:
        print("crashed copying the thing! I can't document it.")
        return False
    stuff=analyzeThing(thing2)
    names2=list(stuff.keys())
    for i,name in enumerate(names2):
        if name.startswith("_"):
            names2[i]="zzzzzzzzzz"+name

    html="""<html><head><style>
    body {font-family: courier, monospace;}
    .name {font-weight: bold;}
    .type {font-style: italic; font-family: serif; color: #AAA;}
    .desc {}
    .itemEval {background-color: #DDFFDD;}
    .itemEvalFail {}
    table {font-size: .8em;
           margin-top: 20px;
           border-collapse: collapse;}
    tr {border: 1px solid #CCC; vertical-align: text-top;}
    td {padding: 2px 10px 2px 10px;}
    .credits {text-align: center;
              opacity: 0.5;
              margin-top: 50px;
              font-size: .8em;
              font-family: sans-serif;}
    </style></head><body>"""

    if title:
        html+='<span style="color: #CCC;">title: </span>%s<br>'%title
    textTitle=""
    textType=""
    try:
        textTitle=websafe(str(thing))
        textType=websafe(type(thing).__name__)
    except:
        pass
    html+='<span style="color: #CCC;">value: </span>%s<br>'%textTitle
    html+='<span style="color: #CCC;">&nbsp;type: </span>%s<br>'%textType
    html+='<table cellpadding=3 align="center">'
    html+='<tr style="background-color: #000; color: #FFF; font-weight: bold;">'
    html+='<td>property</td><td>type</td><td>value</td>'
    html+='<td>evaluated (without arguments)</td></tr>'
    for name in sorted(names2):
        if name.startswith("zzzzzzzzzz"):
            name=name[10:]
        itemName=str(name)
        itemType=websafe(stuff[name][0])
        itemStr=websafe(stuff[name][1])
        itemEval=websafe(stuff[name][2])
        color="DDDDFF"
        color2=""
        if "method" in itemType:
            itemName+="()"
            color="FFDDDD"
        if itemName.startswith("_"):
            color="EEEEEE"
        if itemStr.startswith("&lt;") and not ", " in itemStr:
            itemStr="""<span style="color: #CCC; font-family: serif;
                font-style: italic;">%s</span>"""%itemStr
        else:
            color2="DDFFDD"
            if itemEval=="":
                itemEval="FAILED TO EVALUATE"
        html+='<tr>'
        html+='<td class="name" style="background-color: #%s;">%s</td>'%(color,itemName)
        html+='<td class="type">%s</td>'%(itemType)
        html+='<td class="itemStr" style="background-color: #%s;">%s</td>'%(color2,itemStr)
        if itemEval=="FAILED TO EVALUATE":
            html+='<td class="itemEvalFail"></td>'
        else:
            html+='<td class="itemEval">%s</td>'%(itemEval)
        html+='</tr>'

    dt=datetime.datetime.now()
    html+="""</table><p class="credits">
    page automatically generated by
    <a href="https://pypi.python.org/pypi/webinspect/">webinspect</a>
    (version %s) %s</p>
    </body></html>"""%(__version__,dt.strftime("at %I:%M %p on %B %d, %Y"))

    return html