In Mathematica, a package is often stored in .wl file format, which has a very different writing style and execute behavior from those of the notebook (.nb) file format.
IMO, the .nb file is more straightforward to learn, study, and develop. So, I want to know if I can import a .wl file into .nb format to help understand and study it.
Another problem is: Take the following code snippet as an example, as shown in notebook:
{{1, 2}, {3, 4}} // MatrixForm
If I exported it into wl format, I want the beautification related command, e.g., MatrixForm used here, is automatically removed, but I still observed the following exported result via Save As:
Only Initialization cells are saved to the wl file as uncommented code. Add the Initialization Cell property to the cells you want to export as code. From the menu Cell / Cell Properties / Initialization Cell. On a Mac the shortcut is Control 8.
After evaluating it, whenever the notebook is saved a corresponding .m file is created for all Initialization cells. I often put expressions that are used in many different projects into such a notebook and use Get to use the expressions in the .m file in another notebook.
For backwards compatibility AutoGeneratedPackage -> Automatic still uses the old .m extension even though .wl is recommended. Matlab also uses the .m extension which is probably why its use for Wolfram Language files is discouraged.
It’s not exactly an XY Problem. My core idea is how to automatically remove code fragments that beautify and increase readability when saving as a .wl file, thus increasing the compactness and simplicity of the source code.