ampproject / ampproject/amp-toolbox-php

Port HtmlParser over from amphtml

Open
#272 2 comments 0 reactions 0 assignees View on GitHub
HtmlParser Validator
Dominant language
PHP
Stars
74
Forks
25
Avg merge
1d 15h
Merged PRs (30d)
3

Description

The validator cannot be built on top of the `Dom\Document` we are using for the sanitizer and optimizer, as it requires precise line/column/length coordinates for pinpointing validation issues in the source files.

The NodeJS validator uses a SAX parser to traverse the HTML, with the actual validation engine being a handler that gets triggered by the SAX events, i.e. `startTag()`, `endTag()`, ...

After looking at existing HTML SAX parsers in PHP, my conclusion is to port over the parser implementation from NodeJS instead of reusing an existing PHP HTML SAX parser, for the following reasons:
- no implementation was recently maintained;
- third-party dependencies should be avoided whenever we can for the toolbox;
- a lot of the hard-coded logic of the parser is already found in the toolbox because we needed parts for other tools...
- ...therefore it can be ported with only modest effort.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the PHP toolbox code that already contains parts of the HTML parser and compare it with the NodeJS validator's SAX parser. Port the parser logic so it emits events such as startTag() and endTag() while preserving precise source coordinates. Done means the validator can use it to pinpoint issues without relying on Dom\Document.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.