Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindprod.compactor
Class Compactor

    java.lang.Object
      com.mindprod.compactor.Compactor

    public class Compactor

extends java.lang.Object

Compacts HTML by removing unnecessary white space.

We always compact whitespace inside and outside comments.

We don't consolidate tags. e.g. <span class="x">this </span><span class="x">and that</span> can be collapsed to <span class="x">this and that</span>.

We don't convert tags to lower case e.g. <BR> to <br>

We leave all comments in place. If ever such a feature is implemented, it must not strip SSI comments. It may or may not leave macro comments.

We do not remove macro generations. You can do that with StripGenerated.

We do not remove the macro comments.

We remove space and NLs on the right of <div><dt><li><h?><ol><table><tbody><td><th><thead><tr><ul> tags.

We remove space and NLs on the lift of </div></dt></li></h?></ol></table></tbody></td></th></thead></tr></ul> tags.

We always remove lead and trailing spaces from lines.

We compact spaces in side HTML text, tags and comments.

We leave spaces as is inside <pre>...</pre> and inside quoted tag parameters.

We convert " to &quot; > to &gt; when used in raw text.

We don't tokenise to convert to CBF, compact binary format. The catch here is web browsers can't read the result without a plugin. This would result in a major compaction. Perhaps the XML folk will eventually get disgusted with their obese format and XHTML can inherit a now compact form.

We don't do any LZW compression. the catch is, browsers can't read this without a special plugin.

Since:
  2006
Version:
  2.9 2010-01-18 - refactor so you first allocate a Compactor object, permitting simultaneous compactings..
Author:
  Roedy Green, Canadian Mind Products

Field Summary
`static java.lang.String` | `EMBEDDED_COPYRIGHT` undisplayed copyright notice
`static java.lang.String` | `VERSION_STRING` embedded version string.

Constructor Summary
`Compactor()` constructor

Method Summary
`void` | `compactFile(boolean quiet, java.io.File fileBeingProcessed)` compact and tidy one file.
`java.lang.String` | `compactString(java.lang.String big, java.lang.String where)` Remove excess whitespace from HTML represented by string.
`static void` | `main(java.lang.String[] args)` compacts HTML files.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EMBEDDED_COPYRIGHT

    public static final java.lang.String EMBEDDED_COPYRIGHT

  undisplayed copyright notice

  See Also:
    Constant Field Values

### VERSION_STRING

    public static final java.lang.String VERSION_STRING

  embedded version string.

  See Also:
    Constant Field Values

Constructor Detail

### Compactor

    public Compactor()

  constructor

Method Detail

### compactFile

    public void compactFile(boolean quiet,
                            java.io.File fileBeingProcessed)
                     throws java.io.IOException

  compact and tidy one file.

  Parameters:
    `quiet` - true if want progress messages suppressed
    `fileBeingProcessed` - File to compact and tidy.
  Throws:
    `java.io.IOException` - Suppress IntelliJ Code Analyse that wants to make this private.

### compactString

    public java.lang.String compactString(java.lang.String big,
                                          java.lang.String where)

  Remove excess whitespace from HTML represented by string.

  Parameters:
    `big` - the String to compact.
    `where` - used in error messages to indicate where the error occurred, usually the name of the file being compacted.
  Returns:
    the compacted String, big itself if nothing changed.

### main

    public static void main(java.lang.String[] args)

  compacts HTML files.

  Parameters:
    `args` - names of files to process, dirs, files, -s, *.*, no wildcards.

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD