| Component | Kind | Role |
|---|---|---|
| static library | Raw lexical scanner; produces a |
|
| static library | Groups tokens into structured |
|
| static library | Applies the eight structural rules; collects all errors before returning | |
| executable ( |
CLI orchestration — parses arguments, walks directories, prints the report |
# 1. Configure and build (Release) cmake -B build -G "Visual Studio 17 2022" cmake --build build --config Release # 2. Validate a single file build\entry_point\Release\page_validator index.html # 3. Validate a directory tree, quiet mode (errors only) build\entry_point\Release\page_validator -r -q .\site # 4. Validate with pass/fail summary build\entry_point\Release\page_validator -r -s .\site
| Option | Argument | Default | Meaning |
|---|---|---|---|
| file or directory | (required) | One or more HTML files or directories to validate | |
| (flag) | off | Descend into subdirectories | |
| (flag) | off | Print only files with errors; suppress PASS lines | |
| (flag) | off | Print pass/fail count after all files are processed | |
| (flag) | off | Print help and exit |
PASS site/index.html
FAIL site/about.html
[tag-nesting] 14:3 — </div> does not match open <p>
[duplicate-id] 22:10 — duplicate id 'header'
PASS site/contact.html
2 passed, 1 failed
| Rule | What is checked |
|---|---|
| Document begins with |
|
| Exactly one |
|
| Every open tag has a matching close tag in the correct order | |
| Void elements ( |
|
| All attribute values are quoted | |
| No two elements share the same |
tok::TagOpen, tok::TagClose, tok::AttrName, tok::AttrValue, tok::AttrUnquoted, tok::SelfClose, tok::TagEnd, tok::Text, tok::Comment, tok::Doctype, tok::EofEvery token carries a (line, col) position for precise error reporting. The tokenizer holds no HTML grammar knowledge — it only recognises
lex::OpenTag, lex::SelfClosingTag, lex::CloseTag, lex::TextNode, lex::CommentNode, lex::DoctypeDecl
# Configure cmake -B build -G "Visual Studio 17 2022" # Build Release cmake --build build --config Release # Run all unit tests ctest --test-dir build --build-config Release --output-on-failure
| Component | Tests | Coverage |
|---|---|---|
| 12 | tags, attributes, doctypes, comments, position tracking | |
| 11 | tag grouping, attribute collection, case normalization | |
| 12 | valid documents, missing elements, nesting errors, void elements, duplicate IDs, unquoted attributes |
# Run all tests ctest --test-dir build --build-config Release --output-on-failure