diff --git a/scripts/docs-i18n/doc_mode_test.go b/scripts/docs-i18n/doc_mode_test.go index 570ac7b13069..939855b592dd 100644 --- a/scripts/docs-i18n/doc_mode_test.go +++ b/scripts/docs-i18n/doc_mode_test.go @@ -2404,6 +2404,7 @@ func TestTranslateDocBodyChunkedMasksInlineCodeAndListMarkers(t *testing.T) { body := strings.Join([]string{ "- Visible prose uses `openclaw config`.", " 1. Visible prose keeps ``nested `ticks` `` exact.", + "- Visible prose keeps Hailuo 2.3/02 exact.", "- Channel configs:", " - Telegram: Visible prose.", " - WhatsApp: Visible prose.", @@ -2428,7 +2429,7 @@ func TestTranslateDocBodyChunkedMasksInlineCodeAndListMarkers(t *testing.T) { t.Fatal("expected raw translator inputs") } for _, input := range translator.rawInputs { - if strings.Contains(input, "`openclaw config`") || strings.Contains(input, "``nested `ticks` ``") { + if strings.Contains(input, "`openclaw config`") || strings.Contains(input, "``nested `ticks` ``") || strings.Contains(input, "2.3/02") { t.Fatalf("expected inline code outside fences to be masked:\n%s", input) } if strings.Contains(input, "- Visible prose uses") || strings.Contains(input, "1. Visible prose keeps") || strings.Contains(input, "> - Visible prose inside a quote.") { @@ -2441,6 +2442,7 @@ func TestTranslateDocBodyChunkedMasksInlineCodeAndListMarkers(t *testing.T) { for _, exact := range []string{ "- Видимый текст uses `openclaw config`.", " 1. Видимый текст keeps ``nested `ticks` `` exact.", + "- Видимый текст keeps Hailuo 2.3/02 exact.", "- Channel configs:\n - Telegram: Видимый текст.\n - WhatsApp: Видимый текст.", "> - Видимый текст inside a quote.", "```md\n- Видимый текст and `fenced example` stay exposed.\n```", diff --git a/scripts/docs-i18n/masking.go b/scripts/docs-i18n/masking.go index ba63c0748b04..942b4746ec9e 100644 --- a/scripts/docs-i18n/masking.go +++ b/scripts/docs-i18n/masking.go @@ -87,8 +87,8 @@ func maskMarkdownDocSyntax(text string, nextPlaceholder func() string, placehold } inlineRanges = append(inlineRanges, protectedMarkdownLinkRanges(text)...) masked := maskByteRanges(text, inlineRanges, nextPlaceholder, placeholders, mapping) - - return maskByteRanges(masked, markdownListMarkerRanges(masked), nextPlaceholder, placeholders, mapping) + masked = maskByteRanges(masked, markdownListMarkerRanges(masked), nextPlaceholder, placeholders, mapping) + return maskByteRanges(masked, compositeNumericValueRanges(masked), nextPlaceholder, placeholders, mapping) } func markdownListMarkerRanges(text string) [][2]int { @@ -306,11 +306,20 @@ func markdownInlineLinkDestination(value string) string { } func extractNumericValues(text string) []string { + ranges := compositeNumericValueRanges(text) + values := make([]string, 0, len(ranges)) + for _, span := range ranges { + values = append(values, text[span[0]:span[1]]) + } + return values +} + +func compositeNumericValueRanges(text string) [][2]int { protocolRanges := make([][2]int, 0) for _, span := range placeholderRe.FindAllStringIndex(text, -1) { protocolRanges = append(protocolRanges, [2]int{span[0], span[1]}) } - values := make([]string, 0) + ranges := make([][2]int, 0) for _, span := range numericValueRe.FindAllStringIndex(text, -1) { candidate := [2]int{span[0], span[1]} if hasCompositeNumericLeadingContinuation(text, candidate[0]) || @@ -318,9 +327,9 @@ func extractNumericValues(text string) []string { rangeOverlapsAny(candidate, protocolRanges) { continue } - values = append(values, text[span[0]:span[1]]) + ranges = append(ranges, [2]int{span[0], span[1]}) } - return values + return ranges } func hasClockMeridiemSuffix(text string, span [2]int) bool {