'Handles `nodes.footnote_reference` and `nodes.citation_reference`
elements.'

def footnote_reference(self, match, lineno):

    label = match.group('footnotelabel')
    refname = normalize_name(label)
    string = match.string
    before = string[:match.start('whole')]
    remaining = string[match.end('whole'):]
    if match.group('citationlabel'):
        refnode = nodes.citation_reference(('[%s]_' % label), refname=refname)
        refnode += nodes.Text(label)
        self.document.note_citation_ref(refnode)
    else:
        refnode = nodes.footnote_reference(('[%s]_' % label))
        if (refname[0] == '#'):
            refname = refname[1:]
            refnode['auto'] = 1
            self.document.note_autofootnote_ref(refnode)
        elif (refname == '*'):
            refname = ''
            refnode['auto'] = '*'
            self.document.note_symbol_footnote_ref(refnode)
        else:
            refnode += nodes.Text(label)
        if refname:
            refnode['refname'] = refname
            self.document.note_footnote_ref(refnode)
        if utils.get_trim_footnote_ref_space(self.document.settings):
            before = before.rstrip()
    return (before, [refnode], remaining, [])
