Skip to content

grabcode

miscellaneous · scripts/miscellaneous/grabcode.m

: grabcode (file)
: code = grabcode (file)

Recover the source code from a document written by publish.

file is the name of a local HTML file, a ‘file://’ address or an ‘http://’ or ‘https://’ address of such a document. The code is the text between the markers ##### SOURCE BEGIN ##### and ##### SOURCE END ##### in the page, with the HTML escapes undone.

With an output argument the code is returned as a string. Without one, it is saved to a temporary file that is opened in the editor.