Added protection against undefined text on toHtml(text, settings)