chore: migrate mail themes to shared framework and locked upstream inputs
Release / Validate Templates (push) Canceled after 0s
Release / Package & Release (push) Canceled after 0s
Release / Update Latest Release Documentation (push) Canceled after 0s

This commit is contained in:
KenanZhu committed 2026-10-09 18:34:36 +08:00
1 parent 5c0589f6f6
commit fec3ace600
225 files changed
+4718 -15807

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
package builder
import (
"bytes"
"fmt"
"golang.org/x/net/html"
"io"
)
func BodyAnchors(masked []byte) ([2]int, error) {
var anchors [2]int
opens, closes, offset := 0, 0, 0
z := html.NewTokenizer(bytes.NewReader(masked))
for {
kind := z.Next()
raw := z.Raw()
start := offset
offset += len(raw)
switch kind {
case html.ErrorToken:
if z.Err() != io.EOF {
return anchors, z.Err()
}
if opens != 1 || closes != 1 || anchors[0] >= anchors[1] {
return anchors, fmt.Errorf("expected exactly one static body start and end")
}
return anchors, nil
case html.StartTagToken:
tag, _ := z.TagName()
if bytes.Equal(tag, []byte("body")) {
opens++
anchors[0] = offset
}
case html.EndTagToken:
tag, _ := z.TagName()
if bytes.Equal(tag, []byte("body")) {
closes++
anchors[1] = start
}
}
}
}