@@ -236,8 +236,10 @@ export function renderMarkdown(raw: string): string {
236236 const rows = bodyRows . trim ( ) . split ( / \r ? \n / ) ;
237237 const bodyHtml = rows . map ( ( row : string ) => {
238238 // Remove leading/trailing | then split, keeping empty cells
239- const cells = row . replace ( / ^ \| | \| $ / g, '' ) . split ( '|' ) . map ( ( c : string ) => c . trim ( ) ) ;
240- return `<tr>${ cells . map ( ( c : string ) => `<td>${ c } </td>` ) . join ( '' ) } </tr>` ;
239+ // Regex uses non-capturing groups for explicit precedence: (^|) OR (|$)
240+ const cells = row . replace ( / (?: ^ \| ) | (?: \| $ ) / g, '' ) . split ( '|' ) . map ( ( c : string ) => c . trim ( ) ) ;
241+ const cellsHtml = cells . map ( ( c : string ) => '<td>' + c + '</td>' ) . join ( '' ) ;
242+ return '<tr>' + cellsHtml + '</tr>' ;
241243 } ) . join ( '' ) ;
242244 return `<table><thead><tr>${ headerHtml } </tr></thead><tbody>${ bodyHtml } </tbody></table>` ;
243245 }
@@ -279,12 +281,12 @@ export function renderMarkdown(raw: string): string {
279281
280282 // Step 13: Restore inline code
281283 html = html . replace ( / % % I N L I N E C O D E _ ( \d + ) % % / g, ( _match , index : string ) => {
282- return inlineCodes [ parseInt ( index , 10 ) ] ;
284+ return inlineCodes [ Number . parseInt ( index , 10 ) ] ;
283285 } ) ;
284286
285287 // Step 14: Restore code blocks
286288 html = html . replace ( / % % C O D E B L O C K _ ( \d + ) % % / g, ( _match , index : string ) => {
287- return codeBlocks [ parseInt ( index , 10 ) ] ;
289+ return codeBlocks [ Number . parseInt ( index , 10 ) ] ;
288290 } ) ;
289291
290292 // Step 15: Convert double newlines to paragraph breaks
0 commit comments