|
110 | 110 | case 'variable'
|
111 | 111 | result{ii} = processVariable(outputData);
|
112 | 112 | case 'variableString'
|
113 |
| - result{ii} = processVariable(outputData); |
| 113 | + result{ii} = processVariableString(outputData); |
114 | 114 | case 'symbolic'
|
115 | 115 | result{ii} = processSymbolic(outputData);
|
116 | 116 | case 'error'
|
|
165 | 165 | result = processText(text);
|
166 | 166 |
|
167 | 167 | function result = processVariable(output)
|
168 |
| -text = sprintf("%s = %s\n %s", output.name, output.header, strtrim(output.value)); |
| 168 | +if isempty(output.header) |
| 169 | + indentation = ''; |
| 170 | +else |
| 171 | + indentation = sprintf('\n '); |
| 172 | +end |
| 173 | +text = sprintf("%s = %s%s%s", output.name, output.header, indentation, output.value); |
169 | 174 | result = processText(text);
|
170 | 175 |
|
| 176 | +function result = processVariableString(output) |
| 177 | +indentation = ''; |
| 178 | +useSingleLineDisplay = ~contains(output.value, sprintf(newline)); |
| 179 | +if useSingleLineDisplay |
| 180 | + if ~isempty(output.header) |
| 181 | + indentation = sprintf(newline); |
| 182 | + end |
| 183 | +else |
| 184 | + indentation = sprintf(newline); |
| 185 | +end |
| 186 | +text = sprintf("%s = %s%s%s", output.name, output.header, indentation, output.value); |
| 187 | +result = processText(text); |
| 188 | + |
171 | 189 | % Helper function for post-processing symbolic outputs. The captured output
|
172 | 190 | % contains MathML representation of symbolic expressions. Since Jupyter and
|
173 | 191 | % GitHub have native support for LaTeX, we use EquationRenderer JS API to
|
|
0 commit comments