Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/server/tr.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / server / tr.om` 1022 lines ยท 21053 bytes Raw Blame History 1 note forged server/tr.om (TranslateConnector, 2026-11-11): translation hints on every HTML page. 2 note Readers translate pages with their own browser or tool; forged translates nothing and stores no 3 note translation. This unit only marks what must be copied exactly, so a translator leaves it alone: 4 note 1. every opening code, pre, kbd and samp tag, and every tag whose class names the token mono, 5 note files, file, dir, crumbs (paths), brand (the Interplane name) or rname (a project name in a 6 note list), gets translate="no" (unless it already has a translate attribute); 7 note 2. in text outside tags, a word that is a hex hash (7 or more of 0-9 a-f, at least one digit) or 8 note a Radicle id (z then 28 or more base58 letters with a digit and a capital) is wrapped in 9 note ...; "rad:" or "did:key:" before an id stays outside the span. 10 note Text inside title, textarea, option, script and style is copied unchanged. 11 note fsend0 (server/main.om) runs ftrrun twice over each part of the page (head, fragment, foot): mode 0 counts the 12 note bytes for Content-Length, mode 1 sends them through a 32 KiB chunk. Both passes run the same 13 note code, so the length always matches the body. Gate: server/tests/translate.sh. 14 note ftrq: 0 chunk fill, 1 bytes counted, 2 mode (0 count, 1 send), 3 raw element open (1 or 0) 15 global ftrq ulong 4 16 note ftrer: the first negative hput result of a send pass, else 0 17 global ftrer long 1 18 text tftrno " translate=\"no\"" 19 text tftrsp "" 20 text tftrse "" 21 text tftrat " translate=" 22 text tftrcl "class=\"" 23 text tftrcod "code" 24 text tftrpre "pre" 25 text tftrkbd "kbd" 26 text tftrsmp "samp" 27 text tftrmon "mono" 28 text tftrfil "files" 29 text tftrbrd "brand" 30 text tftrrnm "rname" 31 text tftrcrm "crumbs" 32 text tftrfle "file" 33 text tftrdir "dir" 34 text tftrtit "title" 35 text tftrtxa "textarea" 36 text tftropt "option" 37 text tftrscr "script" 38 text tftrsty "style" 39 text tftrcm "-->" 40 fn ftrfl cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 n ulong to void 41 r = hput cs io view part ch 0 n 42 if lt r 0 43 if eq get ftrer 0 0 44 put ftrer 0 r 45 end 46 end 47 end 48 fn ftrb cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 b uchar to void 49 put ftrq 1 add get ftrq 1 1 50 if eq get ftrq 2 0 51 ret 52 end 53 p = get ftrq 0 54 put ch p b 55 p = add p 1 56 if eq p 32768 57 ftrfl cs io ch p 58 p = ulong 0 59 end 60 put ftrq 0 p 61 end 62 note ftrcp: emit fob[a, e) 63 fn ftrcp cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 a ulong e ulong to void 64 k = a 65 while lt k e bound `8388608` 66 ftrb cs io ch get fob k 67 k = add k 1 68 end 69 end 70 fn ftrt cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 s view uchar * to void 71 for k ulong len s bound 4096 72 ftrb cs io ch get s k 73 end 74 end 75 fn ftrdig c uchar to bool 76 ret and ge c 48 le c 57 77 end 78 fn ftrlow c uchar to bool 79 ret and ge c 97 le c 122 80 end 81 fn ftrup c uchar to bool 82 ret and ge c 65 le c 90 83 end 84 fn ftralnum c uchar to bool 85 ret or ftrdig c or ftrlow c ftrup c 86 end 87 fn ftrhex c uchar to bool 88 ret or ftrdig c and ge c 97 le c 102 89 end 90 note base58: letters and digits except 0 O I l 91 fn ftrb58 c uchar to bool 92 x = or or eq c 48 eq c 79 or eq c 73 eq c 108 93 ret and ftralnum c not x 94 end 95 note ftrat: fob[a, a + len s) equals s, inside fob[0, e) 96 fn ftrat a ulong e ulong s view uchar * to bool 97 n = len s 98 if gt add a n e 99 ret false 100 end 101 for k ulong n bound 4096 102 if ne get fob add a k get s k 103 ret false 104 end 105 end 106 ret true 107 end 108 note ftrfind: first index in [a, e) where s starts and ends before e, else e 109 fn ftrfind a ulong e ulong s view uchar * to ulong 110 k = a 111 while lt k e bound `8388608` 112 if ftrat k e s 113 ret k 114 end 115 k = add k 1 116 end 117 ret e 118 end 119 note ftrnm: fob[a, e) is exactly s 120 fn ftrnm a ulong e ulong s view uchar * to bool 121 if ne sub e a len s 122 ret false 123 end 124 ret ftrat a e s 125 end 126 note ftrcls: the tag fob[a, e) has class="..." with a token that must stay exact 127 fn ftrcls a ulong e ulong to bool 128 c = ftrfind a e tftrcl 129 if ge c e 130 ret false 131 end 132 k = add c 7 133 s = k 134 while lt k e bound `8388608` 135 b = get fob k 136 if or eq b 34 eq b 32 137 if ftrnm s k tftrcrm 138 ret true 139 end 140 if ftrnm s k tftrfle 141 ret true 142 end 143 if ftrnm s k tftrdir 144 ret true 145 end 146 if or or ftrnm s k tftrmon ftrnm s k tftrfil or ftrnm s k tftrbrd ftrnm s k tftrrnm 147 ret true 148 end 149 if eq b 34 150 ret false 151 end 152 s = add k 1 153 end 154 k = add k 1 155 end 156 ret false 157 end 158 note ftrnotr: the opening tag named fob[a, n), ending at e, gets translate="no" 159 fn ftrnotr a ulong n ulong e ulong to bool 160 if lt ftrfind n e tftrat e 161 ret false 162 end 163 c = or or ftrnm a n tftrcod ftrnm a n tftrpre or ftrnm a n tftrkbd ftrnm a n tftrsmp 164 ret or c ftrcls n e 165 end 166 fn ftrraw a ulong n ulong to bool 167 c = or or ftrnm a n tftrtit ftrnm a n tftrtxa or ftrnm a n tftropt ftrnm a n tftrscr 168 ret or c ftrnm a n tftrsty 169 end 170 note ftrcmt: fob[j] starts "!--" (j is the byte after '<') 171 fn ftrcmt j ulong l ulong to bool 172 if ge add j 2 l 173 ret false 174 end 175 if ne get fob j 33 176 ret false 177 end 178 if ne get fob add j 1 45 179 ret false 180 end 181 ret eq get fob add j 2 45 182 end 183 note ftrtend: the index after the tag that starts at fob[i] = '<': a comment ends after "-->", any 184 note other tag after '>'; l when it does not end before l 185 fn ftrtend i ulong l ulong to ulong 186 j = add i 1 187 if ge j l 188 ret l 189 end 190 if ftrcmt j l 191 e = ftrfind add j 3 l tftrcm 192 ret hmin l add e 3 193 end 194 e = j 195 while lt e l bound `8388608` 196 if eq get fob e 62 197 ret add e 1 198 end 199 e = add e 1 200 end 201 ret l 202 end 203 note ftrnend: the end of the tag name that starts at a (letters and digits) 204 fn ftrnend a ulong e ulong to ulong 205 n = a 206 while lt n e bound `8388608` 207 if not ftralnum get fob n 208 ret n 209 end 210 n = add n 1 211 end 212 ret n 213 end 214 note ftrtag: fob[i] is '<'; emit the tag and return the index after it. A comment, a declaration, 215 note a closing tag or a tag cut by l is copied as it is. 216 fn ftrtag cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 i ulong l ulong to ulong 217 e = ftrtend i l 218 j = add i 1 219 if or ge j e ne get fob sub e 1 62 220 ftrcp cs io ch i e 221 ret e 222 end 223 if eq get fob j 47 224 if ftrraw add j 1 ftrnend add j 1 e 225 put ftrq 3 0 226 end 227 ftrcp cs io ch i e 228 ret e 229 end 230 n = ftrnend j e 231 if or eq n j ftrcmt j l 232 ftrcp cs io ch i e 233 ret e 234 end 235 if ftrraw j n 236 put ftrq 3 1 237 end 238 ftrcp cs io ch i n 239 if ftrnotr j n e 240 ftrt cs io ch tftrno 241 end 242 ftrcp cs io ch n e 243 ret e 244 end 245 fn ftrwc c uchar to bool 246 ret ftralnum c 247 end 248 note ftrid: the word fob[s, e) is a hash or a Radicle id 249 fn ftrid s ulong e ulong to bool 250 a = s 251 n = sub e a 252 if lt n 7 253 ret false 254 end 255 hx = true 256 dg = false 257 b58 = true 258 up = false 259 k = a 260 while lt k e bound `8388608` 261 c = get fob k 262 if not ftrhex c 263 hx = false 264 end 265 if not ftrb58 c 266 b58 = false 267 end 268 if ftrdig c 269 dg = true 270 end 271 if ftrup c 272 up = true 273 end 274 k = add k 1 275 end 276 if and hx dg 277 ret true 278 end 279 if ne get fob a 122 280 ret false 281 end 282 ok = and b58 ge n 29 283 ret and ok and dg up 284 end 285 note ftrtxt: emit the text from fob[i] up to the next '<' (or l); return where it stopped 286 fn ftrtxt cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 i ulong l ulong to ulong 287 k = i 288 while lt k l bound `8388608` 289 c = get fob k 290 if eq c 60 291 ret k 292 end 293 if not ftrwc c 294 ftrb cs io ch c 295 k = add k 1 296 continue 297 end 298 s = k 299 while lt k l bound `8388608` 300 if not ftrwc get fob k 301 break 302 end 303 k = add k 1 304 end 305 e = k 306 while gt e s bound `8388608` 307 if ne get fob sub e 1 58 308 break 309 end 310 e = sub e 1 311 end 312 if and eq get ftrq 3 0 ftrid s e 313 ftrt cs io ch tftrsp 314 ftrcp cs io ch s e 315 ftrt cs io ch tftrse 316 ftrcp cs io ch e k 317 else 318 ftrcp cs io ch s k 319 end 320 end 321 ret k 322 end 323 note ftrrun: mode 0 returns the byte count of the marked range fob[a, e); mode 1 sends it and 324 note returns 0 or the first negative hput result 325 fn ftrrun cs edit ulong 320 io edit uchar 131072 a ulong e ulong mode ulong to long 326 ch = new uchar 32768 0 327 put ftrq 0 0 328 put ftrq 1 0 329 put ftrq 2 mode 330 put ftrq 3 0 331 put ftrer 0 0 332 i = a 333 while lt i e bound `8388608` 334 if eq get fob i 60 335 i = ftrtag cs io ch i e 336 else 337 i = ftrtxt cs io ch i e 338 end 339 end 340 if eq mode 0 341 ret long get ftrq 1 342 end 343 if gt get ftrq 0 0 344 ftrfl cs io ch get ftrq 0 345 end 346 ret get ftrer 0 347 end 348 note ---- plain-text rendering: any HTML page with the query format=text (docs/API.md). The page's 349 note own content (no site header or footer) as text for reading tools and agents that translate it 350 note themselves. Inline code and the hashes and ids found above are in backticks, pre blocks in ``` 351 note fences, a link's target follows its text in <...>; nothing is translated or stored here. 352 note ftxs: 0 last byte, 1 pre depth, 2 pending space, 3 link start, 4 skipped element depth, 353 note 5 newlines in a row, 6 code depth, 7 link end, 8 end of the tag ftxel acts on, 9 inside a 354 note span of class mono (sent as inline code) 355 global ftxs ulong 10 356 global ftxcrm ulong 1 357 note ftxfil: 0 outside a files table, 1 inside it between cells, 2 inside one of its cells; 358 note ftxfsp: one space owed before the next byte of a files-table cell (a new cell or a link target) 359 global ftxfil ulong 1 360 global ftxfsp ulong 1 361 text tftxct "text/plain; charset=utf-8" 362 text tftxfmt "format" 363 text tftxval "text" 364 text tftxpre "Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.\nPage: " 365 text tftxfen "```" 366 text tftxhr "href=\"" 367 text tftxamp "&" 368 text tftxa "a" 369 text tftxbr "br" 370 text tftxli "li" 371 text tftxtd "td" 372 text tftxth "th" 373 text tftxsvg "svg" 374 text tftxspan "span" 375 text tftxp "p" 376 text tftxdiv "div" 377 text tftxtr "tr" 378 text tftxsec "section" 379 text tftxart "article" 380 text tftxul "ul" 381 text tftxol "ol" 382 text tftxdl "dl" 383 text tftxdt "dt" 384 text tftxdd "dd" 385 text tftxtab "table" 386 text tftxbq "blockquote" 387 text tftxhrt "hr" 388 text tftxmain "main" 389 text tftxhead "header" 390 text tftxfoot "footer" 391 text tftxnav "nav" 392 text tftxfrm "form" 393 text tftxent1 "amp" 394 text tftxent2 "lt" 395 text tftxent3 "gt" 396 text tftxent4 "quot" 397 text tftxent5 "apos" 398 text tftxent6 "nbsp" 399 text tftxent7 "middot" 400 text tftxent8 "trade" 401 text tftxent9 "mdash" 402 text tftxen10 "ndash" 403 text tftxen11 "hellip" 404 text tftxen12 "rarr" 405 text tftxen13 "larr" 406 text tftxen14 "copy" 407 text tftxen15 "times" 408 note ftxwant: the query names format=text 409 fn ftxwant to bool 410 n = fqget tftxfmt 411 if ne n long len tftxval 412 ret false 413 end 414 for k ulong len tftxval 415 if ne get fval k get tftxval k 416 ret false 417 end 418 end 419 ret true 420 end 421 fn ftxws c uchar to bool 422 ret or or eq c 32 eq c 9 or eq c 10 eq c 13 423 end 424 note ftxraw: emit c as it is (pre text, the page line, fences) 425 fn ftxraw cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 c uchar to void 426 if eq c 10 427 put ftxs 5 add get ftxs 5 1 428 else 429 put ftxs 5 0 430 end 431 put ftxs 0 ulong c 432 ftrb cs io ch c 433 end 434 note ftxo: emit c outside pre; no newline before the first text, at most one empty line 435 fn ftxo cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 c uchar to void 436 if eq c 10 437 if or eq get ftxs 0 0 ge get ftxs 5 2 438 ret 439 end 440 end 441 ftxraw cs io ch c 442 end 443 note ftxch: one text byte; outside pre a run of white space is one space, none after a newline 444 fn ftxch cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 c uchar to void 445 if ne get ftxs 1 0 446 if eq get ftxfil 0 1 447 ret 448 end 449 if ne get ftxfsp 0 0 450 put ftxfsp 0 0 451 ftxraw cs io ch 32 452 end 453 ftxraw cs io ch c 454 ret 455 end 456 if ftxws c 457 put ftxs 2 1 458 ret 459 end 460 if ne get ftxs 2 0 461 put ftxs 2 0 462 b = get ftxs 0 463 if and ne b 0 and ne b 10 ne b 32 464 ftxo cs io ch 32 465 end 466 end 467 ftxo cs io ch c 468 end 469 fn ftxnl cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 to void 470 put ftxs 2 0 471 if ne get ftxs 1 0 472 ftxraw cs io ch 10 473 ret 474 end 475 ftxo cs io ch 10 476 end 477 fn ftxrt cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 s view uchar * to void 478 for k ulong len s bound 4096 479 ftxraw cs io ch get s k 480 end 481 end 482 fn ftxct cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 s view uchar * to void 483 for k ulong len s bound 4096 484 ftxch cs io ch get s k 485 end 486 end 487 note ftxcps: the text bytes fob[a, e) 488 fn ftxcps cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 a ulong e ulong to void 489 k = a 490 while lt k e bound `8388608` 491 ftxch cs io ch get fob k 492 k = add k 1 493 end 494 end 495 note ftxu8: code point v as UTF-8 496 fn ftxu8 cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 v ulong to void 497 if lt v 128 498 ftxch cs io ch uchar v 499 ret 500 end 501 if lt v 2048 502 ftxch cs io ch uchar or 192 shr v 6 503 ftxch cs io ch uchar or 128 and v 63 504 ret 505 end 506 if lt v 65536 507 ftxch cs io ch uchar or 224 shr v 12 508 ftxch cs io ch uchar or 128 and shr v 6 63 509 ftxch cs io ch uchar or 128 and v 63 510 ret 511 end 512 ftxch cs io ch uchar or 240 shr v 18 513 ftxch cs io ch uchar or 128 and shr v 12 63 514 ftxch cs io ch uchar or 128 and shr v 6 63 515 ftxch cs io ch uchar or 128 and v 63 516 end 517 note ftxnum: the number of the entity name fob[a, e) after '#' (decimal, or x then hex); 0 when it 518 note is not one 519 fn ftxnum a ulong e ulong to ulong 520 k = a 521 hx = false 522 if lt k e 523 if or eq get fob k 120 eq get fob k 88 524 hx = true 525 k = add k 1 526 end 527 end 528 if ge k e 529 ret 0 530 end 531 v = ulong 0 532 while lt k e bound `8388608` 533 c = get fob k 534 d = ulong 99 535 if ftrdig c 536 d = sub ulong c 48 537 end 538 if hx 539 if and ge c 97 le c 102 540 d = sub ulong c 87 541 end 542 if and ge c 65 le c 70 543 d = sub ulong c 55 544 end 545 end 546 b = ulong 10 547 if hx 548 b = 16 549 end 550 if ge d b 551 ret 0 552 end 553 v = add mul v b d 554 if gt v `1114111` 555 ret 0 556 end 557 k = add k 1 558 end 559 ret v 560 end 561 note ftxnam: the code point of a named entity fob[a, e); 0 when not known 562 fn ftxnam a ulong e ulong to ulong 563 if ftrnm a e tftxent1 564 ret 38 565 end 566 if ftrnm a e tftxent2 567 ret 60 568 end 569 if ftrnm a e tftxent3 570 ret 62 571 end 572 if ftrnm a e tftxent4 573 ret 34 574 end 575 if ftrnm a e tftxent5 576 ret 39 577 end 578 if ftrnm a e tftxent6 579 ret 32 580 end 581 if ftrnm a e tftxent7 582 ret 183 583 end 584 if ftrnm a e tftxent8 585 ret 8482 586 end 587 if ftrnm a e tftxent9 588 ret 8212 589 end 590 if ftrnm a e tftxen10 591 ret 8211 592 end 593 if ftrnm a e tftxen11 594 ret 8230 595 end 596 if ftrnm a e tftxen12 597 ret 8594 598 end 599 if ftrnm a e tftxen13 600 ret 8592 601 end 602 if ftrnm a e tftxen14 603 ret 169 604 end 605 if ftrnm a e tftxen15 606 ret 215 607 end 608 ret 0 609 end 610 note ftxent: fob[k] is '&'; emit the character and return the index after the entity. An entity 611 note that is not known is text: '&' alone is emitted and the rest follows as text. 612 fn ftxent cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 k ulong l ulong to ulong 613 m = hmin l add k 34 614 s = add k 1 615 while lt s m bound 64 616 if eq get fob s 59 617 break 618 end 619 s = add s 1 620 end 621 if ge s m 622 ftxch cs io ch 38 623 ret add k 1 624 end 625 v = ulong 0 626 if and lt add k 1 s eq get fob add k 1 35 627 v = ftxnum add k 2 s 628 else 629 v = ftxnam add k 1 s 630 end 631 if eq v 0 632 ftxch cs io ch 38 633 ret add k 1 634 end 635 ftxu8 cs io ch v 636 ret add s 1 637 end 638 note ftxlink: the link target fob[a, e) after its text, & read as & 639 fn ftxlink cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 a ulong e ulong to void 640 if ge a e 641 ret 642 end 643 if eq get fob a 35 644 ret 645 end 646 put ftxs 2 1 647 if ne get ftxfil 0 0 648 put ftxfsp 0 1 649 end 650 ftxch cs io ch 60 651 k = a 652 while lt k e bound `8388608` 653 if ftrat k e tftxamp 654 ftxch cs io ch 38 655 k = add k 5 656 else 657 ftxch cs io ch get fob k 658 k = add k 1 659 end 660 end 661 ftxo cs io ch 62 662 put ftxs 2 1 663 end 664 fn ftxblk a ulong n ulong to bool 665 c = or or ftrnm a n tftxp ftrnm a n tftxdiv or ftrnm a n tftxtr ftrnm a n tftxsec 666 c = or c or or ftrnm a n tftxart ftrnm a n tftxul or ftrnm a n tftxol ftrnm a n tftxdl 667 c = or c or or ftrnm a n tftxdt ftrnm a n tftxdd or ftrnm a n tftxtab ftrnm a n tftxbq 668 c = or c or or ftrnm a n tftxhrt ftrnm a n tftxmain or ftrnm a n tftxhead ftrnm a n tftxfoot 669 ret or c or ftrnm a n tftxnav ftrnm a n tftxfrm 670 end 671 note ftxhn: 1..6 for h1..h6, else 0 672 fn ftxhn a ulong n ulong to ulong 673 if ne sub n a 2 674 ret 0 675 end 676 if ne get fob a 104 677 ret 0 678 end 679 c = get fob add a 1 680 if and ge c 49 le c 54 681 ret sub ulong c 48 682 end 683 ret 0 684 end 685 note ftxel: the element named fob[a, n), its tag ending at ftxs[8], cl = closing tag 686 fn ftxel cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 a ulong n ulong cl bool to void 687 sk = or or ftrnm a n tftrscr ftrnm a n tftrsty or ftrnm a n tftrtit ftrnm a n tftxsvg 688 if sk 689 if cl 690 if gt get ftxs 4 0 691 put ftxs 4 sub get ftxs 4 1 692 end 693 else 694 put ftxs 4 add get ftxs 4 1 695 end 696 ret 697 end 698 if ne get ftxs 4 0 699 ret 700 end 701 if ftrnm a n tftrpre 702 ftxpre cs io ch cl 703 ret 704 end 705 if ftrnm a n tftrcod 706 ftxcod cs io ch cl 707 ret 708 end 709 if ftrnm a n tftxbr 710 ftxnl cs io ch 711 ret 712 end 713 if ftrnm a n tftxspan 714 ftxmono cs io ch n cl 715 ret 716 end 717 if ftrnm a n tftxa 718 ftxa cs io ch n get ftxs 8 cl 719 ret 720 end 721 hn = ftxhn a n 722 if gt hn 0 723 ftxnl cs io ch 724 ftxnl cs io ch 725 if not cl 726 for k ulong hn bound 6 727 ftxch cs io ch 35 728 end 729 put ftxs 2 1 730 end 731 ret 732 end 733 if ftrnm a n tftxli 734 ftxnl cs io ch 735 if not cl 736 ftxch cs io ch 45 737 put ftxs 2 1 738 end 739 ret 740 end 741 if ne get ftxfil 0 0 742 if or ftrnm a n tftxtd ftrnm a n tftxth 743 put ftxfsp 0 0 744 if cl 745 put ftxfil 0 1 746 else 747 put ftxfil 0 2 748 if ne get ftxs 0 10 749 put ftxfsp 0 1 750 end 751 end 752 ret 753 end 754 if ftrnm a n tftxtr 755 put ftxfsp 0 0 756 put ftxfil 0 1 757 if ne get ftxs 0 10 758 ftxraw cs io ch 10 759 end 760 ret 761 end 762 end 763 if or ftrnm a n tftxtd ftrnm a n tftxth 764 put ftxs 2 1 765 ret 766 end 767 if ftrnm a n tftxp 768 if cl 769 if ne get ftxcrm 0 0 770 put ftxcrm 0 0 771 ftxcod cs io ch true 772 ftxnl cs io ch 773 ret 774 end 775 else 776 if ftxhas n tftrcrm 777 ftxnl cs io ch 778 ftxcod cs io ch false 779 put ftxcrm 0 1 780 ret 781 end 782 end 783 end 784 if ftrnm a n tftxtab 785 if cl 786 if ne get ftxfil 0 0 787 put ftxfil 0 0 788 ftxpre cs io ch true 789 ret 790 end 791 else 792 if ftxhas n tftrfil 793 ftxpre cs io ch false 794 put ftxfil 0 1 795 ret 796 end 797 end 798 end 799 if ftxblk a n 800 ftxnl cs io ch 801 end 802 end 803 note ftxhas: the open tag ending at ftxs[8], name ending at n, has class token tok 804 fn ftxhas n ulong tok view uchar * to bool 805 e = get ftxs 8 806 c = ftrfind n e tftrcl 807 if ge c e 808 ret false 809 end 810 k = add c 7 811 s = k 812 while lt k e bound `8388608` 813 b = get fob k 814 if or eq b 34 eq b 32 815 if ftrnm s k tok 816 ret true 817 end 818 if eq b 34 819 ret false 820 end 821 s = add k 1 822 end 823 k = add k 1 824 end 825 ret false 826 end 827 note ftxmono: a span whose class names mono (a command, an id) is inline code in the text form 828 fn ftxmono cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 n ulong cl bool to void 829 if cl 830 if ne get ftxs 9 0 831 put ftxs 9 0 832 ftxcod cs io ch true 833 end 834 ret 835 end 836 if ne get ftxs 9 0 837 ret 838 end 839 if ftrcls n get ftxs 8 840 put ftxs 9 1 841 ftxcod cs io ch false 842 end 843 end 844 fn ftxpre cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 cl bool to void 845 if cl 846 if gt get ftxs 1 0 847 put ftxs 1 sub get ftxs 1 1 848 end 849 if ne get ftxs 0 10 850 ftxraw cs io ch 10 851 end 852 ftxrt cs io ch tftxfen 853 ftxraw cs io ch 10 854 ret 855 end 856 ftxnl cs io ch 857 if ne get ftxs 0 10 858 ftxraw cs io ch 10 859 end 860 ftxrt cs io ch tftxfen 861 ftxraw cs io ch 10 862 put ftxs 1 add get ftxs 1 1 863 end 864 fn ftxcod cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 cl bool to void 865 if ne get ftxs 1 0 866 ret 867 end 868 if cl 869 if gt get ftxs 6 0 870 put ftxs 6 sub get ftxs 6 1 871 ftxo cs io ch 96 872 end 873 ret 874 end 875 ftxch cs io ch 96 876 put ftxs 6 add get ftxs 6 1 877 end 878 note ftxa: an opening a keeps where its href value is; the closing a emits it 879 fn ftxa cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 n ulong e ulong cl bool to void 880 if cl 881 ftxlink cs io ch get ftxs 3 get ftxs 7 882 put ftxs 3 0 883 put ftxs 7 0 884 ret 885 end 886 put ftxs 3 0 887 put ftxs 7 0 888 h = ftrfind n e tftxhr 889 if ge h e 890 ret 891 end 892 p = add h 6 893 q = p 894 while lt q e bound `8388608` 895 if eq get fob q 34 896 break 897 end 898 q = add q 1 899 end 900 put ftxs 3 p 901 put ftxs 7 q 902 end 903 note ftxtag: fob[i] is '<'; act on the element and return the index after the tag 904 fn ftxtag cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 i ulong l ulong to ulong 905 e = ftrtend i l 906 j = add i 1 907 if or ge j e ne get fob sub e 1 62 908 ret e 909 end 910 if ftrcmt j l 911 ret e 912 end 913 cl = eq get fob j 47 914 a = j 915 if cl 916 a = add j 1 917 end 918 n = ftrnend a e 919 if gt n a 920 put ftxs 8 e 921 ftxel cs io ch a n cl 922 end 923 ret e 924 end 925 note ftxtxt: the text from fob[i] to the next '<' (or l); hashes and ids outside code in backticks 926 fn ftxtxt cs edit ulong 320 io edit uchar 131072 ch edit uchar 32768 i ulong l ulong to ulong 927 k = i 928 while lt k l bound `8388608` 929 c = get fob k 930 if eq c 60 931 ret k 932 end 933 if ne get ftxs 4 0 934 k = add k 1 935 continue 936 end 937 if eq c 38 938 k = ftxent cs io ch k l 939 continue 940 end 941 if not ftrwc c 942 ftxch cs io ch c 943 k = add k 1 944 continue 945 end 946 s = k 947 while lt k l bound `8388608` 948 if not ftrwc get fob k 949 break 950 end 951 k = add k 1 952 end 953 w = ftxcode 954 if and not w ftrid s k 955 ftxch cs io ch 96 956 ftxcps cs io ch s k 957 ftxo cs io ch 96 958 else 959 ftxcps cs io ch s k 960 end 961 end 962 ret k 963 end 964 note ftxrun: mode 0 returns the byte count of the text of fob[0, l); mode 1 sends it 965 note ftxmore: fsend5 keeps the text renderer's element state between complete batches. 966 fn ftxrun cs edit ulong 320 io edit uchar 131072 l ulong mode ulong to long 967 ch = new uchar 32768 0 968 put ftrq 0 0 969 put ftrq 1 0 970 put ftrq 2 mode 971 put ftrer 0 0 972 if eq get ftxmore 0 0 973 for k ulong 10 974 put ftxs k 0 975 end 976 put ftxcrm 0 0 977 put ftxfil 0 0 978 put ftxfsp 0 0 979 ftxrt cs io ch tftxpre 980 for k ulong get fpathl 0 bound 4096 981 ftxraw cs io ch get fpath k 982 end 983 ftxraw cs io ch 10 984 ftxraw cs io ch 10 985 end 986 i = ulong 0 987 while lt i l bound `8388608` 988 if eq get fob i 60 989 i = ftxtag cs io ch i l 990 else 991 i = ftxtxt cs io ch i l 992 end 993 end 994 if ne get ftxs 0 10 995 ftxraw cs io ch 10 996 end 997 if eq mode 0 998 ret long get ftrq 1 999 end 1000 if gt get ftrq 0 0 1001 ftrfl cs io ch get ftrq 0 1002 end 1003 ret get ftrer 0 1004 end 1005 note ftxsend: the plain-text response of a kind-0 page, same status and security headers 1006 fn ftxsend cs edit ulong 320 io edit uchar 131072 st ulong l ulong to long 1007 n = ftxrun cs io l 0 1008 r = hrspst cs io st 1009 r = hfe r fhdrt cs io tfnctype tftxct 1010 r = hfe r fsechdr cs io 1011 r = hfe r fhdrt cs io tfncc tfnostor 1012 r = hfe r hhend cs io 0 ulong n 1013 r = hfe r ftxrun cs io l 1 1014 ret hfe r hwfin cs io 1015 end 1016 note ftxcode: inside a pre block or inline code 1017 fn ftxcode to bool 1018 if ne get ftxs 1 0 1019 ret true 1020 end 1021 ret ne get ftxs 6 0 1022 end