Notebook Document Processing
Since Version 3, notebooks have been saved as symbolic expressions that can easily be loaded and processed into the Wolfram Language, but doing so requires a significant understanding of the notebook's symbolic representation. NotebookImport clears that hurdle by making it simple to pull text, graphics, and code from notebooks.
Import all "Notes"-styled cells found in the documentation for Cos, convert them to plain text strings, and return them in a nicely formatted table.
show complete Wolfram Language input
In[2]:=
![Click for copyable input](assets.en/notebook-document-processing/In_2.png)
makeGrid[Text /@ NotebookImport[docNotebook, "Notes" -> "Text"]]
Out[2]=
![](assets.en/notebook-document-processing/O_15.png)
Samples of all extracted inputs.
In[3]:=
![Click for copyable input](assets.en/notebook-document-processing/In_3.png)
makeGrid[Take[NotebookImport[docNotebook, "Input"], 9]]
Out[3]=
![](assets.en/notebook-document-processing/O_16.png)
Show the inputs in "InactiveExpression" form.
In[4]:=
![Click for copyable input](assets.en/notebook-document-processing/In_4.png)
makeGrid[Take[
NotebookImport[docNotebook, "Input" -> "InactiveExpression"], 9]]
Out[4]=
![](assets.en/notebook-document-processing/O_17.png)
Samples of all the graphical outputs.
In[5]:=
![Click for copyable input](assets.en/notebook-document-processing/In_5.png)
Take[Cases[
NotebookImport[docNotebook,
"Output"], _Graphics | _Image | _Graphics3D], 4]
Out[5]=
![](assets.en/notebook-document-processing/O_18.png)
Samples of all extracted example texts.
In[6]:=
![Click for copyable input](assets.en/notebook-document-processing/In_6.png)
makeGrid[Take[NotebookImport[docNotebook, "ExampleText" -> "Text"],
9]]
Out[6]=
![](assets.en/notebook-document-processing/O_19.png)