Code Monkey home page Code Monkey logo

vnu-elixir's Introduction

Vnu

angelikatyborska Hex.pm Hex.pm Hex.pm Coverage Status

An Elixir client for the Nu HTML Checker (v.Nu).

Expected HTML document to be valid, but got 1 error. Attribute html-is-awesome not allowed on element body at this point.

v.Nu is a document validity checker used by the W3C. It offers validating HTML, CSS, and SVG documents.

This library brings that functionality to Elixir by using the Checker's JSON API. It offers ExUnit assertions for validating dynamic content in tests, Mix tasks for validating static content, and general purpose functions to fulfill other needs.

Prerequisites

While it is possible to use this library with the service run by W3C at validator.w3.org/nu, I would recommend running your own instance. You will eliminate a lot of network latency if it runs on the same machine as your code, and you will not hit any rate limits that might exist for validator.w3.org/nu.

The source of the Checker can be found in the repository validator/validator. Follow their instructions on how to download it and run it as a web server.

The easiest option is to use the Docker image, like this:

docker run -d --rm -p 8888:8888 ghcr.io/validator/validator:latest

The command might require an additional --platform linux/amd64 flag on M1 macs.

Check if the server is running:

$ curl localhost:8888 -I
HTTP/1.1 200 OK

Installation

Make sure to read about the prerequisites first.

Add Vnu as a dependency to your project's mix.exs. To use the built-in, Hackney-based HTTP client adapter, also add :hackney:

defp deps do
  [
    {:vnu, "~> 1.1", only: [:dev, :test], runtime: false},
    {:hackney, "~> 1.18"}
  ]
end

Then run:

$ mix deps.get

If you don't want to use Hackney, you can implement your own HTTP client module using the Vnu.HTTPClient behavior and pass it in the http_client option.

Documentation

Available on hexdocs.pm.

Usage

See the usage guide.

Development

Make sure to read about the prerequisites first.

After cloning the repository, run mix deps.get and you should be ready for development.

To ensure code consistency, run mix lint.

Running tests

All test that expect to talk with the server accept the server's URL as an VNU_SERVER_URL environment variable or fallback to the default http://localhost:8888.

$ VNU_SERVER_URL=http://localhost:4000/ mix test 

If you're adding a new test, make sure it will do that do.

Contributing

Issues

If you noticed a problem with the library or its documentation, or have an idea for a feature, open an issue.

If you have an idea on how to act upon the problem or idea, feel free to open a pull request instead.

Pull requests

If you noticed a problem with the library or its documentation and know how to fix it, or have an idea for a feature, or want to fix a typo, open a pull request.

If you are not sure of your changes or need help finishing them, open a pull request anyway. I'll try to help!

License

Vnu is released under the MIT License. See the LICENSE file for further details.

vnu-elixir's People

Contributors

angelikatyborska avatar dependabot-preview[bot] avatar dependabot[bot] avatar

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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vnu-elixir's Issues

Make HTTPoison optional, allow replacing with Tesla

For projects that already use Tesla as a HTTP client, it might be annoying that this library requires HTTPoison.

It should be possible to allow to choose either one or the other.

However, that would make it slightly harder for everyone else to start using the library, because now everyone would have to explicitly add a HTTP client library as a dependency too (if it's not already there).

Are there any other popular HTTP client libraries that this one should support?

Please react with ๐Ÿ‘ if you think that's a change worth adding.

Make Jason optional, allow replacing with Poison

For projects that already use Poison for JSONs, it might be annoying that this library requires Jason.

It should be possible to allow to choose either one or the other, like Phoenix currently does:
https://github.com/phoenixframework/phoenix/blob/51baf69993100c7ef40d097b02285ff28e4e16c9/lib/phoenix.ex#L69-L71
https://github.com/phoenixframework/phoenix/blob/2e5711c102a260a8d9457229c3dfd33f91c7cf99/lib/phoenix.ex#L87

However, that would make it slightly harder for everyone else to start using the library, because now everyone would have to explicitly add a JSON library as a dependency too (if it's not already there).

Are there any other popular JSON libraries that this one should support?

Please react with ๐Ÿ‘ if you think that's a change worth adding.

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.