承接 golchha21/htmlforge 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

golchha21/htmlforge

最新稳定版本:v1.2.1

Composer 安装命令:

composer require golchha21/htmlforge

包简介

A standards-first HTML compiler for PHP that generates W3C-compliant, accessibility-validated HTML by construction.

README 文档

README

PHP Version Downloads License Accessibility Standards

HTMLForge is a standards-first HTML compiler for PHP.

It generates W3C-compliant, accessibility-validated HTML by compiling an explicit Abstract Syntax Tree (AST) through a deterministic validation pipeline.

HTMLForge does not guess, auto-fix, or silently tolerate invalid markup.

If HTML renders, it is structurally correct and policy-compliant.

Why HTMLForge

Most HTML generation tools:

  • concatenate strings
  • rely on browsers to fix mistakes
  • mix validation, rendering, and presentation
  • fail late and unclearly

HTMLForge takes a different approach:

  • HTML is treated as a language with rules
  • Validation happens before rendering
  • Errors are data, not crashes
  • Accessibility is enforced by default

Core Concepts

AST-first design

HTMLForge builds an immutable Abstract Syntax Tree (AST).

  • No raw HTML strings are rendered directly
  • Every element, attribute, and text node is explicit
  • Invalid structures cannot be constructed accidentally

Deterministic validation (v1.2)

All validation happens explicitly through a multi-phase validator pipeline:

  • Document structure
  • Content model rules
  • Attribute validity
  • Attribute value constraints
  • Accessibility (WCAG-aware)
  • ARIA semantics
  • Document metadata
  • Policy & security rules

Validation always runs before rendering.

In v1.2, validators emit violations instead of throwing, which guarantees:

  • All violations are collected
  • Multiple failures on multiple nodes are all reported
  • No early exits or hidden errors

Each violation maps to:

  • a stable rule ID
  • a single semantic failure
  • an exact element path

Policy-driven profiles

Validation rules are grouped into profiles, not flags:

  • WCAG_A
  • WCAG_AA
  • WCAG_AAA
  • STRICT_HTML
  • CMS_SAFE

Profiles define what is enforced, not how HTML is written.

No conditionals.
No runtime switches.
Profiles are declarative and explicit.

No runtime surprises

HTMLForge never:

  • auto-injects missing elements
  • fixes invalid markup
  • rewrites your structure
  • relies on browser error recovery

If something is wrong, you get a complete validation report — not broken HTML.

Accessibility by default

HTMLForge enforces real accessibility rules, not heuristics:

  • Accessible names for interactive elements
  • Proper form labeling (implicit and explicit)
  • Landmark and heading structure
  • ARIA role correctness
  • Native HTML semantics preferred over ARIA

Accessibility failures are validation errors, not warnings.

Rendering model

  • Exactly one <html>, <head>, and <body> per document
  • <body> is the root content container
  • No implicit wrapper elements
  • Raw-text and inert elements are isolated correctly
  • Rendering only happens if validation passes

Validation reports (v1.2)

HTMLForge produces structured diagnostics, not strings:

  • Stable rule IDs (e.g. accessibility:img-alt-required)
  • Exact element paths (html > body > form > input)
  • Multiple violations are never deduplicated
  • Machine-readable JSON output
  • Browser-friendly grouped HTML reports

One violation always corresponds to one semantic rule failure.

Security and policy enforcement

HTMLForge enforces strict security-related HTML policies:

  • Inline JavaScript event handlers (onclick, onload, etc.)
  • Profile-aware severity:
    • error in STRICT_HTML
    • warning in CMS-oriented profiles

These rules are enforced at validation time, not runtime.

Documentation

The documentation is intentionally small, focused, and correctness-oriented.

If something is not documented, it is either unstable or out of scope.

Getting started

  • Overview
    What HTMLForge is, what it is not, and when to use it.

  • Core Concepts
    ASTs, validation vs rendering, determinism, and design decisions.

Validation

Examples

Document encoding enforcement

HTMLForge requires an explicit character encoding declaration:

  • <meta charset="utf-8"> is mandatory
  • Missing charset is a validation error
  • HTMLForge does not auto-insert encoding metadata

This ensures deterministic parsing behavior and avoids browser-dependent encoding assumptions.

Appendix: Element Coverage Matrix

This usage example exercises the following HTML element categories:

Category Elements Demonstrated
Document root html, head, body
Metadata title, meta, style, link
Sectioning header, nav, main, section, article, aside, footer
Headings h1, h2
Grouping p, ul, li, figure, figcaption
Phrasing a, span (implicit), text nodes
Embedded img
Forms form, label, input, button
Interactive a, button, input
Global attributes class, id, lang, data-*
Accessibility implicit labels, alt text, landmarks

This matrix reflects real validation coverage, not theoretical support.

Elements not shown here are still supported if present in the registry.

Error handling

HTMLForge never throws during rendering.

Instead:

  • All validation errors are collected
  • Rendering returns a RenderResult
  • You decide how to display, log, or block output

This makes HTMLForge safe for:

  • browsers
  • CMS pipelines
  • static builds
  • CI environments

Installation

composer require golchha21/htmlforge

Requires PHP 8.3+.

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email vardhans@ulhas.net instead of using the issue tracker.

Author

See also the list of contributors who participated in this project.

License

MIT license.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固