unclosed-tag-finder
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "unclosed-tag-finder", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A library to find unclosed html5 tags, that are normally optional.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,13 +0,34 @@ | ||
# node-unclosed-tag-finder | ||
# Unclosed Tag Finder | ||
> A library that finds unclosed html5 tags, that are normally optional. | ||
A library that finds unclosed html5 tags that are normally optional. These optional tags could be: | ||
- html | ||
- head | ||
- body | ||
- p | ||
- dt | ||
- dd | ||
- li | ||
- option | ||
- thead | ||
- th | ||
- tbody | ||
- tr | ||
- td | ||
- tfoot | ||
- colgroup | ||
## Install | ||
``` | ||
$ npm install unclosed-tag-finder | ||
user$ npm install unclosed-tag-finder | ||
``` | ||
## Usage | ||
## Usage (in short) | ||
``` | ||
user$ npm install unclosed-tag-finder | ||
user$ vi listUnclosedTags.js | ||
``` | ||
```js | ||
@@ -38,4 +59,69 @@ #!/usr/bin/env node | ||
finder.printUnclosedTags(unclosedTags); | ||
if (unclosedTags.length == 0) { | ||
console.info('Congratulations! No unclosed tags.'); | ||
} else { | ||
if (unclosedTags.length == 1) { | ||
console.info('The following tag doesn\'t seem to be closed'); | ||
} else { | ||
console.info('The following tags don\'t seem to be closed'); | ||
} | ||
for (var i = 0; i < unclosedTags.length; i++) { | ||
console.info('line ' + unclosedTags[i].line + ': ' + unclosedTags[i].full); | ||
} | ||
} | ||
}); | ||
``` | ||
``` | ||
user$ chmod 775 listUnclosedTags.js | ||
user$ ./listUnclosedTags.js test.html | ||
The following tags don't seem to be closed | ||
line 7: <p> | ||
line 8: <p> | ||
line 10: <li> | ||
``` | ||
## Full example with html5 file | ||
Create a W3C valid html5 file (but with some unclosed tags): | ||
``` | ||
user$ vi w3cValid.html | ||
``` | ||
``` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>test</title> | ||
</head> | ||
<body> | ||
<p>123 | ||
<p>456 | ||
<ul> | ||
<li>123 | ||
</ul> | ||
</body> | ||
</html> | ||
``` | ||
Install a W3C checker and check the file (the w3c checker above will accept the unclosed tags): | ||
``` | ||
user$ npm install html-validator-cli -g | ||
user$ html-validator --file=w3cValid.html | ||
Page is valid | ||
``` | ||
The page is valid. Now check the file with the listUnclosedTags.js script (see [Usage](#user-content-usage)): | ||
``` | ||
user$ ./listUnclosedTags.js test.html | ||
The following tags don't seem to be closed | ||
line 7: <p> | ||
line 8: <p> | ||
line 10: <li> | ||
``` | ||
Although the script is valid, we found some unclosed html5 tags. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8162
127