Skip to content
Snippets Groups Projects
Commit bd7ea079 authored by Matti Harjula's avatar Matti Harjula
Browse files

Modification on the handling of simplification, resimplify after value...

Modification on the handling of simplification, resimplify after value evaluation just in case some texput logic needs simplification. #844

Not a lot of code and leaves inline CASText behaviour unclear.
parent d77ad0d6
Branches
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@ class stack_cas_castext2_commonstring extends stack_cas_castext2_block {
} else if (strpos($key, 'nosimp_') === 0) {
$r[] = stack_utils::php_string_to_maxima_string(mb_substr($key, 7));
$r[] = 'block([_ct2_tmp,_ct2_simp],_ct2_simp:simp,simp:false,' . $ev .
',simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,"i"),simp:_ct2_simp,_ct2_tmp)';
',simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,"i",false),simp:_ct2_simp,_ct2_tmp)';
} else if (strpos($key, 'raw_') === 0) {
$r[] = stack_utils::php_string_to_maxima_string(mb_substr($key, 4));
// If prefixed by raw output as {#...#} would do.
......@@ -74,7 +74,7 @@ class stack_cas_castext2_commonstring extends stack_cas_castext2_block {
$r[] = stack_utils::php_string_to_maxima_string($key);
$r[] = 'block([_ct2_tmp,_ct2_simp],_ct2_simp:simp,' . $ev .
',simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,"i"),simp:_ct2_simp,_ct2_tmp)';
',simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,"i",_ct2_simp),simp:_ct2_simp,_ct2_tmp)';
}
}
}
......
......@@ -52,16 +52,19 @@ class stack_cas_castext2_latex extends stack_cas_castext2_raw {
$r = 'block([_ct2_tmp,_ct2_simp],_ct2_simp:simp,';
$r .= '_ct2_tmp:' . stack_utils::php_string_to_maxima_string($this->content) . ',';
$simp = ',_ct2_simp';
if ($forcesimp) {
$r .= 'simp:true,';
$simp = ',true';
} else if ($disablesimp) {
$r .= 'simp:false,';
$simp = ',false';
}
$epos = $options['context'] . '/' . $this->position['start'] . '-' . $this->position['end'];
$epos = stack_utils::php_string_to_maxima_string($epos);
$r .= '_EC(errcatch(_ct2_tmp:' . $ev . '),' . $epos . '),';
$r .= 'simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,'. $mode . '),simp:_ct2_simp,_ct2_tmp)';
$r .= 'simp:false,_ct2_tmp:ct2_latex(_ct2_tmp,'. $mode . $simp .'),simp:_ct2_simp,_ct2_tmp)';
return $r;
}
......
......@@ -3363,4 +3363,4 @@ is_lang(code):=ev(is(%_STACK_LANG=code),simp=true)$
/* Stack expects some output with the version number the output happens at */
/* maximalocal.mac after additional library loading */
stackmaximaversion:2022071400$
stackmaximaversion:2022082400$
......@@ -417,7 +417,8 @@ stack_csv_formatter(_data, _labels) := block([_sep,simp,_out,_rowcount,_sepcount
* Basically the mode tells if we are to wrap things in math-delimiters and if we are in
* markdown mode.
*/
ct2_latex(%_val, %_mode):=block([%_tmp],
ct2_latex(%_val, %_mode, %_simp):=block([%_tmp,simp],
simp:false,
%_tmp: %_val,
/* Strings */
if stringp(%_tmp) then (
......@@ -431,6 +432,7 @@ ct2_latex(%_val, %_mode):=block([%_tmp],
return(%_tmp[2]), /* Unwrap it as it does not need that wrapping anymore. Unfortunately can only do this for the single elemetn case here. */
return(%_tmp)
) else (
simp: %_simp,
%_tmp: stack_disp(%_tmp, ""), /* Do our own wrapping. */
%_tmp: sconcat("{", strimr(" ", %_tmp), "}"),
if %_mode = "i" or %_mode = "im" then %_tmp: sconcat("\\(", %_tmp, "\\)")
......
......@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2022071400;
$plugin->version = 2022082400;
$plugin->requires = 2020061500;
$plugin->cron = 0;
$plugin->component = 'qtype_stack';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment