deezer / html-linter Goto Github PK
View Code? Open in Web Editor NEWHTML5 Linter based on Google Style Guide
License: Apache License 2.0
HTML5 Linter based on Google Style Guide
License: Apache License 2.0
If the string '&redirect=' appears in the document then it will be reported as that it needs to be changed to its character representation.
The problem here is that the regex that comes with HTMLParser, does not enforce that the entity ends in a semicolon.
This problem can also happen with urls that do not use & and use instead just '&'.
I'd be great if there were a package for this to integrate with https://github.com/atom-community/linter for https://atom.io.
Hey,
we're working on a tool that makes it very easy to create "code checking routines" and provide you with the whole user interaction (from JSON output via interactive CLI UI to an actual GUI and we're working on things like direct GitHub integration that automatically reviews your code using arbitrary coala routines and stuff like that) and collection routines for free. You just need to write the logic, nothing else.
We'd be interested in porting your routines over to our project so you get a better user interaction, logging, severity levels, automatic issue fixing and so on for them (and we get more analysis). Would you be interested in porting your analysis routines over to coala? I'd be glad to assist you.
This would implicitly solve #5. It should also simplify your development and we'd maintain your stuff together with coala and its routines, hopefully with you.
More info also on coala-analyzer.org , I'm also happy to answer any questions you might have right here.
Is there a functionality to temporarily disable the linter for a block of HTML code?
I have some unavoidable errors that I'd like to suppress. I render some HTML with a syntax highlighter (ruby rouge), and the indentation is off. What would be useful is this:
... pretty HTML ...
<!-- html-linter:disable Indentation -->
... some ugly HTML ...
<!-- html-linter:enable Indentation -->
... more pretty HTML
Note: This syntax is taken directly from the SCSS linter.
I have following code:
<div class="form-group{% if provider.errors %} has-error{% endif %}">
After cleaning template tags it becomes this:
<div class="form-group has-error ">
And html-linter
reports ExtraWhitespaceMessage
error.
Any ideas how to workaround this?
Currently I had to disable ExtraWhitespaceMessage
.
Sometimes an error like:
20:1: Error: Indentation: Use two spaces and no tabs: Was expecting between 0 and 7 (in multiples of 2) spaces but got 4.
is displayed. However, this should never happen as the expected numbers of spaces must be even.
This happens because when adjusting the indentation we don't check that the value was odd.
When an attribute is a number (product of being replaced by the tempalte remover), a CapitalizationMessage will be reported. This is because python islower is broken (see http://bugs.python.org/issue13822).
In [1]: '0'.islower()
Out[1]: False
In [2]: '0' == '0'.lower()
Out[2]: True
Unfortunately html_linter
does not currently work with Python 3.5, returning the following error:
(mysite)Honorss-Air-2:templates Honors$ html_lint.py this_website.html
Traceback (most recent call last):
File "/Users/Honors/Desktop/mysite/bin/html_lint.py", line 119, in <module>
sys.exit(main())
File "/Users/Honors/Desktop/mysite/bin/html_lint.py", line 109, in main
results = html_linter.lint(clean_html, exclude=exclude)
File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 1024, in lint
messages = [m.__unicode__() for m in HTML5Linter(html).messages
File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 529, in __init__
self.feed(html)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 111, in feed
self.goahead(0)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 163, in goahead
k = self.parse_starttag(i)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/html/parser.py", line 337, in parse_starttag
self.handle_starttag(tag, attrs)
File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 617, in handle_starttag
self._check_attributes_case_quotation_entities(tag, attrs)
File "/Users/Honors/Desktop/mysite/lib/python3.5/site-packages/html_linter.py", line 800, in _check_attributes_case_quotation_entities
for match in HTMLParser.attrfind.finditer(original_def, len(tag) + 1):
AttributeError: module 'html.parser' has no attribute 'attrfind'
A quick Google search for the nature of this problem brought up this blog post, which seems to point to HTMLParseError
having been deprecated in Python 3.5.0.
This commit was pushed to fix this issue for Django
. My project uses Flask
, though.
Hope to see this get fixed! In the meantime I am using online HTML validators and fixing post-facto, which is inelegant; for the meantime, does anyone know of a good workaround?
Hi guys,
Thanks a lot for putting this tool together. Just have one small issue with it. The html_lint.py
script appears to return 0 on Lint failure, making it difficult to use for automated build tools like Travis. It should return a non-0 code on Lint failure, I reckon.
> html_lint.py bad.html
1:1: Error: Indentation: Do not use tabs: Remove the tabs.
> echo $?
0
Redirecting the output to a pipe or a file will result in the following traceback:
Traceback (most recent call last):
File "/usr/local/bin/html_lint.py", line 107, in <module>
sys.exit(main())
File "/usr/local/bin/html_lint.py", line 103, in main
print(html_linter.lint(clean_html, exclude=exclude)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 307: ordinal not in range(128)```
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.