Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
37 lines
789 B
Go
37 lines
789 B
Go
package mestionora
|
|
|
|
import (
|
|
"golang.org/x/net/html"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
// FirstHTMLHeading extracts untrusted title text. Callers bound input before
|
|
// extraction and escape output at rendering time; this is not a sanitizer.
|
|
func FirstHTMLHeading(source string) string {
|
|
t := html.NewTokenizer(strings.NewReader(source))
|
|
in := false
|
|
var out strings.Builder
|
|
for {
|
|
kind := t.Next()
|
|
if kind == html.ErrorToken {
|
|
if t.Err() == io.EOF {
|
|
break
|
|
}
|
|
break
|
|
}
|
|
tok := t.Token()
|
|
if kind == html.StartTagToken && strings.EqualFold(tok.Data, "h1") {
|
|
in = true
|
|
continue
|
|
}
|
|
if kind == html.EndTagToken && strings.EqualFold(tok.Data, "h1") {
|
|
break
|
|
}
|
|
if in && kind == html.TextToken {
|
|
out.WriteString(tok.Data)
|
|
}
|
|
}
|
|
return strings.TrimSpace(out.String())
|
|
}
|