Introduction

edit

Meziantou.Framework.Html.Tool is a .NET tool, meziantou.html, that updates HTML files in place. Run it in a build or a deployment script, after the files are generated and before they are published.

What you can do with it

  • Replace values: set the text of the elements or the values of the attributes that an XPath expression selects, such as a version number. See Replacing values.
  • Append versions to URLs: add a ?v= parameter, computed from the content of the file, to the URLs of the style sheets, scripts and images, so that browsers download a file again when it changes. See Appending versions.
  • Inline resources: replace the references to style sheets, scripts and images with their content, to get a single-file page. See Inlining resources.

Each command updates one file, or all the files that a glob pattern matches. See Selecting files.

How it works

The tool parses each file with the HTML parser of Meziantou.Framework.WebPlatform, as a browser does, finds the nodes to change, and writes the file back. The patterns use the standard dialect of Meziantou.Framework.Globbing.

The updated files are re-serialized in the standard HTML form: the formatting of the markup, such as the quotes of the attributes or the self-closing tags, is not preserved. See Output format and encoding.

Next steps