Serializes comment.

def serialize_comment(ctx, document, el, root):
    "Serializes comment."

    # Check if option is turned on

    if el.comment_type == 'end':
        ctx.opened_comments.remove(el.cid)
    else:
        if el.comment_type != 'reference':
            ctx.opened_comments.append(el.cid)

        if ctx.options['comment_span']:
            link = etree.SubElement(root, 'a')
            link.set('href', '#')
            link.set('class', 'comment-link')    
            link.set('id', 'comment-id-' + el.cid)    

            link.text = ''

            fire_hooks(ctx, document, el, link, ctx.get_hook('comment'))

    return root