mlreportgen.utils.html2dom.prepHTMLFile
Prepare HTML file for conversion to DOM
Syntax
Description
prepares the HTML in the file specified by preppedHTMLStr = mlreportgen.utils.html2dom.prepHTMLFile(htmlFile)htmlFile for conversion to the
MATLAB®
Report Generator™ internal document object model (DOM). The prepared HTML in
preppedHTMLStr can be converted to a DOM API representation by using an
mlreportgen.dom.HTML object. The
mlreportgen.utils.html2dom.prepHTMLFile function:
Corrects invalid markup by calling
mlreportgen.utils.tidywith the settings for HTML output.Uses the MATLAB HTML Viewer to convert the tidied markup to an HTML DOM document. See https://www.w3.org/TR/WD-DOM/introduction.html.
The MATLAB HTML Viewer computes the CSS properties of the elements in the HTML input based on internal and external style sheets specified by the input HTML, and on the style attribute of an element. The CSS property computation supports all valid CSS style sheet selectors, including selectors not directly supported by
mlreportgen.dom.HTMLormlreportgen.dom.HTMLFileobjects.Converts the HTML DOM document to HTML markup that is supported by
mlreportgen.dom.HTMLandmlreportgen.dom.HTMLFileobjects. The style attribute for each element specifies the element CSS properties that the MATLAB HTML Viewer computed.Returns the prepared HTML as a string scalar.
generates the prepared HTML in a file with the name specified by
preppedHTMLFileName = mlreportgen.utils.html2dom.prepHTMLFile(htmlFile,preppedHTMLFileName)preppedHTMLFile.The prepared HTML in
preppedHTMLFileName can be converted to a DOM API representation by
using an mlreportgen.dom.HTMLFile object.
prepares the HTML without first tidying it. Specify preppedHTMLStr = mlreportgen.utils.html2dom.prepHTMLFile(___,"Tidy",false)"Tidy",false after
all other input arguments. Use this syntax if you want to tidy the HTML markup yourself. For
example, you might want to call mlreportgen.utils.tidy with different
options than the ones used by mlreportgen.utils.html2dom.prepHTMLFile,
then pass the tidied HTML as the input to
mlreportgen.utils.html2dom.prepHTMLFile.
Examples
Input Arguments
Output Arguments
Tips
MATLAB Report Generator
mlreportgen.dom.HTMLormlreportgen.dom.HTMLFileobjects typically cannot accept the raw HTML output of third-party applications, such as Microsoft® Word, that export native documents as HTML markup. In these cases, your Report API report generation program can use themlreportgen.utils.html2dom.prepHTMLStringandmlreportgen.utils.html2dom.prepHTMLFilefunctions to prepare the raw HTML for use with themlreportgen.dom.HTMLormlreportgen.dom.HTMLFileobjects. Typically, your program will have to further process the prepared HTML to remove valid but undesirable objects, such as line feeds that were in the raw content.
Version History
Introduced in R2020a