Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Save a notebook to a file that is formatted to maximize readability when viewing changes in version control systems
ResourceFunction["SaveReadableNotebook"][notebook,"file"] saves notebook to "file" as a Notebook expression formatted for readability. |
Notebook[…] | a notebook expression |
NotebookObject[…] | a currently open notebook |
"path" | a pathname of a saved notebook |
"ExcludedCellOptions" | {CellChangeTimes,ExpressionUUID} | cell options that should be discarded from the saved notebook |
"ExcludedNotebookOptions" | {WindowSize,WindowMargins} | notebook options that should be discarded |
Save a NotebookObject to a human-readable file:
In[1]:= |
Out[1]= |
In[2]:= |
Out[2]= |
In[3]:= |
Save a Notebook expression:
In[4]:= |
Out[4]= |
In[5]:= |
Save a copy of a notebook file that already exists:
In[6]:= |
Out[6]= |
In[7]:= |
By default, some cell options are automatically stripped:
In[8]:= |
Preserve all cell options:
In[9]:= |
Ignore specific options:
In[10]:= |
By default, some notebook options are automatically stripped:
In[11]:= |
Preserve all notebook options:
In[12]:= |
Ignore specific options:
In[13]:= |
SaveReadableNotebook can be used to create notebook files that are well suited for version control systems that look at changes to files on a line-by-line basis.
Here’s a test notebook:
In[14]:= |
Now make changes to the notebook, then save to a new file:
In[15]:= |
It can be difficult to visualize what actually changed:
In[16]:= |
In[17]:= |
Out[17]= |
Create a formatted version of each notebook and view changes for those files instead:
In[18]:= |
Out[20]= |
The formatted notebook files still open normally:
In[21]:= |
Out[21]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License