--- name: publishing-tutorials-examples description: Use when converting an ISETCam tutorial or example .m file into a self-contained HTML file for a wiki page — iePublish, s_publishTutorials, s_publishExamples, embedding figures or movies, or GitHub Pages/wiki linking. --- # Publishing Tutorials and Examples ISETCam provides `iePublish` and the `s_publish*.m` helper scripts for converting MATLAB tutorials and examples into HTML files that can be linked from wiki pages. The publishing helpers are intended to create self-contained HTML files. Figures are embedded directly in the HTML as base64 images, so the result can be served as one file without copying a companion folder of PNG files. ## Publish One File From a MATLAB session with ISETCam on the path: ```matlab htmlFile = iePublish('tutorials/scene/t_sceneIntroduction.m'); web(htmlFile, '-browser'); ``` For tutorials in a dependent repository, pass the full path to the source script after that repository is on the MATLAB path: ```matlab htmlFile = iePublish(fullfile(isetbioRootPath, ... 'tutorials', 'cmosaic', 't_cMosaicBasic.m')); ``` `iePublish` writes the HTML file next to the source `.m` file, using the same base name and the `.html` extension. ## Publish a Set of Files ISETCam provides these batch scripts: ```matlab s_publishTutorials s_publishExamples ``` Both scripts call `iePublish` with `imageFormat` set to `'inline'`. This is the setting that embeds figures in the HTML and makes the output suitable for serving from a web page and linking from a wiki. The default `s_publishTutorials` run publishes all known ISETCam tutorial directories. The default `s_publishExamples` run currently publishes the selected example directory listed in the script; edit `sDir` in that file to publish a different example subset. ## Useful Options The defaults are chosen for wiki-linkable tutorial output: ```matlab htmlFile = iePublish(sourceFile, ... 'evalCode', true, ... 'showCode', true, ... 'imageFormat', 'inline', ... 'maxHeight', 512, ... 'maxWidth', 512); ``` Common adjustments are: - `evalCode`: Set to `false` for a quick code-only preview. Figures and command output are only regenerated when this is `true`. - `showCode`: Set to `false` when the HTML should show output without source code. - `maxHeight` and `maxWidth`: Resize embedded figures for more manageable HTML pages. - `catchError`: Leave as `true` for most publishing runs so one script error does not terminate a batch unexpectedly. - `stylesheet`: Pass a CSS file when a project needs custom HTML styling. For wiki-linked pages, keep `imageFormat` set to `'inline'`. Other formats, such as `'png'`, require the external image files to be copied and linked along with the HTML file. ## Embedded Movies Small MP4 movies can be embedded in the generated HTML. Write the movie next to the source file while publishing, then add a prose marker comment with the relative movie file name: ```matlab movieFile = fullfile(fileparts(mfilename('fullpath')), 'exampleMovie.mp4'); ieMovie(movieData, 'vname', movieFile, 'show', false, 'FrameRate', 8); %% % iePublishVideo: exampleMovie.mp4 ``` With the default inline publishing mode, `iePublish` replaces that marker with a self-contained HTML `