1<?xml version="1.0"?> 2<!-- 3 For generating the `tidy.1` man page from the 4 output of `tidy -xml-help` and `tidy -xml-config` 5 6 (c) 2005 (W3C) MIT, ERCIM, Keio University 7 See tidy.h for the copyright notice. 8 9 Written by Jelks Cabaniss and Arnaud Desitter 10 11 CVS Info : 12 13 $Author: iccir $ 14 $Date: 2007/01/31 02:44:02 $ 15 $Revision: 1.1 $ 16 17--> 18<xsl:stylesheet version="1.0" 19 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 20 21<xsl:strip-space elements="description" /> 22 23<xsl:output method="text" /> 24 25<!-- 26 The default template match is to the document passed on the 27 command line to the XSLT processor, currently "tidy-help.xml". 28 For the detailed config options section however, the template 29 match is to the file "tidy-config.xml". This is captured in 30 the $CONFIG variable, declared here: 31--> 32 33<xsl:variable name="CONFIG" select="document('tidy-config.xml')"/> 34 35 36<!-- Main Template: --> 37 38<xsl:template match="/"> 39 <xsl:call-template name="header-section" /> 40 <xsl:call-template name="cmdline-section" /> 41 <xsl:call-template name="config-section" /> 42 <xsl:call-template name="manpage-see-also-section" /> 43</xsl:template> 44 45 46<!-- Named Templates: --> 47 48 49<xsl:template name="header-section"> 50 <xsl:text/>.\" tidy man page for the Tidy Sourceforge project 51.TH tidy 1 "$Date: 2007/01/31 02:44:02 $" "HTML Tidy <xsl:value-of select="cmdline/@version" />" "User commands" 52</xsl:template> 53 54 55<xsl:template name="cmdline-section"> 56.SH NAME 57\fBtidy\fR - validate, correct, and pretty-print HTML files 58.br 59(version: <xsl:value-of select="cmdline/@version" />) 60.SH SYNOPSIS 61\fBtidy\fR [option ...] [file ...] [option ...] [file ...] 62.SH DESCRIPTION 63Tidy reads HTML, XHTML and XML files and writes cleaned up markup. For HTML variants, it detects and corrects many common coding errors and strives to produce visually equivalent markup that is both W3C compliant and works on most browsers. A common use of Tidy is to convert plain HTML to XHTML. For generic XML files, Tidy is limited to correcting basic well-formedness errors and pretty printing. 64.LP 65If no input file is specified, Tidy reads the standard input. If no output file is specified, Tidy writes the tidied markup to the standard output. If no error file is specified, Tidy writes messages to the standard error. 66For command line options that expect a numerical argument, a default is assumed if no meaningful value can be found. 67.SH OPTIONS 68<xsl:call-template name="show-cmdline-options" /> 69.SH USAGE 70.LP 71Use \fB--\fR\fIoptionX valueX\fR for the any detailed configuration option "optionX" with the argument "valueX". See also below under \fBDetailed Configuration Options\fR as to how to conveniently group all such options in a single config file. 72.LP 73Input/Output default to stdin/stdout respectively. Single letter options apart from \fB-f\fR and \fB-o\fR may be combined as in: 74.LP 75.in 1i 76\fBtidy -f errs.txt -imu foo.html\fR 77.LP 78For further info on HTML see \fIhttp://www.w3.org/MarkUp\fR. 79.LP 80For more information about HTML Tidy, visit the project home page at \fIhttp://tidy.sourceforge.net\fR. Here, you will find links to documentation, mailing lists (with searchable archives) and links to report bugs. 81.SH ENVIRONMENT 82.TP 83.B HTML_TIDY 84Name of the default configuration file. This should be an absolute path, since you will probably invoke \fBtidy\fR from different directories. The value of HTML_TIDY will be parsed after the compiled-in default (defined with -DCONFIG_FILE), but before any of the files specified using \fB-config\fR. 85.SH "EXIT STATUS" 86.IP 0 87All input files were processed successfully. 88.IP 1 89There were warnings. 90.IP 2 91There were errors. 92</xsl:template> 93 94 95<xsl:template name="config-section"> 96.SH ______________________________ 97.SH " " 98.SH "DETAILED CONFIGURATION OPTIONS" 99This section describes the Detailed (i.e., "expanded") Options, which may be specified by preceding each option with \fB--\fR at the command line, followed by its desired value, OR by placing the options and values in a configuration file, and telling tidy to read that file with the \fB-config\fR standard option. 100.SH SYNOPSIS 101\fBtidy --\fR\fIoption1 \fRvalue1 \fB--\fIoption2 \fRvalue2 [standard options ...] 102.br 103\fBtidy -config \fIconfig-file \fR[standard options ...] 104.SH WARNING 105The options detailed here do not include the "standard" command-line options (i.e., those preceded by a single '\fB-\fR') described above in the first section of this man page. 106.SH DESCRIPTION 107A list of options for configuring the behavior of Tidy, which can be passed either on the command line, or specified in a configuration file. 108.LP 109A Tidy configuration file is simply a text file, where each option 110is listed on a separate line in the form 111.LP 112.in 1i 113\fBoption1\fR: \fIvalue1\fR 114.br 115\fBoption2\fR: \fIvalue2\fR 116.br 117etc. 118.LP 119The permissible values for a given option depend on the option's \fBType\fR. There are five types: \fIBoolean\fR, \fIAutoBool\fR, \fIDocType\fR, \fIEnum\fR, and \fIString\fR. Boolean types allow any of \fIyes/no, y/n, true/false, t/f, 1/0\fR. AutoBools allow \fIauto\fR in addition to the values allowed by Booleans. Integer types take non-negative integers. String types generally have no defaults, and you should provide them in non-quoted form (unless you wish the output to contain the literal quotes). 120.LP 121Enum, Encoding, and DocType "types" have a fixed repertoire of items; consult the \fIExample\fR[s] provided below for the option[s] in question. 122.LP 123You only need to provide options and values for those whose defaults you wish to override, although you may wish to include some already-defaulted options and values for the sake of documentation and explicitness. 124.LP 125Here is a sample config file, with at least one example of each of the five Types: 126.LP 127\fI 128 // sample Tidy configuration options 129 output-xhtml: yes 130 add-xml-decl: no 131 doctype: strict 132 char-encoding: ascii 133 indent: auto 134 wrap: 76 135 repeated-attributes: keep-last 136 error-file: errs.txt 137\fR 138.LP 139Below is a summary and brief description of each of the options. They are listed alphabetically within each category. There are five categories: \fIHTML, XHTML, XML\fR options, \fIDiagnostics\fR options, \fIPretty Print\fR options, \fICharacter Encoding\fR options, and \fIMiscellaneous\fR options. 140.LP 141.SH OPTIONS 142<xsl:call-template name="show-config-options" /> 143</xsl:template> 144 145 146<xsl:template name="show-cmdline-options"> 147.SS File manipulation 148 <xsl:call-template name="cmdline-detail"> 149 <xsl:with-param name="category">file-manip</xsl:with-param> 150 </xsl:call-template> 151.SS Processing directives 152 <xsl:call-template name="cmdline-detail"> 153 <xsl:with-param name="category">process-directives</xsl:with-param> 154 </xsl:call-template> 155.SS Character encodings 156 <xsl:call-template name="cmdline-detail"> 157 <xsl:with-param name="category">char-encoding</xsl:with-param> 158 </xsl:call-template> 159.SS Miscellaneous 160 <xsl:call-template name="cmdline-detail"> 161 <xsl:with-param name="category">misc</xsl:with-param> 162 </xsl:call-template> 163</xsl:template> 164 165 166<xsl:template name="cmdline-detail"> 167<!-- 168For each option in one of the 3 categories/classes, provide its 169 1. names 170 2. description 171 3. equivalent configuration option 172--> 173 <xsl:param name="category" /> 174 <xsl:for-each select='/cmdline/option[@class=$category]'> 175<xsl:text> 176.TP 177</xsl:text> 178 <xsl:call-template name="process-names" /> 179 <xsl:text> 180</xsl:text> 181 <xsl:apply-templates select="description" /> 182 <xsl:text> 183</xsl:text> 184 <xsl:call-template name="process-eqconfig" /> 185 </xsl:for-each> 186</xsl:template> 187 188 189<xsl:template name="process-names"> 190<!-- Used only in the cmdline section --> 191 <xsl:for-each select="name"> 192 <xsl:text />\fB<xsl:value-of select="." />\fR<xsl:text /> 193 <xsl:if test="position() != last()"> 194 <xsl:text>, </xsl:text> 195 </xsl:if> 196 </xsl:for-each> 197</xsl:template> 198 199 200<xsl:template name="process-eqconfig"> 201<!-- Used only in the cmdline section --> 202 <xsl:if test="string-length(eqconfig) > 0"> 203 <xsl:for-each select="eqconfig"> 204 <xsl:text>(\fI</xsl:text> 205 <xsl:value-of select="." /> 206 <xsl:text>\fR)</xsl:text> 207 </xsl:for-each> 208 </xsl:if> 209</xsl:template> 210 211 212<xsl:template name="show-config-options"> 213<!-- Used only in the cmdline section --> 214.SS HTML, XHTML, XML options: 215 <xsl:call-template name="config-detail"> 216 <xsl:with-param name="category">markup</xsl:with-param> 217 </xsl:call-template> 218.SS Diagnostics options: 219 <xsl:call-template name="config-detail"> 220 <xsl:with-param name="category">diagnostics</xsl:with-param> 221 </xsl:call-template> 222.SS Pretty Print options: 223 <xsl:call-template name="config-detail"> 224 <xsl:with-param name="category">print</xsl:with-param> 225 </xsl:call-template> 226.SS Character Encoding options: 227 <xsl:call-template name="config-detail"> 228 <xsl:with-param name="category">encoding</xsl:with-param> 229 </xsl:call-template> 230.SS Miscellaneous options: 231 <xsl:call-template name="config-detail"> 232 <xsl:with-param name="category">misc</xsl:with-param> 233 </xsl:call-template> 234</xsl:template> 235 236 237<!-- 238 Note that any templates called implicitly or explicitly 239 from the "config-detail" template below will match on 240 the document referred to by the $CONFIG variable, i.e., 241 the file "tidy-config.xml", created by running 242 243 tidy -xml-config > tidy-config.xml 244 245 The $CONFIG variable is set at the top level of this 246 stylesheet. 247--> 248 249<xsl:template name="config-detail"> 250<!-- 251For each option in one of the 5 categories/classes, provide its 252 1. name 253 2. type 254 3. default (if any) 255 4. example (if any) 256 5. seealso (if any) 257 6. description 258--> 259 <xsl:param name="category" /> 260 <xsl:for-each select='$CONFIG/config/option[@class=$category]'> 261 <xsl:sort select="name" order="ascending" /> 262.TP 263\fB<xsl:apply-templates select="name" />\fR 264 265Type: \fI<xsl:apply-templates select="type" />\fR 266.br 267<xsl:call-template name="provide-default" /> 268.br 269<xsl:call-template name="provide-example" /> 270<xsl:text> 271 272</xsl:text> 273<xsl:apply-templates select="description" /> 274<xsl:call-template name="seealso" /> 275 </xsl:for-each> 276</xsl:template> 277 278 279<!-- Used only in the config options section: --> 280<xsl:template name="seealso"> 281 <xsl:if test="seealso"> 282 <xsl:text> 283 284</xsl:text> 285.rj 1 286\fBSee also\fR: <xsl:text /> 287 <xsl:for-each select="seealso"> 288 <xsl:text />\fI<xsl:value-of select="." />\fR<xsl:text /> 289 <xsl:if test="position() != last()"> 290 <xsl:text>, </xsl:text> 291 </xsl:if> 292 </xsl:for-each> 293 </xsl:if> 294</xsl:template> 295 296 297<!-- Used only in the config options section: --> 298<xsl:template name="provide-default"> 299<!-- 300Picks up the default from the XML. If the `default` element 301doesn't exist, or it's empty, a single '-' is provided. 302--> 303 <xsl:choose> 304 <xsl:when test="string-length(default) > 0 "> 305 <xsl:text />Default: \fI<xsl:apply-templates 306 select="default" />\fR<xsl:text /> 307 </xsl:when> 308 <xsl:otherwise> 309 <xsl:text />Default: \fI-\fR<xsl:text /> 310 </xsl:otherwise> 311 </xsl:choose> 312</xsl:template> 313 314 315<!-- Used only in the config options section: --> 316<xsl:template name="provide-example"> 317<!-- 318By default, doesn't output examples for String types (mirroring the 319quickref page). But for *any* options in the XML instance that 320have an `example` child, that example will be used in lieu of a 321stylesheet-provided one. (Useful e.g. for `repeated-attributes`). 322--> 323 <xsl:choose> 324 <xsl:when test="string-length(example) > 0"> 325 <xsl:text />Example: \fI<xsl:apply-templates 326 select="example" />\fR<xsl:text /> 327 </xsl:when> 328 <xsl:otherwise> 329 <xsl:text />Default: \fI-\fR<xsl:text /> 330 </xsl:otherwise> 331 </xsl:choose> 332</xsl:template> 333 334 335<!-- Called from the templates below matching `code`, `em`, `strong`: --> 336<xsl:template name="escape-backslash"> 337<!-- 338Since backslashes are "special" to the *roff processors used 339to generate man pages, we need to escape backslash characters 340appearing in content with another backslash. 341--> 342 <xsl:choose> 343 <xsl:when test="contains(.,'\')"> 344 <xsl:value-of select= 345 "concat( substring-before(.,'\'), '\\', substring-after(.,'\') )" /> 346 </xsl:when> 347 <xsl:otherwise> 348 <xsl:apply-templates /> 349 </xsl:otherwise> 350 </xsl:choose> 351</xsl:template> 352 353 354<!-- Appears at the bottom of the man page: --> 355<xsl:template name="manpage-see-also-section"> 356.SH "SEE ALSO" 357HTML Tidy Project Page at \fIhttp://tidy.sourceforge.net\fR 358.SH AUTHOR 359\fBTidy\fR was written by Dave Raggett <\fIdsr@w3.org\fR>, and is now maintained and developed by the Tidy team at \fIhttp://tidy.sourceforge.net/\fR. It is released under the \fIMIT Licence\fR. 360.LP 361Generated automatically with HTML Tidy released on <xsl:value-of select="cmdline/@version" />. 362</xsl:template> 363 364 365<!-- Regular Templates: --> 366 367 368<xsl:template match="description"> 369 <xsl:apply-templates /> 370</xsl:template> 371 372<xsl:template match="a"> 373 <xsl:apply-templates /> 374 <xsl:text /> at \fI<xsl:value-of select="@href" />\fR<xsl:text /> 375</xsl:template> 376 377<xsl:template match="code | em"> 378 <xsl:text />\fI<xsl:call-template name="escape-backslash" />\fR<xsl:text /> 379</xsl:template> 380 381<xsl:template match="br"> 382 <xsl:text> 383.br 384</xsl:text> 385</xsl:template> 386 387<xsl:template match="strong"> 388 <xsl:text />\fB<xsl:call-template name="escape-backslash" />\fR<xsl:text /> 389</xsl:template> 390 391 392<!-- 393The following templates 394 a) normalize whitespace, primarily necessary for `description` 395 b) do so without stripping possible whitespace surrounding `code` 396 d) strip leading and trailing whitespace in 'description` and `code` 397(courtesy of Ken Holman on the XSL-list): 398--> 399 400<xsl:template match="text()[preceding-sibling::node() and 401 following-sibling::node()]"> 402 <xsl:variable name="ns" select="normalize-space(concat('x',.,'x'))"/> 403 <xsl:value-of select="substring( $ns, 2, string-length($ns) - 2 )" /> 404</xsl:template> 405 406<xsl:template match="text()[preceding-sibling::node() and 407 not( following-sibling::node() )]"> 408 <xsl:variable name="ns" select="normalize-space(concat('x',.))"/> 409 <xsl:value-of select="substring( $ns, 2, string-length($ns) - 1 )" /> 410</xsl:template> 411 412<xsl:template match="text()[not( preceding-sibling::node() ) and 413 following-sibling::node()]"> 414 <xsl:variable name="ns" select="normalize-space(concat(.,'x'))"/> 415 <xsl:value-of select="substring( $ns, 1, string-length($ns) - 1 )" /> 416</xsl:template> 417 418<xsl:template match="text()[not( preceding-sibling::node() ) and 419 not( following-sibling::node() )]"> 420 <xsl:value-of select="normalize-space(.)"/> 421</xsl:template> 422 423</xsl:stylesheet> 424