Skip to content

Commit abe377a

Browse files
docs-botCopilot
andauthored
fix: rejoin dangling hyphen (-) bullet markers in translation corrections (#61271)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e7a56f3 commit abe377a

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/languages/lib/correct-translation-content.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ export function correctTranslatedContentStrings(
5858
)
5959

6060
// The translation pipeline frequently splits Markdown bullet markers
61-
// (`*`) and table-cell pipes (`|`) onto their own line, with the
62-
// actual content pushed to the next line as deeply indented text.
61+
// (`*` and `-`) and table-cell pipes (`|`) onto their own line, with
62+
// the actual content pushed to the next line as deeply indented text.
6363
// This breaks list and table rendering and leaves `[AUTOTITLE]` links
6464
// unexpanded. Rejoin the marker with its content. This corruption
65-
// affects every translated language (~47k bullets and ~11k cells in
66-
// total), so it lives in the universal pre-fixes block.
67-
content = content.replace(/^([ \t]*)\* ?\n[ \t]+/gm, '$1* ')
65+
// affects every translated language, so it lives in the universal
66+
// pre-fixes block.
67+
content = content.replace(/^([ \t]*)([*-]) ?\n[ \t]+/gm, '$1$2 ')
6868
content = content.replace(/^\|[ \t]*\n[ \t]+/gm, '| ')
6969

7070
// The same translator wrapping habit also strands heading markers

src/languages/tests/correct-translation-content.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,19 @@ describe('correctTranslatedContentStrings', () => {
15951595
expect(fix('* \n one\n* \n two', 'fr')).toBe('* one\n* two')
15961596
// Valid bullets are not modified
15971597
expect(fix('* normal\n* another', 'de')).toBe('* normal\n* another')
1598+
1599+
// Lone `-` (hyphen) bullet markers are also rejoined (same corruption)
1600+
const brokenHyphen = '- \n [AUTOTITLE](/orgs/transfer)'
1601+
const expectedHyphen = '- [AUTOTITLE](/orgs/transfer)'
1602+
for (const lang of ['ja', 'de', 'es', 'fr', 'ko', 'pt', 'ru', 'zh']) {
1603+
expect(fix(brokenHyphen, lang)).toBe(expectedHyphen)
1604+
}
1605+
// No trailing space variant
1606+
expect(fix('-\n [AUTOTITLE](/path)', 'ko')).toBe('- [AUTOTITLE](/path)')
1607+
// Multiple consecutive broken hyphen bullets
1608+
expect(fix('- \n one\n- \n two', 'fr')).toBe('- one\n- two')
1609+
// Valid hyphen bullets are not modified
1610+
expect(fix('- normal\n- another', 'de')).toBe('- normal\n- another')
15981611
})
15991612

16001613
test('rejoins broken table cells split across lines (all languages)', () => {

0 commit comments

Comments
 (0)