Skip to content

Commit

Permalink
Support MATLAB R2024a.
Browse files Browse the repository at this point in the history
  • Loading branch information
rashedmyt authored and Prabhakar Kumar committed Dec 18, 2023
1 parent 5869117 commit 1fa043c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
Binary file added img/tables_after_r2024a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/tables_before_r2024a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ This package has some constraints and limitations:

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

* **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.
* is an empty table
* has more than 1000 rows
* has more than 100 columns
* has nested/grouped headers
* has multi-column variables
* is an event table
* is a dataset

----

Copyright 2023 The MathWorks, Inc.
Expand Down
8 changes: 6 additions & 2 deletions src/jupyter_matlab_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Click on `MATLAB Kernel` to create a Jupyter notebook for MATLAB.

|Jupyter Notebook| JupyterLab |
|--|--|
|<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> |
|<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> |

## Architecture

Expand Down Expand Up @@ -46,7 +46,11 @@ Click on `MATLAB Kernel` to create a Jupyter notebook for MATLAB.
* Inline static plot images
* LaTeX representation for symbolic expressions
* **For MATLAB R2022b and later:** Local functions can be defined at the end of a cell for use in the same cell
![cellLocalFunctions](https://github.com/mathworks/jupyter-matlab-proxy/blob/main/img/local_functions.png)
<p><img src="https://github.com/mathworks/jupyter-matlab-proxy/raw/main/img/local_functions.png"></p>
* **For MATLAB R2024a and later:** Tables are formatted using HTML instead of ASCII
| Before R2024a | After R2024a |
|--|--|
|<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> |

## Limitations
Please refer to this [README](https://github.com/mathworks/jupyter-matlab-proxy#limitations) file for a listing of the current limitations.
Expand Down
19 changes: 18 additions & 1 deletion src/jupyter_matlab_kernel/matlab/+jupyter/execute.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
switch matlab.internal.editor.getApiVersion('synchronous')
case 1
request = updateRequestFromVersion1(request, code);
case 2
request = updateRequestFromVersion2(request, code);
otherwise
error("Invalid API version. Create an issue at https://github.com/mathworks/jupyter-matlab-proxy for further support.");
end
Expand Down Expand Up @@ -95,6 +97,13 @@
request.shouldResetState = false;
request.shouldDoFullCleanup = false;

% Helper function to update fields in the request when LiveEditor API version is 2.
function request = updateRequestFromVersion2(request, code)
request = updateRequestFromVersion1(request, code);

% Request MIME based outputs.
request.preferBasicOutputs = true;

% Helper function to process different types of outputs given by LiveEditor API.
function result = processOutputs(outputs)
result =cell(1,length(outputs));
Expand Down Expand Up @@ -141,6 +150,8 @@
end
result{idx} = processFigure(outputData.figureImage);
end
case 'text/html'
result{ii} = processHtml(outputData);
end
end

Expand Down Expand Up @@ -185,7 +196,7 @@
end
text = sprintf("%s = %s%s%s", output.name, output.header, indentation, output.value);
result = processText(text);

% Helper function for post-processing symbolic outputs. The captured output
% contains MathML representation of symbolic expressions. Since Jupyter and
% GitHub have native support for LaTeX, we use EquationRenderer JS API to
Expand Down Expand Up @@ -252,6 +263,12 @@
result.value = {result.value};
result.type = 'execute_result';

% Helper function for processing text/html mime-type outputs.
function result = processHtml(text)
result.type = 'execute_result';
result.mimetype = {"text/html", "text/plain"};
result.value = [sprintf("%s",text), text];

% Helper function to notify browser page load finished
function pageLoadCallback(~,~,idler)
idler.stopIdling();

0 comments on commit 1fa043c

Please sign in to comment.