code wiki / _hdl_build / nx_apistack_migrate.nx
nx_apistack_migrate.nx source
↩ module page · 17 lines · 989 B
1// nx_apistack_migrate.nx -- CAP-API-MIGRATE: wire /api/migrate (was 501) = ingest external HTML into a sovereign
2// .site blueprint. Strips HTML tags and sanitizes the '|' field delimiter so the result is a clean, delimiter-safe
3// plain-text blueprint the provisioner can consume. Pure + deterministic. license_tier: ORIGINAL
4import "nx_syscalls.nx"
5
6// HTML -> .site-safe plain text: drop everything inside <...>, drop the '|' delimiter, keep the rest. Returns length.
7func mg_html_to_blueprint(html: *u8, n: i64, out: *u8) -> i64 {
8 var o: i64 = 0; var in_tag: i64 = 0; var i: i64 = 0
9 while i < n {
10 let c: i64 = (html[i] as i64) & 0xff
11 if c == 60 { in_tag = 1 } // '<' -> enter tag
12 else { if c == 62 { in_tag = 0 } // '>' -> leave tag
13 else { if in_tag == 0 { if c != 124 { out[o] = c as u8; o = o + 1 } } } } // outside tags, keep (drop '|')
14 i = i + 1
15 }
16 return o
17}