Skip to content

Commit

Permalink
Formatting w/ black
Browse files Browse the repository at this point in the history
  • Loading branch information
danthedeckie committed Mar 6, 2020
1 parent 574d623 commit 03b4506
Show file tree
Hide file tree
Showing 8 changed files with 801 additions and 526 deletions.
7 changes: 7 additions & 0 deletions Makefile
Expand Up @@ -17,3 +17,10 @@ pypi: test dist/
clean:
rm -r build
rm -r dist

.venv:
python3 -m venv .venv
.venv/bin/pip install black

format: .venv
.venv/bin/black html5validate tests
13 changes: 8 additions & 5 deletions README.rst
Expand Up @@ -21,10 +21,14 @@ The version on PyPI (0.0.2) uses html5lib's basic parsing and linting,
here is the development version, which includes actually checking for
valid elements and attributes as per the W3C spec.

This branch (custom-parser-lexer-WIP) uses a basic custom HTML5 parser, which
enabled better error messages including line & character number, checking for multiple
errors rather than failing at the first one, amongst other improvements.

Still work in progress - it needs to have easy options for specifying
extra tags that you want to allow (such as `ng-` style or `v-` javascript
templating), and also an easy way to disallow anything you don't want,
or forbid external URLs, or whatever.
templating), custom elements, etc. and also an easy way to disallow anything
you don't want, or forbid external URLs, or whatever.

Please feel free to add to this, contributions welcome!

Expand Down Expand Up @@ -64,7 +68,8 @@ Status:
Very Early - I just pulled this out of some django view testing code in one of
my other projects, as it seemed more sensible to have it as a stand-alone
library that could be unit-tested and stuff, and I can use again easily,
and then started hacking a bit on it to make it more general.
and then started hacking a bit on it to make it more general, and it got a bit
out of control...

Initial basic tests are here - but it should really have a LOT of tests written.

Expand All @@ -75,5 +80,3 @@ Roadmap:
- Write some extra tree walkers and checkers to look for valid tags, and throw
some decent exceptions, and have customisability, specify what tags users
want, etc.


3 changes: 2 additions & 1 deletion html5validate/__init__.py
@@ -1,8 +1,9 @@
from .validator import validate


if __name__ == '__main__':
if __name__ == "__main__":
import sys

if len(sys.argv) > 1:
for f in sys.argv[1:]:
with open(f) as fh:
Expand Down
13 changes: 11 additions & 2 deletions html5validate/exceptions.py
@@ -1,33 +1,42 @@
class HTML5Invalid(Exception):
pass

#class LintError(HTML5Invalid):

# class LintError(HTML5Invalid):
# pass


class ValidationException(HTML5Invalid):
pass


class InvalidTag(ValidationException):
pass


class EmptyPage(ValidationException):
pass


class MisplacedElement(ValidationException):
pass


class MisplacedEndTag(ValidationException):
pass


class InvalidAttribute(ValidationException):
pass


class NonSecureRequestInSecurePage(ValidationException):
pass


class UnclosedTags(ValidationException):
pass


class UnknownNodeType(Exception):
pass

0 comments on commit 03b4506

Please sign in to comment.