HtmlLoadOptions.IgnoreNoscriptElements

HtmlLoadOptions IgnoreNoscriptElements property. Gets or sets a value indicating whether to ignore noscript HTML elements. Default value is false.

HtmlLoadOptions.IgnoreNoscriptElements property

Gets or sets a value indicating whether to ignore <noscript> HTML elements. Default value is false.

public bool IgnoreNoscriptElements { get; set; }

Remarks

Like MS Word, Wordize does not support scripts and by default loads content of <noscript> elements into the resulting document. In most browsers, however, scripts are supported and content from <noscript> is not visible. Setting this property to true forces Wordize to ignore all <noscript> elements and helps to produce documents that look closer to what is seen in browsers.

Examples

Shows how to ignore noscript HTML elements.

const string html = @"
    <html>
      <head>
        <title>NOSCRIPT</title>
          <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">
          <script type=""text/javascript"">
            alert(""Hello, world!"");
          </script>
      </head>
    <body>
      <noscript><p>Your browser does not support JavaScript!</p></noscript>
    </body>
    </html>";
MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html));

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.IgnoreNoscriptElements = true;

Converter.Create()
    .From(htmlStream, htmlLoadOptions)
    .To(ArtifactsDir + "HtmlLoadOptions.IgnoreNoscriptElements.docx")
    .Execute();

See Also