refactored generic and HTML pretty printing