Refactor gallery to support HTML content