Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
486 commits
Select commit Hold shift + click to select a range
0a3bdb6
Exercise WASM head fragment context
sirreal Jun 11, 2026
c5737e2
Allow frames in WASM frameset fragments
sirreal Jun 11, 2026
653de4f
Exercise WASM template fragment context
sirreal Jun 11, 2026
ba1d265
Ignore document starts in WASM integration fragments
sirreal Jun 11, 2026
5773fd1
Exercise WASM table cell fragment contexts
sirreal Jun 11, 2026
11ad2f8
Ignore nested table starts in WASM table fragments
sirreal Jun 11, 2026
fd189f8
Ignore text in WASM colgroup fragments
sirreal Jun 11, 2026
b755132
Ignore row boundaries in WASM tr fragments
sirreal Jun 11, 2026
66b9d17
Ignore section boundaries in WASM tbody fragments
sirreal Jun 11, 2026
71f005d
Ignore table boundaries in WASM caption fragments
sirreal Jun 11, 2026
15e940d
Support raw-text WASM fragments
sirreal Jun 12, 2026
afae5d8
Normalize nulls in raw WASM fragments
sirreal Jun 12, 2026
8cd9733
Allow raw WASM fragment text mutation
sirreal Jun 12, 2026
b0cf187
Preserve foreign fragment context breadcrumbs
sirreal Jun 12, 2026
8779ffc
Expand html5lib fragment context coverage
sirreal Jun 12, 2026
0c89fc4
Restore SVG namespace after fragment breakouts
sirreal Jun 12, 2026
47c17ac
Handle temporary head reopen in WASM parser
sirreal Jun 12, 2026
e8152a9
Document WASM processor constructor options
sirreal Jun 12, 2026
de67e34
Add WASM package build script
sirreal Jun 12, 2026
051c544
Cover WASM helper named exports
sirreal Jun 12, 2026
40bd821
Cover default WASM loader path
sirreal Jun 12, 2026
05a6b03
Cover WASM unsupported exception context
sirreal Jun 12, 2026
f4a3ef5
Build WASM before packing package
sirreal Jun 12, 2026
629e528
Remove unused Rust attribute helper
sirreal Jun 12, 2026
cfabac5
Add combined WASM test script
sirreal Jun 12, 2026
3e57406
Support Response inputs in WASM loader
sirreal Jun 12, 2026
b3283a2
Support promised WASM loader inputs
sirreal Jun 12, 2026
d6f8647
Support PLAINTEXT tokens in WASM processor
sirreal Jun 12, 2026
318866f
Support WASM instance loader inputs
sirreal Jun 12, 2026
39406f5
Support after-frameset comments in WASM parser
sirreal Jun 12, 2026
8b15fd5
Support instantiated WASM loader inputs
sirreal Jun 12, 2026
7a8783d
Support file URL string WASM inputs
sirreal Jun 12, 2026
e66948f
Support Blob WASM loader inputs
sirreal Jun 12, 2026
5ad6186
Cover Request WASM loader inputs
sirreal Jun 12, 2026
95ea25e
Handle frameset text in WASM parser
sirreal Jun 12, 2026
6914df6
Handle trailing frameset noframes comments
sirreal Jun 12, 2026
e6c7a69
Ignore null text before framesets
sirreal Jun 12, 2026
8ec5d9d
Delay after-frameset comments before noframes
sirreal Jun 12, 2026
50e2de8
Consume unclosed raw text at EOF
sirreal Jun 12, 2026
2bf4056
Skip incomplete select breakout tags
sirreal Jun 12, 2026
62a68cf
Consume unclosed textareas at EOF
sirreal Jun 12, 2026
186123b
Ignore incomplete end tags at EOF
sirreal Jun 12, 2026
f582e97
Ignore quoted incomplete start tags at EOF
sirreal Jun 12, 2026
767a07f
Allow foreign starts in table fragments
sirreal Jun 12, 2026
76d4fd9
Recover incomplete full-parser start tags at EOF
sirreal Jun 12, 2026
8aa5a13
Accept instantiated WASM in createHtmlApi
sirreal Jun 12, 2026
a979d3d
Support WASM exports in loadWasm
sirreal Jun 12, 2026
0109969
Document WASM JavaScript loader API
sirreal Jun 12, 2026
1079ab5
Cover WASM JavaScript API exports
sirreal Jun 12, 2026
3f8ac3f
Reject unsupported WASM loader inputs
sirreal Jun 12, 2026
067563e
Preserve foreign attribute fallback casing
sirreal Jun 12, 2026
0fb3286
Declare WASM crate artifact
sirreal Jun 12, 2026
6c3f117
Check WASM type declarations match runtime API
sirreal Jun 12, 2026
4516065
Check WASM processor declarations
sirreal Jun 12, 2026
c19998d
Check WASM support declarations
sirreal Jun 12, 2026
cd588e6
Support detached form closers in WASM parser
sirreal Jun 12, 2026
e605b3c
Test WASM package self-reference exports
sirreal Jun 12, 2026
d0b4637
Test installed WASM package artifact
sirreal Jun 12, 2026
ba71622
Validate WASM runtime exports eagerly
sirreal Jun 12, 2026
c68358d
Check raw WASM ABI exports
sirreal Jun 12, 2026
5c5f1de
Test browser default WASM loading
sirreal Jun 12, 2026
3d3617e
Type raw WASM API exports
sirreal Jun 12, 2026
bdad9ca
Return normalized WASM exports from JS API
sirreal Jun 12, 2026
e2a0c0d
Type exported WASM asset subpath
sirreal Jun 12, 2026
dc48585
Check WASM JS API against PHP surface
sirreal Jun 12, 2026
63fedcb
Check WASM JS constants against PHP values
sirreal Jun 12, 2026
6661fd0
Mark active formatting scopes in WASM parser
sirreal Jun 12, 2026
69e293d
Reject table foster parenting end tags in WASM parser
sirreal Jun 12, 2026
039b3ba
Handle nested NOBR starts in WASM parser
sirreal Jun 12, 2026
2231774
Explain WASM html5lib shell attribute skips
sirreal Jun 12, 2026
fc9625a
Report WASM html5lib unsupported reasons
sirreal Jun 12, 2026
98cfec3
Sample unsupported WASM html5lib cases
sirreal Jun 12, 2026
4399acf
Check WASM JS public properties against PHP
sirreal Jun 12, 2026
22b1b75
Document WASM JavaScript package usage
sirreal Jun 12, 2026
70e4d9a
Verify packaged WASM README content
sirreal Jun 12, 2026
1832841
Check WASM exports against Rust ABI
sirreal Jun 12, 2026
e1037e7
Cover processor bookmark parity in WASM
sirreal Jun 12, 2026
8dba3b8
Check WASM package version parity
sirreal Jun 12, 2026
a3e287e
Check WASM runtime API surface exactly
sirreal Jun 12, 2026
97c67f0
Cover WASM tag processor update parity
sirreal Jun 12, 2026
0711f0d
Add WASM browser smoke test
sirreal Jun 12, 2026
7bee642
Stream WASM loading from browser responses
sirreal Jun 12, 2026
9c213f4
Run WASM browser smoke test without Playwright
sirreal Jun 12, 2026
f5abbb6
Omit trailing incomplete syntax when normalizing
sirreal Jun 12, 2026
70297cd
Report incomplete tokens in WASM tag processor
sirreal Jun 12, 2026
c65648f
Support more nested anchors in WASM processor
sirreal Jun 12, 2026
122d45d
Clear stale WASM tag state accessors
sirreal Jun 12, 2026
20ef634
Clear stale WASM modifiable text
sirreal Jun 12, 2026
72b911c
Gate WASM script content type by token state
sirreal Jun 12, 2026
611361d
Reject stale WASM bookmarks
sirreal Jun 12, 2026
1c8efe2
Match WASM decoder integer coercion
sirreal Jun 12, 2026
b2b7ccc
Match WASM span integer coercion
sirreal Jun 12, 2026
0eae175
Match WASM helper constructor coercion
sirreal Jun 12, 2026
3f2d1d6
Match WASM unsupported exception coercion
sirreal Jun 12, 2026
520dad1
Preserve WASM attribute token values
sirreal Jun 12, 2026
231215f
Reject null WASM integer parameters
sirreal Jun 12, 2026
6246b4c
Describe WASM helper coercion types
sirreal Jun 12, 2026
a43ce1a
Coerce WASM open elements parameters
sirreal Jun 12, 2026
bc581ce
Coerce WASM open elements index
sirreal Jun 12, 2026
b5cc44f
Validate WASM stack token parameters
sirreal Jun 12, 2026
1bda1ad
Coerce WASM tag processor string parameters
sirreal Jun 12, 2026
bc45e5b
Coerce WASM doctype token input
sirreal Jun 12, 2026
27836cd
Coerce WASM normalize input
sirreal Jun 12, 2026
183cc4d
Coerce WASM doctype constructor inputs
sirreal Jun 12, 2026
8792b75
Coerce WASM qualified attribute names
sirreal Jun 12, 2026
ad98c9a
Coerce WASM void tag names
sirreal Jun 12, 2026
3b428a4
Support frameset after hidden input in WASM
sirreal Jun 12, 2026
91495d3
Support frameset after pre-body paragraph in WASM
sirreal Jun 12, 2026
a389653
Coerce WASM decoder string parameters
sirreal Jun 12, 2026
81f10af
Coerce WASM attribute and class parameters
sirreal Jun 12, 2026
4c644fd
Coerce WASM processor next tag names
sirreal Jun 12, 2026
02ca693
Coerce WASM decoder reference offsets
sirreal Jun 12, 2026
4bc6ab0
Validate WASM processor breadcrumbs
sirreal Jun 12, 2026
50e23f9
Declare WASM breadcrumb scalar inputs
sirreal Jun 12, 2026
dbbbcda
Coerce WASM expects closer token input
sirreal Jun 12, 2026
d362458
Coerce WASM bookmark names
sirreal Jun 12, 2026
8f08578
Declare WASM next tag breadcrumb scalars
sirreal Jun 12, 2026
8855ae6
Coerce WASM special tag input fields
sirreal Jun 12, 2026
17c96d4
Align WASM special tag object namespaces
sirreal Jun 12, 2026
529eec7
Declare WASM processor constructor input
sirreal Jun 12, 2026
ccfdbe8
Handle null WASM attribute values
sirreal Jun 12, 2026
c33c8a8
Align WASM decoder case sensitivity input
sirreal Jun 12, 2026
c93b3fa
Align WASM decoder context input
sirreal Jun 12, 2026
db60e75
Declare WASM special tag input broadly
sirreal Jun 12, 2026
f4a5089
Coerce nullable WASM decoder inputs
sirreal Jun 12, 2026
6435e6c
Coerce nullable WASM tag string inputs
sirreal Jun 12, 2026
72bb226
Coerce nullable WASM breadcrumb inputs
sirreal Jun 12, 2026
75800db
Declare WASM next tag class query broadly
sirreal Jun 12, 2026
e8b0559
Declare WASM tag next query fields broadly
sirreal Jun 12, 2026
c21032f
Cast WASM processor match offsets like PHP
sirreal Jun 12, 2026
4795496
Declare WASM processor factory inputs broadly
sirreal Jun 12, 2026
dddb822
Make WASM doctype constructor private
sirreal Jun 12, 2026
c6132bf
Delay WASM scope termination list coercion
sirreal Jun 12, 2026
0df1fcb
Coerce WASM processor bookmarks like PHP interpolation
sirreal Jun 12, 2026
6aa7eb4
Match WASM special tag object casing
sirreal Jun 12, 2026
65b1468
Match WASM expects_closer token type
sirreal Jun 12, 2026
719336b
Default WASM processor constructor to full parser
sirreal Jun 12, 2026
856e005
Default WASM processor scalar constructor args
sirreal Jun 12, 2026
622ecf4
Preserve null WASM qualified attribute names
sirreal Jun 12, 2026
6a30fdf
Match WASM closing tag argument ordering
sirreal Jun 12, 2026
fa501d3
Reject non-finite WASM integer parameters
sirreal Jun 12, 2026
7cef277
Reject overflowing WASM integer parameters
sirreal Jun 12, 2026
ee626c8
Coerce WASM NaN booleans like PHP
sirreal Jun 12, 2026
a730c10
Stringify WASM non-finite numbers like PHP
sirreal Jun 12, 2026
80fa809
Format WASM finite numbers like PHP
sirreal Jun 12, 2026
069d94a
Match WASM attribute prefix scalar handling
sirreal Jun 12, 2026
64c62ab
Stringify WASM safe integers like PHP ints
sirreal Jun 12, 2026
5935d8f
Match WASM class update key coercion
sirreal Jun 12, 2026
708878c
Cover WASM quirks class update keys
sirreal Jun 12, 2026
7bc4313
Defer WASM class updates like PHP
sirreal Jun 12, 2026
4a4fbf7
Filter WASM html5lib tests by input
sirreal Jun 12, 2026
71998a9
Filter WASM html5lib tests by context
sirreal Jun 12, 2026
8c593d8
Cover WASM full comment text
sirreal Jun 12, 2026
12b0af8
Support framesets after ignored shell closers
sirreal Jun 12, 2026
d363694
Ignore void starts before framesets
sirreal Jun 12, 2026
a13c28b
Skip empty foreign nodes before framesets
sirreal Jun 12, 2026
aaf2987
Skip open chains before framesets
sirreal Jun 12, 2026
e5a42a9
Skip NUL-only foreign nodes before framesets
sirreal Jun 12, 2026
81a0d02
Skip frame noise before framesets
sirreal Jun 12, 2026
b9b0b67
Document remaining WASM parser gaps
sirreal Jun 12, 2026
b26f62d
Reconstruct anchors across paragraphs
sirreal Jun 12, 2026
ba3f24b
Track paragraph adoption preclosures
sirreal Jun 12, 2026
bb59d19
Handle nested anchors in paragraphs
sirreal Jun 12, 2026
733eb1e
Preclose anchors before nested block anchors
sirreal Jun 12, 2026
14830a6
Allow marker-scoped nested anchors
sirreal Jun 12, 2026
5253ebe
Preclose anchors before list adoption
sirreal Jun 12, 2026
0abe48d
Reconstruct anchors across special starts
sirreal Jun 12, 2026
eb2c372
Preclose formatting before buttons
sirreal Jun 12, 2026
e428ae5
Scan font adoption before paragraphs
sirreal Jun 12, 2026
df6264f
Preclose formatting ancestors before divs
sirreal Jun 12, 2026
38075dc
Preclose formatting before menus
sirreal Jun 12, 2026
37afa59
Preclose formatting before divs
sirreal Jun 12, 2026
ae4506c
Reconstruct font before metadata
sirreal Jun 12, 2026
12c8fa2
Track nested divs for anchor preclosure
sirreal Jun 12, 2026
419d287
Guard html5lib unsupported count
sirreal Jun 12, 2026
d7292e5
Handle nested nobr formatting reconstruction
sirreal Jun 12, 2026
8c79595
Handle eof nested nobr reconstruction
sirreal Jun 12, 2026
3faa348
Preclose nobr before div reconstruction
sirreal Jun 12, 2026
bf53927
Handle aside formatting preclosure
sirreal Jun 12, 2026
82e1e06
Handle deeper aside formatting preclosure
sirreal Jun 12, 2026
298c04d
Handle paired aside formatting preclosure
sirreal Jun 12, 2026
eeaf94a
Preclose formatting ancestors before paragraphs
sirreal Jun 12, 2026
9989a47
Handle paired paragraph formatting preclosure
sirreal Jun 12, 2026
7659881
Handle deep anchor special-start preclosure
sirreal Jun 12, 2026
177fc44
Expose get_updated_html flush option in WASM types
sirreal Jun 12, 2026
cd5b3cd
Handle cite formatting special-start preclosure
sirreal Jun 12, 2026
c1db93f
Handle italic bold special-start preclosure
sirreal Jun 12, 2026
89d6e28
Handle capped deep anchor reconstruction
sirreal Jun 12, 2026
bcae962
Handle bold paragraph reconstruction
sirreal Jun 12, 2026
714e6bd
Reconstruct font before paragraph italics
sirreal Jun 12, 2026
08585dd
Delay table opener for fostered text
sirreal Jun 12, 2026
2c720b0
Allow hidden input after fostered table text
sirreal Jun 12, 2026
544e3f9
Foster delayed table whitespace before meta
sirreal Jun 12, 2026
7a4b245
Foster foreign content before delayed table
sirreal Jun 12, 2026
c97c2ba
Foster select before delayed table
sirreal Jun 12, 2026
d662eb4
Defer table section openers before fostered content
sirreal Jun 12, 2026
c59e395
Keep comments after fostered table text
sirreal Jun 12, 2026
8b35977
Foster void metadata before delayed table
sirreal Jun 12, 2026
9e66370
Foster title before delayed table
sirreal Jun 12, 2026
91b65a9
Defer row wrappers before fostered table text
sirreal Jun 12, 2026
e69c7a2
Foster div before delayed table
sirreal Jun 12, 2026
84b102e
Defer colgroup before fostered table text
sirreal Jun 12, 2026
dc8c8e8
Split colgroup text around fostered content
sirreal Jun 12, 2026
b73cbd8
Foster non-hidden input before delayed table
sirreal Jun 12, 2026
12d6e3f
Skip ignored html end tag before fostered table text
sirreal Jun 12, 2026
7c223ed
Foster list items before delayed table
sirreal Jun 12, 2026
31ec7cb
Foster paragraphs before delayed table
sirreal Jun 12, 2026
4516e11
Support standalone table fragment anchor
sirreal Jun 12, 2026
3e74c63
Support standalone section fragment anchors
sirreal Jun 12, 2026
ecfff75
Support table fragment anchors before table content
sirreal Jun 12, 2026
a473f94
Handle colgroup fragment anchor before col
sirreal Jun 12, 2026
9e57293
Support fostered paragraph closer before table
sirreal Jun 12, 2026
571978b
Foster presumptuous br before table
sirreal Jun 12, 2026
fc39923
Skip inert table lookahead end tags
sirreal Jun 12, 2026
eeb0c08
Defer table template before fostered content
sirreal Jun 12, 2026
9dd8032
Close template row before fostered div
sirreal Jun 12, 2026
91415e9
Foster plaintext before deferred tables
sirreal Jun 12, 2026
838d3ce
Defer table rawtext children before fostered text
sirreal Jun 12, 2026
91e9f80
Defer table form children before fostered starts
sirreal Jun 12, 2026
2d7696d
Foster table anchors before deferred tables
sirreal Jun 12, 2026
7ebfcc4
Close template table bodies before select
sirreal Jun 12, 2026
b25e82b
Keep select template text out of table foster mode
sirreal Jun 12, 2026
a583448
Defer table col before fostered select
sirreal Jun 12, 2026
3907b70
Defer nested tables in table fragments
sirreal Jun 12, 2026
0d90d48
Defer table whitespace before fostered meta
sirreal Jun 12, 2026
2aeb2ce
Defer table text across fostered cells
sirreal Jun 12, 2026
23c8be2
Defer table whitespace before ignored foster end tags
sirreal Jun 12, 2026
0d014b2
Defer tables before bare cell foster text
sirreal Jun 12, 2026
0a94784
Reconstruct formatting before deferred tables
sirreal Jun 12, 2026
c4bd1bc
Reconstruct font before deferred table foster content
sirreal Jun 12, 2026
131339e
Foster italic formatting before deferred tables
sirreal Jun 12, 2026
0bf5f3f
Break out foreign select tables before fostered formatting
sirreal Jun 12, 2026
f9cefdc
Defer foreign table cells before fostered text
sirreal Jun 12, 2026
4f5baa2
Defer table cell content before fostered anchor text
sirreal Jun 12, 2026
47ef04c
Reconstruct nested fostered anchors around deferred tables
sirreal Jun 12, 2026
52cdff2
Handle nested fostered anchors in templates
sirreal Jun 12, 2026
f46f00b
Close nested fostered anchors before following blocks
sirreal Jun 12, 2026
3f2fd51
Defer table whitespace before fostered row starts
sirreal Jun 12, 2026
de76264
Defer completed rows before fostered starts
sirreal Jun 12, 2026
bf003ac
Tighten WASM html5lib unsupported budget
sirreal Jun 12, 2026
25dec1d
Handle nested anchors around deferred tables
sirreal Jun 12, 2026
4c03a47
Handle fostered DIV adoption before deferred tables
sirreal Jun 12, 2026
35cfb4a
Handle nested NOBR around tables in WASM parser
sirreal Jun 12, 2026
500c6da
Document WASM parser support status
sirreal Jun 12, 2026
98fc329
Support direct fostered content in table fragments
sirreal Jun 12, 2026
7bb1421
Support fostered COLGROUP text in fragments
sirreal Jun 12, 2026
975eee5
Support fostered INPUT starts in table fragments
sirreal Jun 12, 2026
9536421
Defer table fragments through fostered wrappers
sirreal Jun 12, 2026
5cdb18c
Support foreign fostered content in COLGROUP fragments
sirreal Jun 12, 2026
c5c113f
Clarify WASM unsupported diagnostics
sirreal Jun 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ext/html-api-rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/target/
/wasm/dist/
/autom4te.cache/
/build/
/modules/
/.libs/
/Makefile
/Makefile.fragments
/Makefile.objects
/Makefile.global
/acinclude.m4
/aclocal.m4
/config.cache
/config.guess
/config.h
/config.h.in
/config.log
/config.nice
/config.status
/config.sub
/configure
/configure~
/install-sh
/libtool
/ltmain.sh
/missing
/mkinstalldirs
/run-tests.php
/tmp-php.ini
/*.dep
/*.la
/*.lo
7 changes: 7 additions & 0 deletions ext/html-api-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ext/html-api-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "wp-html-api-rust-core"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
name = "wp_html_api_rust_core"
crate-type = ["staticlib", "cdylib"]

[profile.release]
lto = true
codegen-units = 1
panic = "abort"
72 changes: 72 additions & 0 deletions ext/html-api-rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# WordPress HTML API Rust Extension

This directory contains the native Rust core and PHP extension shim for the
incremental Rust implementation of the WordPress HTML API.

Build locally with:

```sh
cd ext/html-api-rust
sh build.sh
```

Smoke-test the built extension with:

```sh
php -d extension="$(pwd)/modules/wp_html_api_rust.so" \
-r 'var_dump(wp_html_api_rust_version(), wp_html_api_rust_scan_next_tag("<p class=\"x\">Hi</p>"));'
```

Build the WebAssembly module and JavaScript API wrapper with:

```sh
cd ext/html-api-rust
npm --prefix wasm run build
npm --prefix wasm run test:all
```

Regenerate the Rust HTML5 named-character-reference table with:

```sh
node scripts/generate-html5-named-character-references.mjs
```

The JavaScript wrapper is an ES module in `wasm/wp-html-api-rust.js`. It directly
exports `loadWasm()`, `createHtmlApi()`, `WP_HTML_Span`,
`WP_HTML_Text_Replacement`, `WP_HTML_Attribute_Token`, `WP_HTML_Token`,
`WP_HTML_Stack_Event`, `WP_HTML_Active_Formatting_Elements`,
`WP_HTML_Open_Elements`, `WP_HTML_Processor_State`,
`WP_HTML_Unsupported_Exception`, and `WP_HTML_Doctype_Info`.

Call `loadWasm()` to instantiate the WASM module and receive the WASM-bound API:
`WP_HTML_Decoder`, `WP_HTML_Tag_Processor`, `WP_HTML_Processor`,
`scanNextTag()`, `version()`, the support classes, and the raw `wasm` exports.
The tag processor methods call the same Rust core used by the PHP extension. The
JavaScript API surface mirrors the public WordPress HTML API classes with
JavaScript naming, including processor factory/static helpers, constants,
bookmark methods, doctype parsing, serialization helpers, and inherited
tag-processor methods.

```js
import { loadWasm } from "./wasm/wp-html-api-rust.js";

const { WP_HTML_Processor } = await loadWasm();
const processor = WP_HTML_Processor.create_fragment("<p>Hello</p>");
processor.next_tag("p");
console.log(processor.get_breadcrumbs());
processor.destroy();
```

`loadWasm()` accepts the default bundled WASM URL, a path or URL string,
`URL`, `Request`, `Response`, `Blob`, `ArrayBuffer`, typed array/DataView,
`WebAssembly.Module`, `WebAssembly.Instance`, raw `WebAssembly.Exports`, or an
instantiated source object returned by `WebAssembly.instantiate()`.

The processor layer adds JavaScript-side open-element stack tracking for HTML
breadcrumbs, breadcrumb queries, void-element handling, namespaces, scoped end
tags, frameset handling, implied closures, foster parenting, and adoption-agency
reconstruction. The html5lib tree-construction harness runs with zero
unsupported cases, aside from the known WordPress duplicate shell-attribute
skips. `WP_HTML_Unsupported_Exception` remains part of the public API for
guarded parser states, such as tentative encoding detection from unsupported
META tags.
12 changes: 12 additions & 0 deletions ext/html-api-rust/build-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu

cd "$(dirname "$0")"

cargo build --target wasm32-unknown-unknown --release --lib

mkdir -p wasm/dist
wasm_file="target/wasm32-unknown-unknown/release/wp_html_api_rust_core.wasm"
cp "$wasm_file" wasm/dist/wp_html_api_rust_core.wasm

echo "WASM build complete: ext/html-api-rust/wasm/dist/wp_html_api_rust_core.wasm"
9 changes: 9 additions & 0 deletions ext/html-api-rust/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu

PHP_CONFIG_BIN="${PHP_CONFIG:-php-config}"

cargo build --release
phpize
./configure --enable-wp-html-api-rust --with-php-config="${PHP_CONFIG_BIN}"
make
13 changes: 13 additions & 0 deletions ext/html-api-rust/config.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PHP_ARG_ENABLE(
[wp-html-api-rust],
[whether to enable the WordPress HTML API Rust extension],
[AS_HELP_STRING([--enable-wp-html-api-rust], [Enable WordPress HTML API Rust extension])],
[no]
)

if test "$PHP_WP_HTML_API_RUST" != "no"; then
PHP_SUBST(WP_HTML_API_RUST_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(wp_html_api_rust_core, $abs_srcdir/target/release, WP_HTML_API_RUST_SHARED_LIBADD)

PHP_NEW_EXTENSION([wp_html_api_rust], [wp_html_api_rust.c], [$ext_shared])
fi
200 changes: 200 additions & 0 deletions ext/html-api-rust/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
dnl This file becomes configure.ac for self-contained extensions.

dnl Include external macro definitions before the AC_INIT to also remove
dnl comments starting with # and empty newlines from the included files.
m4_include([build/ax_check_compile_flag.m4])
m4_include([build/ax_gcc_func_attribute.m4])
m4_include([build/libtool.m4])
m4_include([build/php_cxx_compile_stdcxx.m4])
m4_include([build/php.m4])
m4_include([build/pkg.m4])

AC_PREREQ([2.68])
AC_INIT
AC_CONFIG_SRCDIR([config.m4])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER

PHP_CONFIG_NICE([config.nice])

AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
AC_DEFUN([PHP_EXT_DIR],[""])dnl
AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
AC_DEFUN([PHP_ALWAYS_SHARED],[
ext_output="yes, shared"
ext_shared=yes
test "[$]$1" = "no" && $1=yes
])dnl

PHP_INIT_BUILD_SYSTEM

PKG_PROG_PKG_CONFIG
AC_PROG_CC([cc gcc])
PHP_DETECT_ICC
PHP_DETECT_SUNCC

dnl Support systems with system libraries in e.g. /usr/lib64.
PHP_ARG_WITH([libdir],
[for system library directory],
[AS_HELP_STRING([--with-libdir=NAME],
[Look for libraries in .../NAME rather than .../lib])],
[lib],
[no])

PHP_RUNPATH_SWITCH
PHP_SHLIB_SUFFIX_NAMES

dnl Find php-config script.
PHP_ARG_WITH([php-config],,
[AS_HELP_STRING([--with-php-config=PATH],
[Path to php-config [php-config]])],
[php-config],
[no])

dnl For BC.
PHP_CONFIG=$PHP_PHP_CONFIG
prefix=$($PHP_CONFIG --prefix 2>/dev/null)
phpincludedir=$($PHP_CONFIG --include-dir 2>/dev/null)
INCLUDES=$($PHP_CONFIG --includes 2>/dev/null)
EXTENSION_DIR=$($PHP_CONFIG --extension-dir 2>/dev/null)
PHP_EXECUTABLE=$($PHP_CONFIG --php-binary 2>/dev/null)

AS_VAR_IF([prefix],,
[AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])])

AC_MSG_CHECKING([for PHP prefix])
AC_MSG_RESULT([$prefix])
AC_MSG_CHECKING([for PHP includes])
AC_MSG_RESULT([$INCLUDES])
AC_MSG_CHECKING([for PHP extension directory])
AC_MSG_RESULT([$EXTENSION_DIR])
AC_MSG_CHECKING([for PHP installed headers prefix])
AC_MSG_RESULT([$phpincludedir])

dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS.
AC_MSG_CHECKING([if debugging is enabled])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP([php_debug_is_enabled], [
#include <main/php_config.h>
#if ZEND_DEBUG
php_debug_is_enabled
#endif
],
[PHP_DEBUG=yes],
[PHP_DEBUG=no])
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_DEBUG])

AC_MSG_CHECKING([if PHP is built with thread safety (ZTS)])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$phpincludedir"
AC_EGREP_CPP([php_zts_is_enabled], [
#include <main/php_config.h>
#ifdef ZTS
php_zts_is_enabled
#endif
],
[PHP_THREAD_SAFETY=yes],
[PHP_THREAD_SAFETY=no])
CPPFLAGS=$old_CPPFLAGS
AC_MSG_RESULT([$PHP_THREAD_SAFETY])

dnl Discard optimization flags when debugging is enabled.
AS_VAR_IF([PHP_DEBUG], [yes], [
PHP_DEBUG=1
ZEND_DEBUG=yes
PHP_REMOVE_OPTIMIZATION_FLAGS
dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0"
CXXFLAGS="$CXXFLAGS -g -O0"
fi
if test "$SUNCC" = "yes"; then
if test -n "$auto_cflags"; then
CFLAGS="-g"
CXXFLAGS="-g"
else
CFLAGS="$CFLAGS -g"
CXXFLAGS="$CFLAGS -g"
fi
fi
], [
PHP_DEBUG=0
ZEND_DEBUG=no
])

dnl Always shared.
PHP_BUILD_SHARED

PHP_HELP_SEPARATOR([Extension:])
PHP_CONFIGURE_PART([Configuring extension])

sinclude(config.m4)

enable_static=no
enable_shared=yes

PHP_HELP_SEPARATOR([Libtool:])
PHP_CONFIGURE_PART([Configuring libtool])

dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by
dnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++
dnl compiler.
AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
undefine([AC_PROG_CXX])
AC_DEFUN([AC_PROG_CXX], [])
undefine([AC_PROG_CXXCPP])
AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
])
AC_PROG_LIBTOOL

all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
install_targets="install-modules install-headers"
CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
CFLAGS_CLEAN='$(CFLAGS) -D_GNU_SOURCE'
CXXFLAGS_CLEAN='$(CXXFLAGS)'

AS_VAR_IF([prefix], [NONE], [prefix=/usr/local])
AS_VAR_IF([exec_prefix], [NONE], [exec_prefix='$(prefix)'])

AS_VAR_IF([cross_compiling], [yes],
[AC_CHECK_PROGS([BUILD_CC], [gcc clang c99 c89 cc cl], [none])
AC_MSG_CHECKING([for native build C compiler])
AC_MSG_RESULT([$BUILD_CC])],
[BUILD_CC=$CC])

PHP_SUBST([PHP_MODULES])
PHP_SUBST([PHP_ZEND_EX])
PHP_SUBST([all_targets])
PHP_SUBST([install_targets])
PHP_SUBST([prefix])
PHP_SUBST([exec_prefix])
PHP_SUBST([libdir])
PHP_SUBST([phpincludedir])
PHP_SUBST([CC])
PHP_SUBST([CFLAGS])
PHP_SUBST([CFLAGS_CLEAN])
PHP_SUBST([CPP])
PHP_SUBST([CPPFLAGS])
PHP_SUBST([CXX])
PHP_SUBST([CXXFLAGS])
PHP_SUBST([CXXFLAGS_CLEAN])
PHP_SUBST([EXTENSION_DIR])
PHP_SUBST([PHP_EXECUTABLE])
PHP_SUBST([EXTRA_LDFLAGS])
PHP_SUBST([EXTRA_LIBS])
PHP_SUBST([INCLUDES])
PHP_SUBST([LDFLAGS])
PHP_SUBST([LIBTOOL])
PHP_SUBST([SHELL])
PHP_SUBST([INSTALL_HEADERS])
PHP_SUBST([BUILD_CC])

PHP_CONFIGURE_PART([Generating files])

AC_CONFIG_HEADERS([config.h])

AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])])

AC_OUTPUT
9 changes: 9 additions & 0 deletions ext/html-api-rust/php_wp_html_api_rust.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef PHP_WP_HTML_API_RUST_H
#define PHP_WP_HTML_API_RUST_H

extern zend_module_entry wp_html_api_rust_module_entry;
#define phpext_wp_html_api_rust_ptr &wp_html_api_rust_module_entry

#define PHP_WP_HTML_API_RUST_VERSION "0.1.0"

#endif
Loading
Loading