@@ -3,7 +3,7 @@ import createMdxCodePlaceholderLoader from "./code-placeholder";
33import dedent from "dedent" ;
44import { md5 } from "../../utils/md5" ;
55
6- const PLACEHOLDER_REGEX = / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / g;
6+ const PLACEHOLDER_REGEX = / C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / g;
77
88const sampleContent = dedent `
99Paragraph with some code:
@@ -19,8 +19,8 @@ describe("MDX Code Placeholder Loader", () => {
1919
2020 it ( "should replace fenced code with placeholder on pull" , async ( ) => {
2121 const result = await loader . pull ( "en" , sampleContent ) ;
22- const hash = md5 ( '```js\nconsole.log("foo");\n```' ) ;
23- const expected = `Paragraph with some code:\n\n{/* CODE_PLACEHOLDER_ ${ hash } */} ` ;
22+ const hash = md5 ( '```js\nconsole.log("foo");\n```' ) . slice ( 0 , 16 ) ;
23+ const expected = `Paragraph with some code:\n\nCODE_PLACEHOLDER_ ${ hash } _END ` ;
2424 expect ( result . trim ( ) ) . toBe ( expected ) ;
2525 } ) ;
2626
@@ -406,8 +406,8 @@ describe("MDX Code Placeholder Loader", () => {
406406 it ( "should replace inline code with placeholder on pull" , async ( ) => {
407407 const md = "This is some `inline()` code." ;
408408 const pulled = await loader . pull ( "en" , md ) ;
409- const hash = md5 ( "`inline()`" ) ;
410- const expected = `This is some {/* INLINE_CODE_PLACEHOLDER_${ hash } */} code.` ;
409+ const hash = md5 ( "`inline()`" ) . slice ( 0 , 16 ) ;
410+ const expected = `This is some INLINE_CODE_PLACEHOLDER_${ hash } _END code.` ;
411411 expect ( pulled ) . toBe ( expected ) ;
412412 } ) ;
413413
@@ -535,7 +535,7 @@ describe("MDX Code Placeholder Loader", () => {
535535 const pushed = await loader . push ( "en" , translated ) ;
536536
537537 // Should not contain any placeholders
538- expect ( pushed ) . not . toMatch ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
538+ expect ( pushed ) . not . toMatch ( / C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ) ;
539539
540540 // Should preserve all special $ characters exactly as they were
541541 expect ( pushed ) . toContain ( 'const price = "$100";' ) ;
@@ -556,7 +556,7 @@ describe("MDX Code Placeholder Loader", () => {
556556 const pushed = await loader . push ( "en" , translated ) ;
557557
558558 // Should not contain any placeholders
559- expect ( pushed ) . not . toMatch ( / \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
559+ expect ( pushed ) . not . toMatch ( / I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ) ;
560560
561561 // Should preserve all special $ characters
562562 expect ( pushed ) . toContain ( "`$price`" ) ;
@@ -577,8 +577,8 @@ describe("MDX Code Placeholder Loader", () => {
577577 const pushed = await loader . push ( "en" , translated ) ;
578578
579579 // Should not contain any placeholders
580- expect ( pushed ) . not . toMatch ( / \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
581- expect ( pushed ) . not . toMatch ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
580+ expect ( pushed ) . not . toMatch ( / I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ) ;
581+ expect ( pushed ) . not . toMatch ( / C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ) ;
582582 expect ( pushed ) . toContain ( "`getData()`" ) ;
583583 expect ( pushed ) . toContain ( "Utilize" ) ;
584584 } ) ;
@@ -605,7 +605,7 @@ describe("MDX Code Placeholder Loader", () => {
605605
606606 // The fix: ALL placeholders should be replaced, including Arabic ones
607607 expect ( pushedResult ) . not . toMatch (
608- / \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ,
608+ / I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ,
609609 ) ;
610610 expect ( pushedResult ) . not . toMatch ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
611611
@@ -639,7 +639,7 @@ describe("MDX Code Placeholder Loader", () => {
639639
640640 // All placeholders should be replaced, even when not in current pullInput
641641 expect ( pushedResult ) . not . toMatch (
642- / \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ,
642+ / I N L I N E _ C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + _ E N D / ,
643643 ) ;
644644 expect ( pushedResult ) . not . toMatch ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ 0 - 9 a - f ] + \s * \* \/ \} / ) ;
645645 expect ( pushedResult ) . toContain ( "`الحصول_على_البيانات()`" ) ;
@@ -737,7 +737,7 @@ describe("MDX Code Placeholder Loader", () => {
737737 // The code block should be present and not replaced with placeholder
738738 expect ( dePushed ) . toContain ( "```bash" ) ;
739739 expect ( dePushed ) . toContain ( "npm install" ) ;
740- expect ( dePushed ) . not . toMatch ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ / ) ;
740+ expect ( dePushed ) . not . toMatch ( / C O D E _ P L A C E H O L D E R _ / ) ;
741741 } ) ;
742742
743743 it ( "should preserve double newlines around placeholders for section splitting" , async ( ) => {
@@ -764,7 +764,7 @@ describe("MDX Code Placeholder Loader", () => {
764764 const pulled = await loader . pull ( "en" , md ) ;
765765
766766 // Verify placeholders are surrounded by double newlines for proper section splitting
767- const placeholders = pulled . match ( / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \s * \* \/ \} / g) ;
767+ const placeholders = pulled . match ( / C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + _ E N D / g) ;
768768 expect ( placeholders ) . toHaveLength ( 2 ) ;
769769
770770 // Check that each placeholder has double newlines around it
@@ -814,12 +814,12 @@ describe("adjacent code blocks bug", () => {
814814 console . log ( "___" ) ;
815815
816816 // The bug: placeholder is concatenated with "typescript" from next block
817- const bugPattern = / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \s * \* \/ \} t y p e s c r i p t / ;
817+ const bugPattern = / C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \_ E N D t y p e s c r i p t / ;
818818 expect ( pulled ) . not . toMatch ( bugPattern ) ;
819819
820820 // Should have proper separation
821821 expect ( pulled ) . toMatch (
822- / \{ \/ \* C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \s * \* \/ \} \n \n \{ \/ \* C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \s * \* \/ \} / ,
822+ / C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + _ E N D \n \n C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + _ E N D / ,
823823 ) ;
824824 } ) ;
825825} ) ;
@@ -885,13 +885,13 @@ describe("placeholder format edge cases (regression)", () => {
885885 const koreanMdx = `\`코드\` 디렉토리와 그 내용을 이해합니다.` ;
886886 const pulled = await loader . pull ( "ko" , koreanMdx ) ;
887887
888- expect ( pulled ) . toMatch ( / ^ \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R / ) ;
888+ expect ( pulled ) . toMatch ( / ^ I N L I N E _ C O D E _ P L A C E H O L D E R / ) ;
889889
890890 // Simulate frontmatter-split: matter.stringify with placeholder at start
891891 const matter = require ( 'gray-matter' ) ;
892892 const mdxDocument = matter . stringify ( pulled , { title : 'Test' } ) ;
893893
894- expect ( mdxDocument ) . toContain ( '{/* ' ) ;
894+ expect ( mdxDocument ) . toContain ( 'INLINE_CODE_PLACEHOLDER ' ) ;
895895
896896 const restored = await loader . push ( "ko" , pulled , koreanMdx , "en" , koreanMdx ) ;
897897 expect ( restored ) . toBe ( koreanMdx ) ;
@@ -918,8 +918,8 @@ describe("placeholder format edge cases (regression)", () => {
918918 const processor = unified ( ) . use ( remarkParse ) . use ( remarkStringify ) ;
919919 const parsed = processor . stringify ( processor . parse ( pulled ) ) ;
920920
921- // JSX comments get escaped by Markdown but structure is preserved
922- // Underscores in placeholder names get escaped: INLINE\_CODE\_PLACEHOLDER
921+ // Tag-style placeholders are preserved through markdown parsing
922+ // Underscores in placeholder names may get escaped: INLINE\_CODE\_PLACEHOLDER
923923 expect ( parsed ) . toMatch ( / I N L I N E [ _ \\ ] * C O D E [ _ \\ ] * P L A C E H O L D E R / ) ;
924924 expect ( parsed ) . not . toContain ( '***' ) ; // Not parsed as bold-italic
925925 expect ( parsed ) . not . toMatch ( / _ _ _ C O D E .* _ _ _ / ) ; // Not using underscore format
@@ -942,15 +942,15 @@ describe("placeholder format edge cases (regression)", () => {
942942 ` ;
943943
944944 const pulled = await loader . pull ( "en" , mdContent ) ;
945- const placeholders = pulled . match ( / \{ \/ \* I N L I N E _ C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + \s * \* \/ \} / g) ;
945+ const placeholders = pulled . match ( / I N L I N E _ C O D E _ P L A C E H O L D E R _ [ a - f 0 - 9 ] + _ E N D / g) ;
946946 expect ( placeholders ) . toHaveLength ( 3 ) ;
947947
948948 const matter = require ( 'gray-matter' ) ;
949949 const mdxDoc = matter . stringify ( pulled , {
950950 title : 'Multiple Placeholders'
951951 } ) ;
952952
953- expect ( mdxDoc ) . toContain ( '{/* ' ) ;
953+ expect ( mdxDoc ) . toContain ( 'INLINE_CODE_PLACEHOLDER ' ) ;
954954
955955 const restored = await loader . push ( "en" , pulled , mdContent , "en" , mdContent ) ;
956956 expect ( restored ) . toBe ( mdContent ) ;
@@ -970,13 +970,13 @@ describe("placeholder format edge cases (regression)", () => {
970970 ` ;
971971
972972 const pulled = await loader . pull ( "en" , mdContent ) ;
973- expect ( pulled ) . toMatch ( / ^ \{ \/ \* C O D E _ P L A C E H O L D E R / ) ;
973+ expect ( pulled ) . toMatch ( / ^ C O D E _ P L A C E H O L D E R / ) ;
974974
975975 const matter = require ( 'gray-matter' ) ;
976976 const mdxDoc = matter . stringify ( pulled , { title : 'Code First' } ) ;
977977
978978 expect ( mdxDoc ) . toContain ( 'title: Code First' ) ;
979- expect ( mdxDoc ) . toContain ( '{/* ' ) ;
979+ expect ( mdxDoc ) . toContain ( 'CODE_PLACEHOLDER ' ) ;
980980
981981 const restored = await loader . push ( "en" , pulled , mdContent , "en" , mdContent ) ;
982982 expect ( restored ) . toBe ( mdContent ) ;
0 commit comments