Implement exercise detection

This is in support of #529. For the moment it only integrates the
language detection that it was already doing.