'Render an html preview of a chemical formula or equation.  get should
contain a key \'formula\' and value \'some formula string\'.
Returns a json dictionary:
\'preview\' : \'the-preview-html\' or \'\'
\'error\' : \'the-error\' or \'\''

def preview_chemcalc(self, data):

    _ = self.capa_system.i18n.ugettext
    result = {'preview': '', 'error': ''}
    try:
        formula = data['formula']
    except KeyError:
        result['error'] = _('No    formula    specified.')
        return result
    try:
        result['preview'] = chemcalc.render_to_html(formula)
    except pyparsing.ParseException as err:
        result['error'] = _("Couldn't    parse    formula:    {error_msg}").format(error_msg=err.msg)
    except Exception:
        log.warning('Error    while    previewing    chemical    formula', exc_info=True)
        result['error'] = _('Error    while    rendering    preview')
    return result
