Saving a Notebook to Markdown (with full view of graphics)
I have been experimenting with options to save a notebook to markdown. The utility comes in being able to share the notes on an experiment for review in markdown-apps, especially Obsidian. I have implemented the process fully into the Log Book package. In the meantime, for those so inclined, here is a short instruction list to create a markdown notebook that recognizes the graphics in a notebook.
--> Every time you store a graphic, add a markdown link in the format below.
![Graphic Name](<... path to storage location ... NotebookName$Media/PictureN.png>)
In this format, you must provide the path to the storage location (the folder where you will store the notebook file), the NotebookName, and an identifier PictureN, where N is the sequence number for the picture in the notebook (starting from zero). Here is how I handle this in the Log Book package.
Static Function put_URLinNtbk(variable theID, string thegraphic, string theNtbk)
string mdURL
sprintf mdURL "\r![local file: %s.png](<./%sMedia/Picture%d.png>)\r", theGraphic, theNtbk, theID
Notebook $theNtbk, text=mdURL
return 0
end
--> Save the notebook as HTML. This will save an HTML file (NotebookName.htm) and all graphics as PNG in a folder called NotebookNameMedia.
--> Save the notebook as text. Rename the extension from .txt to .md.
--> Remove the .htm file.
Here is how I handle saving the notebook in the Log Book package.
Static Function Save_NtbktoMD(string theNtbk)
string htmfilename, mdfilename
htmfilename = theNtbk + ".htm"
mdfilename = theNtbk + ".md"
NewPath/O/Q/M="Choose location for markdown notebook" ntbkpath
if (v_flag != 0)
return 0
endif
SaveNotebook/O/P=ntbkpath/S=5/H={"UTF-8",0,0,0,0,32} $theNtbk as htmfilename
SaveNotebook/O/P=ntbkpath/S=6 $theNtbk as mdfilename
DeleteFile/P=ntbkpath htmfilename
return 0
end
Here is an example of an Igor Pro notebook output as markdown with the graphics as viewed in Obsidian. This is generated directly by the Log Book package.
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More