mlreportgen.utils.html2dom.prepHTMLString
Prepare HTML string for conversion to DOM
Syntax
Description
prepares the HTML in the string specified by preppedHTMLStr = mlreportgen.utils.html2dom.prepHTMLString(htmlStr)htmlStr 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.prepHTMLString 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.HTMLobjects.Converts the HTML DOM document to HTML markup that is supported by
mlreportgen.dom.HTMLobjects. 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.
prepares the input HTML without first tidying it. Use this syntax if you want to tidy the
HTML markup yourself. For example, you might want to call
preppedHTMLStr = mlreportgen.utils.html2dom.prepHTMLString(htmlStr,"Tidy",false)mlreportgen.utils.tidy with different options than the ones used by
mlreportgen.utils.html2dom.prepHTMLString, then pass the tidied HTML
as the input to mlreportgen.utils.html2dom.prepHTMLString.
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