Is it possible to change the size of my fonts and background color when I generate an HTML document using the PUBLISH function in MATLAB 7.8 (R2009a)?

6 views (last 30 days)
I am using the PUBLISH function to generate an HTML document for my code.
However, when I publish my MATLAB file, the first line (which is in cell mode) appears in two lines of text instead of one.
My code contains just this one line:
%%function myOutputs = testHTML(myInput1,myInput2,myInputs3)
It appears like there is a line break which is being used in the style sheet. I would like to be able to change that value to something which is better suited for my use.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Aug 2015
When the HTML document is created with the PUBLISH function; it uses the 'mxdom2simplehtml.xsl' stylesheet.
Since the code here has only one line of code, the PUBLISH function considers this line to be the introduction and hence has bigger font styles/sizes.
You can modify the contents of the stylesheet and accordingly use it to generate HTML documents of your specification. To make changes to the stylesheet, you can follow these steps:
1) At the MATLAB command prompt, type:
fullfile(matlabroot, '\toolbox\matlab\codetools\private\')
2) Navigate to this folder from within MATLAB or outside MATLAB.
3) Now, open up the XSL stylesheet named: mxdom2simplehtml.xsl either using MATLAB editor or using any other editor like Wordpad.
4) Now, search the document (using Ctrl+F) for the words "max-width"
5) You will come to a location where the document reads:
/* Make the text shrink to fit narrow windows, but not stretch too far in
wide windows. */
p,h1,h2,div.content div {
max-width: 600px;
/* Hack for IE6 */
width: auto !important; width: 600px;
}
Here, you can change the width from "600" to say "900" (in both the locations).
We can also change the color of the text in the HTML file, for example to "black". Search (using ctrl+f) for the following code in the XSL file:
pre.codeoutput {
color: #666666;
padding: 10px;
}
To change the color from "grey" to black, replace the above code with the following code:
pre.codeoutput {
color: black;
padding: 10px;
}
6) Save the changed file as 'mxdom2simplehtml2.xsl' in a location outside the matlabroot folder so that you do not overwrite the existing stylesheet for example at a location like "C:\Users\nidhij\Desktop\xslFiles".
7) Now, whenever you would like to use this width setting, you can use the following command in MATLAB:
publish('testHTML.m', 'stylesheet', 'C:\Users\nidhij\Desktop\xslFiles\mxdom2simplehtml2.xsl')
This will make sure that the PUBLISH function uses this setting for the width while generating the HTML document.
  2 Comments
Matthew Simoneau
Matthew Simoneau on 10 Jun 2014
I recommend saving your modified stylesheet to a location outside of MATLABROOT.
copyfile(which('private/mxdom2simplehtml.xsl'),'C:\Profiles\matthew\Documents\MATLAB\mysheet.xsl')
There's no need to use Wordpad. You can edit the stylesheet right in the MATLAB Editor.
edit C:\Profiles\matthew\Documents\MATLAB\mysheet.xsl
Also, there's no need to get XSLT involved. You can specify the custom stylesheet as an option to PUBLISH:
publish('testHTML', 'stylesheet', 'C:\Profiles\matthew\Documents\MATLAB\mysheet.xsl')

Sign in to comment.

More Answers (0)

Products


Release

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!