Fixed TypeError raised by `richtext` template tag