Code Monkey home page Code Monkey logo

html-linter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html-linter's Issues

HTML Entities are not handled correctly

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 '&'.

coala

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.

Disable linter via HTML comment

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.

False possitive ExtraWhitespaceMessage

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.

Indentation checker fails

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.

Linter fails in Python 3.5.0

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?

Script returns 0 on Lint failure

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

Output cannot be redirected

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)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.