Replace deprecated `cgi.escape()` with `html.escape()` after it was removed from Python 3.8.