// Convert a Cadabra .cnb notebook to a Jupyter notebook. input file to pure Python .py, by doing the // pre-processing stage. #include #include #include #include "nlohmann/json.hpp" #include "DataCell.hh" int main(int argc, char **argv) { if(argc<2) { std::cerr << "Usage: cadabra2ipynb [cadabra notebook] [jupyter notebook]\n\n"; std::cerr << "Convert a Cadabra notebook to a Jupyter notebook.\n" << "If the Jupyter notebook name is not given, output goes to standard out.\n"; return -1; } std::string cdb_file, python_file; int n=1; while(n> content; auto python = cadabra::cnb2ipynb(content); if(python_file!="") { std::ofstream pythonfile(python_file); pythonfile << python.dump(3); } else { std::cout << python.dump(3); } return 0; }