Skip to content

Commit 1fa043c

Browse files
rashedmytPrabhakar Kumar
authored and
Prabhakar Kumar
committed
Support MATLAB R2024a.
1 parent 5869117 commit 1fa043c

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

img/tables_after_r2024a.png

74.1 KB
Loading

img/tables_before_r2024a.png

164 KB
Loading

limitations.md

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ This package has some constraints and limitations:
3636

3737
* MATLAB notebooks and MATLAB files do not autoindent after `case` statements.
3838

39+
* **For MATLAB R2024a and later,** tables are displayed as ASCII instead of HTML if the table meets any of the below conditions. Note that the below list is not exhaustive.
40+
* is an empty table
41+
* has more than 1000 rows
42+
* has more than 100 columns
43+
* has nested/grouped headers
44+
* has multi-column variables
45+
* is an event table
46+
* is a dataset
47+
3948
----
4049

4150
Copyright 2023 The MathWorks, Inc.

src/jupyter_matlab_kernel/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Click on `MATLAB Kernel` to create a Jupyter notebook for MATLAB.
1010

1111
|Jupyter Notebook| JupyterLab |
1212
|--|--|
13-
|<p align="center"><img width="200" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/classic-jupyter.png"></p> | <p align="center"><img width="500" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/jupyterlab-notebook-section.png"></p> |
13+
|<p align="center"><img width="200" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/classic-jupyter-kernel.png"></p> | <p align="center"><img width="500" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/jupyterlab_kernel_icon.png"></p> |
1414

1515
## Architecture
1616

@@ -46,7 +46,11 @@ Click on `MATLAB Kernel` to create a Jupyter notebook for MATLAB.
4646
* Inline static plot images
4747
* LaTeX representation for symbolic expressions
4848
* **For MATLAB R2022b and later:** Local functions can be defined at the end of a cell for use in the same cell
49-
![cellLocalFunctions](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/img/local_functions.png)
49+
<p><img src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/local_functions.png"></p>
50+
* **For MATLAB R2024a and later:** Tables are formatted using HTML instead of ASCII
51+
| Before R2024a | After R2024a |
52+
|--|--|
53+
|<p align="center"><img width="550" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/tables_before_r2024a.png"></p> | <p align="center"><img width="500" src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/tables_after_r2024a.png"></p> |
5054

5155
## Limitations
5256
Please refer to this [README](https://github.com/mathworks/jupyter-matlab-proxy#limitations) file for a listing of the current limitations.

src/jupyter_matlab_kernel/matlab/+jupyter/execute.m

+18-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
switch matlab.internal.editor.getApiVersion('synchronous')
6969
case 1
7070
request = updateRequestFromVersion1(request, code);
71+
case 2
72+
request = updateRequestFromVersion2(request, code);
7173
otherwise
7274
error("Invalid API version. Create an issue at https://github.com/mathworks/jupyter-matlab-proxy for further support.");
7375
end
@@ -95,6 +97,13 @@
9597
request.shouldResetState = false;
9698
request.shouldDoFullCleanup = false;
9799

100+
% Helper function to update fields in the request when LiveEditor API version is 2.
101+
function request = updateRequestFromVersion2(request, code)
102+
request = updateRequestFromVersion1(request, code);
103+
104+
% Request MIME based outputs.
105+
request.preferBasicOutputs = true;
106+
98107
% Helper function to process different types of outputs given by LiveEditor API.
99108
function result = processOutputs(outputs)
100109
result =cell(1,length(outputs));
@@ -141,6 +150,8 @@
141150
end
142151
result{idx} = processFigure(outputData.figureImage);
143152
end
153+
case 'text/html'
154+
result{ii} = processHtml(outputData);
144155
end
145156
end
146157

@@ -185,7 +196,7 @@
185196
end
186197
text = sprintf("%s = %s%s%s", output.name, output.header, indentation, output.value);
187198
result = processText(text);
188-
199+
189200
% Helper function for post-processing symbolic outputs. The captured output
190201
% contains MathML representation of symbolic expressions. Since Jupyter and
191202
% GitHub have native support for LaTeX, we use EquationRenderer JS API to
@@ -252,6 +263,12 @@
252263
result.value = {result.value};
253264
result.type = 'execute_result';
254265

266+
% Helper function for processing text/html mime-type outputs.
267+
function result = processHtml(text)
268+
result.type = 'execute_result';
269+
result.mimetype = {"text/html", "text/plain"};
270+
result.value = [sprintf("%s",text), text];
271+
255272
% Helper function to notify browser page load finished
256273
function pageLoadCallback(~,~,idler)
257274
idler.stopIdling();

0 commit comments

Comments
 (0)