Html generation & refactoring