Pull request Compare This branch is 2 commits ahead, 59 commits behind next.


<h1 id="htacghtmltidy">HTACG HTML Tidy</h1>

<h2 id="prerequisites">Prerequisites</h2>

<li><p>git - <a href="http://git-scm.com/book/en/v2/Getting-Started-Installing-Git">http://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a></p></li>
<li><p>cmake - <a href="http://www.cmake.org/download/">http://www.cmake.org/download/</a></p></li>
<li><p>appropriate build tools for the platform</p></li>
<li><p>the <a href="http://xmlsoft.org/XSLT/xsltproc2.html">xsltproc</a> tool is required to build and install the <code>tidy.1</code> man page on Unix-like platforms.</p></li>

<p>CMake comes in two forms - command line and GUI. Some installations only install one or the other, but sometimes both. The build commands below are only for command line use.</p>

<p>Also the actual build tools vary for each platform. But that is one of the great features of CMake, it can generate variuous &#8216;native&#8217; build files. Running <code>cmake --help</code> should list the generators available on that platform. For sure one of the common ones is &#8220;Unix Makefiles&#8221;, which needs autotools make installed, but many other generators are supported.</p>

<p>In Windows CMake offers various versions for MSVC. Again below only the command line use of MSVC is shown, but the tidy solution (*.sln) file can be loaded into the MSVC IDE, and the building done in there.</p>

<h2 id="buildthetidylibraryandcommandlinetool">Build the tidy library and command line tool</h2>

<li><p><code>cd build/cmake</code></p></li>
<li><p><code>cmake ../.. -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=/path/for/install]</code></p></li>
<li><p>Windows: <code>cmake --build . --config Release</code><br/>
 Unix/OS X: <code>make</code></p></li>
<li><p>Install, if desired:<br/>
 Windows: <code>cmake --build . --config Release --target INSTALL</code><br/>
 Unix/OS X: <code>[sudo] make install</code></p></li>

<p>By default cmake sets the install path to <code>/usr/local/bin</code> in Unix. If you wanted the binary in say <code>/usr/bin</code> instead, then in 2. above use <code>-DCMAKE_INSTALL_PREFIX=/usr</code>.</p>

<p>Also, in Unix if you want to build the release library without any debug <code>assert</code> in the code then add <code>-DCMAKE_BUILD_TYPE=Release</code> in step 2. This adds a <code>-DNDEBUG</code> macro to the compile switches. This is normally added in windows build for the <code>Release</code> config.</p>

<p>In Windows the default install is to <code>C:\Program Files\tidy</code>, or <code>C:/Program Files (x86)/tidy</code>, which is not very useful. After the build the <code>tidy.exe</code> is in the <code>Release</code> directory, and can be copied to any directory in your <code>PATH</code> environment variable for global use.</p>

<p>If you do <strong>not</strong> need the tidy library built as a &#8216;shared&#8217; (DLL) library, then in 2. add the command <code>-DBUILD_SHARED_LIB:BOOL=OFF</code>. This option is <strong>ON</strong> by default. The static library is always built and linked with the command line tool for convenience in Windows, and so the binary can be run as part of the man page build without the shared library being installed in unix.</p>

<p>See the <code>CMakeLists.txt</code> file for other CMake <strong>options</strong> offered.</p>

<h2 id="buildphpwiththetidy-html5library">Build PHP with the tidy-html5 library</h2>

<p>Due to API changes in the PHP source, <code>buffio.h</code> needs to be renamed to <code>tidybuffio.h</code> in the file <code>ext/tidy/tidy.c</code> in PHP&#8217;s source.</p>

<p>That is - prior to configuring PHP run this in the PHP source directory:
sed -i 's/buffio.h/tidybuffio.h/' ext/tidy/*.c

<p>And then continue with (just an example here, use your own PHP config options):</p>

<pre><code>./configure --with-tidy=/usr/local
make test
make install

<p>; eof</p>