Format python data structures in HTML no dependencies
The better way to do this would be to use  html_lib, but short of that, here are a few suggestions.

not_singleton is useless. Just use not singleton.

Use kw.items instead of  zip(kw.keys(), kw.values()).

Don't use SP, use '  '.