To fix it, install the PHP Tidy extension:
aptitude install php7.1-tidy
Then ceck it is enabled for both the command line (CLI) and web interfaces:
php -i | grep tidy
Check it in the phpinfo() output:
phpinfo()