Tidy Example

Using the HTML Filter Site Maven plugin you can tidy HTML files produced outside the normal site generation process. These files can then be used in your site documentation.

You can run the goal directly by executing:

mvn htmlfilter-site:tidy

It is better to bind the goal to the pre-site execution phase, thus:

<plugin>
    <groupId>org.kathrynhuxtable.maven.plugins</groupId>
    <artifactId>htmlfilter-site-maven-plugin</artifactId>
    <version>0.3.4</version>
    <executions>
        <execution>
            <goals>
                <goal>tidy</goal>
            </goals>
            <phase>pre-site</phase>
        </execution>
    </executions>
    ...
</plugin>

That way you can simply execute:

mvn site

and the files will be tidied before your site documentation.

By default, the source files are found in ${basedir}/src/site/html and are tidied into ${project.build.directory}/generated-site/resources, which will be copied into your site documentation folder. You can override this by specifying the tidySourceDirectory or tidyTargetDirectory parameter in the configuration section of the plugin, as in the example below, or by specifying the ${htmlfiltersite.tidySourceDirectory} or ${htmlfiltersite.tidyTargetDirectory} expression in your POM or on the command line.

The source and target directories can be the same, in which case the tidied files will overwrite and replace the originals.

A Full Example

The following is a complete example of using the HTML Filter Site Maven plugin to tidy all the html files in a directory tree.

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.kathrynhuxtable.maven.plugins</groupId>
        <artifactId>htmlfilter-site-maven-plugin</artifactId>
        <version>0.3.4</version>
        <executions>
          <execution>
            <goals>
              <goal>tidy</goal>
            </goals>
            <phase>pre-site</phase>
          </execution>
        </executions>
        <configuration>
          <tidySourceDirectory>${basedir}/src/site/myhtml</tidySourceDirectory>
          <tidyTargetDirectory>${project.build.directory}/generated-site/xhtml</tidyTargetDirectory>
          <tidyFilePattern>**/*.html,**/*.html.vm</tidyFilePattern>
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

The example above binds the tidy goal to the pre-site phase, causing it to run before the site documentation is created.

The tidySourceDirectory parameter overrides the default source directory.

The tidyTargetDirectory parameter overrides the default target directory.

The tidyFilePattern parameter overrides the default pattern matching the files to be converted. The value specified is actually the default value.