forked from validator/validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
614 lines (519 loc) · 19.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
<!doctype html><html><head><meta charset=utf-8>
<title>The Nu Html Checker (v.Nu)</title>
<link href="site/icon.png" rel="icon">
<style>
html {
background: #DDE5D9 url(data:image/gif;base64,R0lGODlhBAAEAIAAANra2v///yH5BAAAAAAALAAAAAAEAAQAAAIFTGB4xlcAOw==) repeat 0 0;
font-family: "Lucida Sans Unicode", "Lucida Sans", verdana, arial, helvetica;
}
body {
border: solid 1px #CED4CA;
background-color: #FFF;
padding: 4px 25px 4px 25px;
margin: 20px 20% 20px 20px;
line-height: 1.75;
}
h1 {
font-size: 36px;
font-weight: normal;
color: #0B5B9D;
vertical-align: top;
margin-bottom: 0px;
}
h2 {
font-size: 28px;
font-weight: normal;
color: #0B5B9D;
vertical-align: top;
margin-bottom: 0px;
margin-top: 24px;
}
h3 {
font-size: 22px;
font-weight: normal;
color: #0B5B9D;
vertical-align: top;
margin-bottom: 0px;
margin-top: 32px;
}
h4 {
font-size: 20px;
font-weight: normal;
color: #0B5B9D;
vertical-align: top;
margin-bottom: 0px;
margin-top: 22px;
}
a {
text-decoration: none;
color: #0B5B9D;
padding: 2px;
}
a:hover {
text-decoration: none;
background-color: #0B5B9D;
color: white;
}
a:active {
text-decoration: none;
background-color: white;
color: black;
}
h1 a:hover {
background-color: inherit;
color: white;
}
.set, .note {
background-color: ivory;
padding: 16px;
padding-top: 4px;
padding-bottom: 4px;
padding-right: 32px;
padding-left: 32px;
border: 1px solid #ccc;
margin-left: 2px;
margin-right: 2px;
border-radius: 6px;
}
.note {
background-color: rgb(241, 255, 240);
}
.note p {
margin-top: 8px;
}
code {
background-color: #F8F8F8;
border: 1px solid #ccc;
border-radius: 3px;
padding: 2px 6px;
}
pre {
background-color: #F8F8F8;
border: 1px solid #ccc;
border-radius: 3px;
padding: 10px;
margin-right: 15%;
margin-top: 6px;
line-height: 1.2
}
pre.aligned {
margin-left: 40px;
}
.java-class, .java-property, .option-value {
background-color: yellow;
padding: 2px 6px;
}
.arg {
color: green;
}
.links {
text-align: center;
}
a b {
font-weight: normal;
}
li > ul {
padding-top: 6px;
padding-bottom: 8px;
}
</style>
</head>
<body>
<h1>The Nu Html Checker (v.Nu)
<a href="https://gitter.im/validator/validator"
><img src="https://goo.gl/1kHqwI" alt="Chat room"></a>
<a href="https://github.com/validator/validator/releases/latest"
><img src="https://goo.gl/3PC2Qn" alt="Download latest"></a>
</h1>
<p>
The Nu Html Checker (v.Nu) is a name for the backend of
<a href="https://checker.html5.org/">checker.html5.org</a>,
<a href="https://html5.validator.nu">html5.validator.nu</a>,
and
<a href="http://validator.w3.org/nu/">validator.w3.org/nu</a>.
Its
<a href="https://github.com/validator/validator">source code is available</a>,
as are
<a href="https://validator.github.io/validator/#build-instructions">instructions on how to build, test, and run the code</a>.
It is released as two packages:
<ul>
<li><code>vnu.jar</code> is a portable standalone version for
<a href="https://validator.github.io/validator/#usage">batch-checking documents from the command line</a>
and from other scripts/apps, or for
<a href="https://validator.github.io/validator/#standalone">deploying the checker as a self-contained service</a>
<li><code>vnu.war</code> is for
<a href="https://validator.github.io/validator/#servlet">deploying the checker service through a servlet container such as Tomcat</a>
</ul>
<p class=note><b>Note:</b> The <var>vnu.jar</var> and <var>vnu.war</var>
packages require a Java 8 environment; they won’t run in Java 7 or
older environment.
<p>
To use the Nu Html Checker on your own,
<a href="https://github.com/validator/validator/releases/latest">get the latest release</a>
and see the
<a href="#usage"><b>Usage</b></a>
and
<a href="#web-based-checking"><b>Web-based checking</b></a>
sections belowーor alternatively, consider automating your HTML
checking with a frontend such as:
<ul>
<li>
<a href="https://github.com/jzaefferer/grunt-html">Grunt plugin for HTML validation</a>
<li>
<a href="https://github.com/watilde/gulp-html">Gulp plugin for HTML validation</a>
<li>
<a href="https://github.com/svenkreiss/html5validator">HTML5 Validator Integration for Travis CI</a>
(auto-check documents pushed to a github repo)
<li>
<a href="https://github.com/cvrebert/lmvtfy/">LMVTFY: Let Me Validate That For You</a>
(auto-check HTML of JSFiddle/JSBin etc. links in github issue comments)
</ul>
<p class=links>
<a href="#usage">Usage</a> ·
<a href="#options">Options</a> ·
<a href="#web-based-checking">Web-based checking</a>
<div class=set>
<section id=usage>
<h2>Usage</h2>
<p>You can use the <code>vnu.jar</code> HTML checker as an executable for
command-line checking of documents by invoking it like this:
<pre>
java -jar vnu.jar [--errors-only] [--no-stream]
[--format gnu|xml|json|text] [--help]
[--html] [--no-langdetect] [--skip-non-html]
[--verbose] [--version] FILES
</pre>
<p class=note><b>Note:</b> In these instructions, replace
<var>"~/vnu.jar"</var> with the actual path to the file on your system.
<p>To check one or more documents from the command line:
<pre>
java -jar ~/vnu.jar FILE.html FILE2.html FILE3.HTML FILE4.html...
</pre>
<div class=note>
<p><b>Note:</b> If you get a <code>StackOverflowError</code>
error when using the vnu.jar file, try adjusting the thread stack size by
providing the <code>-Xss</code> option to java:</p>
<pre>
java <span class="option-value">-Xss512k</span> -jar ~/vnu.jar FILE.html...
</pre>
</div>
<p>To check all documents in a particular directory:
<pre>
java -jar ~/vnu.jar some-directory-name/
</pre>
<p>To check all documents in a particular directory, skipping any documents
whose names don’t end with the extensions <code>.html</code>,
<code>.htm</code>, <code>.xhtml</code>, or <code>.xht</code>:
<pre>
java -jar ~/vnu.jar <span class="option-value">--skip-non-html</span> some-directory-name/
</pre>
<p>To check a Web document:
<pre>
java -jar ~/vnu.jar <var>URL</var>
example: java -jar ~/vnu.jar http://example.com/foo
</pre>
<p>To check standard input:
<pre>
java -jar ~/vnu.jar -
example: echo '<!doctype html><title>...' | java -jar ~/vnu.jar -
</pre>
<h3 id="options">Options</h3>
<p>When used from the command line as described in this section, the
<code>vnu.jar</code> executable provides the following options:
<h4 id="errors-only">--errors-only</h4>
<pre>
Specifies that only error-level messages and non-document-error messages
are reported (so that warnings and info messages are not reported).
default: [unset; all message reported, including warnings & info messages]
</pre>
<h4 id="format">--format <var>format</var></h4>
<pre>
Specifies the output format for reporting the results.
default: <span class=option-value>"gnu"</span>
possible values: <span class=option-value>"gnu"</span>, <span class=option-value>"xml"</span>, <span class=option-value>"json"</span>, <span class=option-value>"text"</span> [see information at URL below]
https://github.com/validator/validator/wiki/Service:-Common-parameters#out
</pre>
<h4 id="help">--help</h4>
<pre>
Shows detailed usage information.
</pre>
<h4 id="skip-non-html">--skip-non-html</h4>
<pre>
Skip documents that don’t have *.html, *.htm, *.xhtml, or *.xht extensions.
default: [unset; all documents found are checked, regardless of extension]
</pre>
<h4 id="html">--html</h4>
<pre>
Forces any *.xhtml or *.xht documents to be parsed using the HTML parser.
default: [unset; XML parser is used for *.xhtml and *.xht documents]
</pre>
<h4 id="no-langdetect">--no-langdetect</h4>
<pre>
Disables language detection, so that documents are not checked for missing
or mislabeled <code>html[lang]</code> attributes.
default: [unset; language detection & <code>html[lang]</code> checking are performed]
</pre>
<h4 id="no-stream">--no-stream</h4>
<pre>
Forces all documents to be be parsed in buffered mode instead of streaming
mode (causes some parse errors to be treated as non-fatal document errors
instead of as fatal document errors).
default: [unset; non-streamable parse errors cause fatal document errors]
</pre>
<h4 id="verbose">--verbose</h4>
<pre>
Specifies "verbose" output. (Currently this just means that the names of
files being checked are written to stdout.)
default: [unset; output is not verbose]
</pre>
<h4 id="version">--version</h4>
<pre>
Shows the <code>vnu.jar</code> version number.
</pre>
</section>
</div>
<h2 id="web-based-checking">Web-based checking with vnu.war or vnu.jar</h2>
<p>The Nu Html Checkerーalong with being usable as
<a href="https://validator.github.io/validator/#usage">a standalone command-line client</a>ーcan
be run as an HTTP service, similar to
<a href="https://checker.html5.org/">checker.html5.org</a>,
<a href="https://html5.validator.nu/">html5.validator.nu</a>,
and
<a href="http://validator.w3.org/nu/">validator.w3.org/nu</a>,
for browser-based checking of HTML documents over
the Web.
To that end, the checker is released as two separate packages:
<ul>
<li><code>vnu.jar</code> for
<a href="#standalone">deploying the checker as a simple self-contained service</a>
<li><code>vnu.war</code> for
<a href="#servlet">deploying the checker to a servlet container such as Tomcat</a>
</ul>
<p>
Both deployments expose a REST API that enables checking of HTML
documents from other clients, not just web browsers. And the
<code>vnu.jar</code> package also includes
<a href="#http-client">a simple HTTP client</a> that enables you to
either send documents to a locally-running instance of the checker HTTP
serviceーfor fast command-line checkingーor to any remote instance of the
checker HTTP service running anywhere on the Web.
<p>
The
<a href="https://github.com/validator/validator/releases/latest" >latest releases of the vnu.jar and vnu.war packages</a>
are available from the <code>validator</code> project at github.
The following are detailed instructions on using them.
<p class=note><b>Note:</b> Replace
<var>"~/vnu.jar"</var> or <var>"~/vnu.war"</var> below
with the actual paths to those files on your system.
<p class=links>
<a href="#standalone">Standalone</a> ·
<a href="#servlet">Servlet</a> ·
<a href="#http-client">Client</a> ·
<a href="#http-client-options">Options</a>
<div class=set>
<section id=standalone>
<h3>Standalone web server</h3>
<p>To run the checker as a standalone service (using a built-in
Jetty server), open a new terminal window and invoke <code>vnu.jar</code>
like this:
<pre>
java -cp ~/vnu.jar <span class=java-class>nu.validator.servlet.Main</span> <span class=arg>8888</span>
</pre>
<p>Then open
<a href="http://localhost:8888">http://localhost:8888</a>
in a browser. (To have the checker listen on a different port,
replace <code class=arg>8888</code> with the port number.)
<p>You’ll see a form similar to
<a href="http://validator.w3.org/nu/">validator.w3.org/nu</a>
that allows you to enter the URL of an HTML document and have the
results for that document displayed in the browser.
<div class=note>
<p><b>Note:</b> If you get a <code>StackOverflowError</code>
error when using the vnu.jar file, try adjusting the thread stack size by
providing the <code>-Xss</code> option to java:
<pre>
java <span class="option-value">-Xss512k</span> -cp ~/vnu.jar nu.validator.servlet.Main 8888
</pre>
</div>
</section>
<section id=servlet>
<h3>Deployment to servlet container</h3>
<p>To run the checker inside of an existing servlet container
such as Apache Tomcat you will need to deploy the <code>vnu.war</code>
file to that server following its documentation.
For example, on Apache Tomcat you could do this using
the <a href="http://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html">Manager</a> application or simply by copying the file to
the <code>webapps</code> directory
(since that is the default <code>appBase</code> setting).
Typically you would see a message similar to the following
in the <code>catalina.out</code> log file.
<pre>
May 7, 2014 4:42:04 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/vnu.war
</pre>
<p>Assuming your servlet container is configured to receive HTTP
requests sent to <code>localhost</code> on port <code>80</code>
and the context root of this application is <code>vnu</code>
(often the default behavior is to use the WAR file's filename
as the context root unless one is explicitly specified)
you should be able to access the application by connecting
to <a href="http://localhost/vnu/">http://localhost/vnu/</a>.
<div class=note>
<p>
<b>Note:</b> You may want to customize the <code>/WEB-INF/web.xml</code>
file inside the WAR file (you can use any ZIP-handling program)
to modify the servlet filter configuration.
For example, if you wanted to disable gzip decompression you
could comment out that filter like this:
<pre>
<!--
<filter>
<filter-name>gzip-filter</filter-name>
<filter-class>org.mortbay.servlet.GzipFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gzip-filter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
--></pre>
</div>
</section>
<section id=http-client>
<h3>HTTP client (for fast command-line checking)</h3>
<p>You can also use <code>vnu.jar</code> from the command line to
either send documents to a locally-running instance of the checker HTTP
serviceーfor fast command-line checkingーor to a remote instance
anywhere on the Web.
<p>
To check documents locally, do this:
<ol>
<li>Start up the checker as a local HTTP service, as described in the
<a href="#standalone">Standalone web server</a>
section.
<li>Open a new terminal window and invoke <code>vnu.jar</code> like this:
<pre>
java -cp ~/vnu.jar <span class=java-class>nu.validator.client.HttpClient</span> FILE.html...
</pre>
</ol>
To send documents to an instance of the checker on the Web, such as
<a href="http://html5.validator.nu/">html5.validator.nu/</a>,
use the
<a href="#nuvalidatorclienthost">nu.validator.client.host</a>
and
<a href="#nuvalidatorclientport">nu.validator.client.port</a>
options, like this:
<pre class=aligned>
java -cp ~/vnu.jar <span class=java-property>-Dnu.validator.client.port=80</span> \
<span class=java-property>-Dnu.validator.client.host=html5.validator.nu</span> \
nu.validator.client.HttpClient FILE.html...
</pre>
<p>Other options are documented below.
<h3 id="http-client-options">HTTP client options</h3>
<p>When using <code>vnu.jar</code> for sending documents to an instance
of the checker HTTP service for checking, you can set Java system
properties to control configuration options for the checker behavior.
<p>For example, you can suppress warning-level messages and only
show error-level ones by setting the value of the
<code>nu.validator.client.level</code> system property to
<code>error</code>, like this:
<pre class=aligned>
java <span class=java-property>-Dnu.validator.client.level=error</span>\
-cp ~/vnu.jar nu.validator.client.HttpClient FILE.html...
</pre>
<p>Most of the properties listed below map to the validator.nu common input
parameters documented at
<a href="https://github.com/validator/validator/wiki/Service:-Common-parameters"
>github.com/validator/validator/wiki/Service:-Common-parameters</a>.
<h4 id="nuvalidatorclienthost">nu.validator.client.host</h4>
<pre>
Specifies the hostname of the checker for the client to connect to.
default: <span class=option-value>"127.0.0.1"</span>
</pre>
<h4 id="nuvalidatorclientport">nu.validator.client.port</h4>
<pre>
Specifies the hostname of the checker for the client to connect to.
default: <span class=option-value>"8888"</span>
example: java -Dnu.validator.client.port=8080 -jar ~/vnu.jar FILE.html
</pre>
<h4 id="nuvalidatorclientlevel">nu.validator.client.level</h4>
<pre>
Specifies the severity level of messages to report; to
suppress warning-level messages, and only show error-level ones, set
this property to "error".
default: [unset]
possible values: <span class=option-value>"error"</span>
example: java -Dnu.validator.client.level=error -jar ~/vnu.jar FILE.html
</pre>
<h4 id="nuvalidatorclientparser">nu.validator.client.parser</h4>
<pre>
Specifies which parser to use.
default: <span class=option-value>"html"</span>; or, for *.xhtml input files, <span class=option-value>"xml"</span>
possible values: [see information at URL below]
https://github.com/validator/validator/wiki/Service:-Common-parameters#parser
</pre>
<h4 id="nuvalidatorclientcharset">nu.validator.client.charset</h4>
<pre>
Specifies the encoding of the input document.
default: [unset]
</pre>
<h4 id="nuvalidatorclientcontent-type">nu.validator.client.content-type</h4>
<pre>
Specifies the content-type of the input document.
default: <span class=option-value>"text/html"</span>; or, for *.xhtml files, <span class=option-value>"application/xhtml+xml"</span>
</pre>
<h4 id="nuvalidatorclientout">nu.validator.client.out</h4>
<pre>
Specifies the output format for messages.
default: "gnu"
possible values: [see information at URL below]
https://github.com/validator/validator/wiki/Service:-Common-parameters#out
</pre>
<h4 id="nuvalidatorclientasciiquotes">nu.validator.client.asciiquotes</h4>
<pre>
Specifies whether ASCII quotation marks are substituted for Unicode
smart quotation marks in messages.
default: "yes"
possible values: "yes" or "no"
</pre>
</section>
</div>
<section id="build-instructions">
<h2>Build instructions</h2>
<p>
Follow the steps below to build, test, and run the checker such that you can open
<code>http://localhost:8888/</code> in a Web browser to use the checker Web UI.
<div class=set>
<ol>
<li>Make sure you have git, python, and JDK 8 installed.
<li>Set the <code>JAVA_HOME</code> environment variable:
<pre>export JAVA_HOME=@@/PATH/TO/JDK/ON/YOUR/SYSTEM@@</pre>
For example:
<ul>
<li><code>export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64</code>
<li><code>export JAVA_HOME=$(/usr/libexec/java_home)</code> (Mac OS X)
</ul>
<li>Create a working directory:
<pre>git clone https://github.com/validator/validator.git</pre>
<li>Change into your working directory:
<pre>cd validator</pre>
<li>Start the build script:
<pre>python ./build/build.py all</pre>
<p class=note>
The first time you run the build script, you’ll need to be online and the
build will need time to download several megabytes of dependencies.
</li>
</ol>
<p>
The steps above will build, test, and run the checker such that you can open
<code>http://localhost:8888/</code> in a Web browser to use the checker Web UI.
<p>
Use <code>python ./build/build.py --help</code> to see command-line options for controlling the
behavior of the script, as well as build-target names you can call separately; e.g.:
<ul>
<li><code>python ./build/build.py build</code> (to build only)
<li><code>python ./build/build.py build test</code> (to build and test)
<li><code>python ./build/build.py run</code> (to run only)
<li><code>python ./build/build.py jar</code> (to compile <code>vnu.jar</code>)
</ul>
</div>
</section>