From c3cc23141194f4c0e56d6802f7e9ff082d21c5fb Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Sun, 4 Feb 2018 11:13:51 +0100 Subject: Display formula using Ajax --- ajax.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'ajax.php') diff --git a/ajax.php b/ajax.php index 156db22..9231012 100644 --- a/ajax.php +++ b/ajax.php @@ -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); -- cgit v1.2.3