fix
This commit is contained in:
@@ -110,6 +110,31 @@ func BuildCategoryEnhanceOverlay(parts LegacyEnhanceParts) string {
|
||||
return strings.TrimSpace(b.String())
|
||||
}
|
||||
|
||||
// ExtractEnhanceSectionBody returns the text between start/end markers
|
||||
// (case-insensitive markers, body preserved). Empty when the start marker is missing.
|
||||
func ExtractEnhanceSectionBody(prompt, start, end string) string {
|
||||
raw := strings.ReplaceAll(strings.ReplaceAll(prompt, "\r\n", "\n"), "\r", "\n")
|
||||
lower := strings.ToLower(raw)
|
||||
startL := strings.ToLower(strings.TrimSpace(start))
|
||||
endL := strings.ToLower(strings.TrimSpace(end))
|
||||
if startL == "" {
|
||||
return ""
|
||||
}
|
||||
startIdx := strings.Index(lower, startL)
|
||||
if startIdx < 0 {
|
||||
return ""
|
||||
}
|
||||
bodyStart := startIdx + len(startL)
|
||||
rest := raw[bodyStart:]
|
||||
restLower := lower[bodyStart:]
|
||||
if endL != "" {
|
||||
if endIdx := strings.Index(restLower, endL); endIdx >= 0 {
|
||||
rest = rest[:endIdx]
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(strings.TrimPrefix(strings.TrimSuffix(rest, "\n"), "\n"))
|
||||
}
|
||||
|
||||
func cleanLegacyInstruction(s string) string {
|
||||
s = modernizeLegacyPlaceholders(s)
|
||||
s = reDoubledQuotes.ReplaceAllString(s, `"`)
|
||||
|
||||
Reference in New Issue
Block a user