@@ -211,6 +211,11 @@ describe('correctTranslatedContentStrings', () => {
211211 '{%- assign supportLevel = entry.support -%}' ,
212212 )
213213 } )
214+
215+ test ( 'fixes garbled endif with percent placed after keyword' , ( ) => {
216+ // `{ endif% %}` — percent appears after "endif" instead of after the opening brace
217+ expect ( fix ( 'some content\n{ endif% %}\nmore' , 'ja' ) ) . toBe ( 'some content\n{% endif %}\nmore' )
218+ } )
214219 } )
215220
216221 // ─── PORTUGUESE (pt) ───────────────────────────────────────────────
@@ -264,6 +269,21 @@ describe('correctTranslatedContentStrings', () => {
264269 expect ( fix ( '{% ifversion fpt ou ghec %}' , 'pt' ) ) . toBe ( '{% ifversion fpt or ghec %}' )
265270 expect ( fix ( '{%- elsif fpt ou ghec %}' , 'pt' ) ) . toBe ( '{%- elsif fpt or ghec %}' )
266271 } )
272+
273+ test ( 'fixes fully translated reutilizáveis reusables path' , ( ) => {
274+ // `reutilizáveis` is Portuguese for "reusables"
275+ expect ( fix ( '{% dados reutilizáveis.repositórios.reaction_list %}' , 'pt' ) ) . toBe (
276+ '{% data reusables.repositories.reaction_list %}' ,
277+ )
278+ expect ( fix ( '{% dados reutilizáveis.foo.bar %}' , 'pt' ) ) . toBe ( '{% data reusables.foo.bar %}' )
279+ } )
280+
281+ test ( 'fixes translated repositórios path segment' , ( ) => {
282+ // `repositórios` is Portuguese for "repositories"
283+ expect ( fix ( '{% data reusables.repositórios.reaction_list %}' , 'pt' ) ) . toBe (
284+ '{% data reusables.repositories.reaction_list %}' ,
285+ )
286+ } )
267287 } )
268288
269289 // ─── CHINESE (zh) ──────────────────────────────────────────────────
@@ -492,6 +512,25 @@ describe('correctTranslatedContentStrings', () => {
492512 expect ( fix ( '{%- conseil %}' , 'fr' ) ) . toBe ( '{%- tip %}' )
493513 expect ( fix ( '{%- conseil -%}' , 'fr' ) ) . toBe ( '{%- tip -%}' )
494514 } )
515+
516+ test ( 'removes orphaned endif when no matching ifversion/elsif opener exists' , ( ) => {
517+ // Caused by translations where only the closing tag survived (e.g. user-api.md reusable)
518+ expect ( fix ( 'Some content\n{% endif %}\nMore content' , 'fr' ) ) . toBe (
519+ 'Some content\n\nMore content' ,
520+ )
521+ expect ( fix ( 'Line one\n{%- endif %}\nLine two' , 'fr' ) ) . toBe ( 'Line one\n\nLine two' )
522+ expect ( fix ( 'Text {%- endif -%} more' , 'fr' ) ) . toBe ( 'Text more' )
523+ } )
524+
525+ test ( 'preserves endif when matching ifversion opener is present' , ( ) => {
526+ const input = '{% ifversion ghec %}content{% endif %}'
527+ expect ( fix ( input , 'fr' ) ) . toBe ( input )
528+ } )
529+
530+ test ( 'preserves endif when elsif opener is present' , ( ) => {
531+ const input = '{% ifversion fpt %}a{% elsif ghec %}b{% endif %}'
532+ expect ( fix ( input , 'fr' ) ) . toBe ( input )
533+ } )
495534 } )
496535
497536 // ─── KOREAN (ko) ──────────────────────────────────────────────────
@@ -586,11 +625,40 @@ describe('correctTranslatedContentStrings', () => {
586625 )
587626 expect ( fix ( '{% für entry in list %}' , 'de' ) ) . toBe ( '{% for entry in list %}' )
588627 } )
628+
629+ test ( 'fixes wiederverwendbare reusables path' , ( ) => {
630+ // `wiederverwendbare` is German for "reusables"
631+ expect ( fix ( '{% data wiederverwendbare.audit_log.reference %}' , 'de' ) ) . toBe (
632+ '{% data reusables.audit_log.reference %}' ,
633+ )
634+ expect ( fix ( '{% Daten wiederverwendbare.audit_log.reference %}' , 'de' ) ) . toBe (
635+ '{% data reusables.audit_log.reference %}' ,
636+ )
637+ // Full real-world example: `{% Data wiederverwendbare.audit_log.referenz-nach-kategorie-gruppiert %}`
638+ // The `{% Data ` → `{% data ` fix runs before this, so by the time we check:
639+ expect (
640+ fix ( '{% Data wiederverwendbare.audit_log.referenz-nach-kategorie-gruppiert %}' , 'de' ) ,
641+ ) . toBe ( '{% data reusables.audit_log.referenz-nach-kategorie-gruppiert %}' )
642+ } )
589643 } )
590644
591645 // ─── GENERIC FIXES ────────────────────────────────────────────────
592646
593647 describe ( 'Generic fixes (all languages)' , ( ) => {
648+ test ( 'strips LLM sentinel markers and preserves word boundaries' , ( ) => {
649+ expect ( fix ( 'Hello<|endoftext|>World' , 'es' ) ) . toBe ( 'Hello World' )
650+ expect ( fix ( 'Hello <|endoftext|> World' , 'es' ) ) . toBe ( 'Hello World' )
651+ expect ( fix ( 'end of sentence.<|endoftext|>Start' , 'es' ) ) . toBe ( 'end of sentence. Start' )
652+ } )
653+
654+ test ( 'fixes capitalized Data Liquid keyword' , ( ) => {
655+ expect ( fix ( '{% Data variables.product.github %}' , 'es' ) ) . toBe (
656+ '{% data variables.product.github %}' ,
657+ )
658+ expect ( fix ( '{% Data reusables.foo %}' , 'es' ) ) . toBe ( '{% data reusables.foo %}' )
659+ expect ( fix ( '{% Data ifversion ghec %}' , 'es' ) ) . toBe ( '{% data ifversion ghec %}' )
660+ } )
661+
594662 test ( 'fixes AUTOTITLE corruption patterns' , ( ) => {
595663 expect ( fix ( '["AUTOTITLE](/path)' , 'es' ) ) . toBe ( '"[AUTOTITLE](/path)' )
596664 expect ( fix ( '[ AUTOTITLE](/path)' , 'es' ) ) . toBe ( '[AUTOTITLE](/path)' )
0 commit comments