aboutsummaryrefslogtreecommitdiff
path: root/ajax.php
diff options
context:
space:
mode:
authorJean-Michel Vedrine <vedrine@vedrine.org>2018-02-04 11:13:51 +0100
committerJean-Michel Vedrine <vedrine@vedrine.org>2018-02-04 11:13:51 +0100
commitc3cc23141194f4c0e56d6802f7e9ff082d21c5fb (patch)
treedcca1dd671f1b45608cf1570f927be31f2f6efe4 /ajax.php
parent6e5d28ec5e338854112daaeb237c55fa6990e30c (diff)
Display formula using Ajax
Diffstat (limited to 'ajax.php')
-rw-r--r--ajax.php24
1 files changed, 18 insertions, 6 deletions
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);