Giter Club home page Giter Club logo

validator-java's Introduction

AMP HTML โšก Validator

Build status: test

AMP HTML Validator takes input of HTML text and parses the text tag by tag, running the ruleset against every tag. Resultant from this process is validity of the input text and the errors generated while parsing.

Table of Contents

Background

@nhant01, @GeorgeLuo, and @randymo own development and maintenance responsibility of the project. As such they will serve as the points of contact surrounding changes and modifications. The team will allocate resources to align the business with the implementations provided under the amphtml repo. With that in mind, should supporting this project become infeasible, we will publish a version of the codebase marked for deprecation and prepare for its removal from public repositories (every effort will be made to not have this happen).

Install

Maven

AMP HTML Validator uses maven as tool for building and managing project. Add following snippet to your pom.xml and hit "mvn" to build your project.

<dependency>
  <groupId>dev.amp</groupId>
  <artifactId>validator-java</artifactId>
  <version>${version.number}</version>
</dependency>

Here are the instructions to setup maven environment. https://maven.apache.org/what-is-maven.html https://maven.apache.org/guides/introduction/introduction-to-the-pom.html

Usage

Initialize the validator using

final AMPHtmlParser ampHtmlParser = new AMPHtmlParser();
final ValidationResult validationResult = ampHtmlParser.parse(inputHtml, htmlFormat, condition, maxNodes);

The parser can be used beyond the first document, to truncate initialization time. The maxNode condition is the maximum number of tags reviewed by the validator before forcing exit on exception. The condition is an enumeration of type ExitCondition, either exit on first error or a full parsing attempt. The htmlFormat is an enumeration for the format of AMP to be validated against.

Issues

The are several known bugs in the validation output.

  • the DOCTYPE tag is assumed to exist. Documents without the tag will fail to return an error.
  • Observance of afterbody mode is not implemented. Tags that appear following a body closing tag should be interpreted as within the body tag. Specs that mandate relationships between tags and ancestors related to the body tag will not account for this behavior and will return unexpected errors.
  • Attributes are de-duped by the internal html parser (the last value assigned to an attribute is the one returned to the handler). This leads to discrepancies in attribute validation to do with validation of the uniqueness of attributes and unexpected behavior in value validation.
  • Validation of URLs found within the HTML document may not return the same errors as the Node.js implementation. This stems from the fact that the internal URL library is lenient in terms of validating hostnames and characters used within the URL.
  • This validator prioritizes amp4email html content, enforcement of validator logic for other formats is not guaranteed.
  • CSS validation does not yet configure for a max nodes value

Contribute

Please refer to the Contribute.md file for information about how to get involved. We welcome issues, questions, and pull requests. Pull Requests are welcome.

License

This project is licensed under the terms of the Apache 2.0 open source license. Please refer to LICENSE for the full terms.

Attribution

validator-java's People

Contributors

danielrozenberg avatar georgeluo avatar gregable avatar jmjames37 avatar nhant01 avatar randymo avatar renovate[bot] avatar rsimha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

validator-java's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update com.github.spotbugs.version to v4.8.5 (com.github.spotbugs:spotbugs-annotations, com.github.spotbugs:spotbugs)
  • Update dependency com.yahoo.tagchowder:tagchowder.core to v2.0.29
  • Update dependency org.apache.maven.plugins:maven-source-plugin to v3.3.1
  • Update dependency org.jacoco:jacoco-maven-plugin to v0.8.12
  • Update dependency org.apache.commons:commons-text to v1.12.0
  • Update dependency org.apache.maven.plugins:maven-assembly-plugin to v3.7.1
  • Update dependency org.apache.maven.plugins:maven-gpg-plugin to v3.2.4
  • Update dependency org.apache.maven.plugins:maven-pmd-plugin to v3.22.0
  • Update dependency org.apache.maven.plugins:maven-scm-plugin to v2.1.0
  • Update dependency org.codehaus.mojo:build-helper-maven-plugin to v3.6.0
  • Update dependency org.testng:testng to v7.10.2
  • Update protobuf.version to v4 (major) (com.google.protobuf:protobuf-java, com.google.protobuf:protoc)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/publish-maven-package.yml
  • actions/checkout v4
  • actions/setup-java v3
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-java v3
maven
pom.xml
  • kr.motd.maven:os-maven-plugin 1.7.1
  • org.apache.maven.plugins:maven-clean-plugin 3.3.2
  • org.codehaus.mojo:exec-maven-plugin 3.1.1
  • org.apache.maven.plugins:maven-dependency-plugin 3.6.1
  • com.google.protobuf:protoc 3.25.2
  • org.apache.maven.plugins:maven-antrun-plugin 3.1.0
  • org.codehaus.mojo:build-helper-maven-plugin 3.5.0
  • org.antlr:antlr3-maven-plugin 3.5.3
  • org.codehaus.mojo:javacc-maven-plugin 3.0.1
  • org.apache.maven.plugins:maven-resources-plugin 3.3.1
  • org.apache.maven.plugins:maven-assembly-plugin 3.6.0
  • org.apache.maven.plugins:maven-scm-plugin 2.0.1
  • com.googlecode.jslint4java:jslint4java-maven-plugin 2.0.5
  • org.apache.maven.plugins:maven-enforcer-plugin 3.4.1
  • com.github.spotbugs:spotbugs-maven-plugin 4.8.3.0
  • com.github.spotbugs:spotbugs 4.8.3
  • com.github.spotbugs:spotbugs-annotations 4.8.3
  • org.dom4j:dom4j 2.1.4
  • org.apache.maven.plugins:maven-pmd-plugin 3.21.2
  • org.apache.maven.plugins:maven-surefire-plugin 3.2.5
  • org.apache.maven.plugins:maven-checkstyle-plugin 3.3.1
  • com.puppycrawl.tools:checkstyle 10.12.7
  • org.jacoco:jacoco-maven-plugin 0.8.11
  • org.apache.maven.plugins:maven-compiler-plugin 3.11.0
  • org.apache.maven.plugins:maven-source-plugin 3.3.0
  • org.apache.maven.plugins:maven-source-plugin 3.3.0
  • org.apache.maven.plugins:maven-javadoc-plugin 3.6.3
  • org.apache.maven.plugins:maven-gpg-plugin 3.1.0
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.6.13
  • com.fasterxml.jackson.core:jackson-annotations 2.16.1
  • com.fasterxml.jackson.core:jackson-core 2.16.1
  • com.fasterxml.jackson.core:jackson-databind 2.16.1
  • com.fasterxml.jackson.jaxrs:jackson-jaxrs-base 2.16.1
  • com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider 2.16.1
  • net.sourceforge.cssparser:cssparser 0.9.30
  • com.google.protobuf:protobuf-java 3.25.2
  • com.yahoo.tagchowder:tagchowder.core 2.0.27
  • com.google.code.findbugs:jsr305 3.0.2
  • org.apache.commons:commons-lang3 3.14.0
  • org.apache.commons:commons-text 1.11.0
  • com.puppycrawl.tools:checkstyle 10.12.7
  • org.testng:testng 7.9.0
  • org.junit.jupiter:junit-jupiter-api 5.10.1
  • org.mockito:mockito-core 5.10.0

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: None
Error type: Invalid gitAuthor
Message: gitAuthor is not parsed as valid RFC5322 format: renovate[bot] <renovate[bot]@users.noreply.github.com>

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.