diff options
author | Jean-Michel Vedrine <vedrine@vedrine.org> | 2018-02-04 11:13:51 +0100 |
---|---|---|
committer | Jean-Michel Vedrine <vedrine@vedrine.org> | 2018-02-04 11:13:51 +0100 |
commit | c3cc23141194f4c0e56d6802f7e9ff082d21c5fb (patch) | |
tree | dcca1dd671f1b45608cf1570f927be31f2f6efe4 /ajax.php | |
parent | 6e5d28ec5e338854112daaeb237c55fa6990e30c (diff) |
Display formula using Ajax
Diffstat (limited to 'ajax.php')
-rw-r--r-- | ajax.php | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -38,18 +38,30 @@ if (!confirm_sesskey()) { try { $vars = explode(',', $vars); if (empty($expr)) { - $texexp = ''; + $texexp = ' '; } else { $exp = $p->parse($expr, $vars); $texexp = $exp->tex(); } } catch (Exception $e) { - $texexp = ''; + $texexp = ' '; } -if ($CFG->qtype_algebra_texdelimiters == 'old') { - $texexp = '$$' . $texexp . '$$'; -} else { - $texexp = '\\[' . $texexp . '\\]'; + +$delimiters = $CFG->qtype_algebra_texdelimiters; +switch($delimiters) { + case 'old': + $texexp = '$$' . $texexp . '$$'; + break; + case 'new': + $texexp = '\\[' . $texexp . '\\]'; + break; + case 'simple'; + $texexp = '$' . $texexp . '$'; + break; + case 'inline': + $texexp = '\\(' . $texexp . '\\)'; + break; } + header('Content-Type: application/json; charset: utf-8'); echo json_encode($texexp); |