def format_word(raw, trs=None, sense=None):
    """Format a word from a template argument, with possibly a transcript
    and a sense attached to it.
    """
    string = "<i>" + raw.value + "</i>"
    if trs is not None:
        string += """, <span class="transcript">%s</span>""" % trs.value
    if sense is not None:
        string += " (&laquo; %s &raquo;)" % sense.value
    return string