Refactor HTML completions

Eliminates 100+ lines of code; should be faster too