'Look up a formatter function based on its name and the tree.'

def _formatter_for_name(self, name):

    if self._is_xml:
        return self.XML_FORMATTERS.get(name, EntitySubstitution.substitute_xml)
    else:
        return self.HTML_FORMATTERS.get(name, HTMLAwareEntitySubstitution.substitute_xml)
