MATLAB: How to publish to HTML without the MATLAB code being automatically inserted as comments into the generated HTML file in MATLAB 7.6 (R2008a)

codecommentedMATLABpublishwithout

The 'showCode' property of the PUBLISH function is set to 'false' while the page source of HTML file shows the commented MATLAB code. I would like to know what to do if commented code is to be hidden.

Best Answer

Navigate to the folllowing folder :
$MATLABROOT\toolbox\matlab\codetools\private
where $MATLABROOT is the root MATLAB directory which can be found by typing
matlabroot
at the MATLAB Command Prompt.
Copy the 'mxdom2simplehtml.xsl' file from this directory and paste it to the location where the code to be published is present. Rename the xsl file as 'noCode.xsl' and remove or comment the following from the file:
##### SOURCE BEGIN #####
<xsl:value-of select="$xcomment"/>
##### SOURCE END #####
Use the following in your code:
options.stylesheet = 'noCode.xsl';
options.showCode = false;
Following is an illustrative example:
options.format = 'html';
options.evalCode = true;
options.stylesheet = 'noCode.xsl';
options.showCode = false;
options.codeToEvaluate = filename; % filename is the name of the file which is to be published
publish(filename,options);