This repository was archived by the owner on Oct 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
frontend/components/design-system-components Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,25 @@ const markdownComponents: any = {
280280 }
281281} as const
282282
283+ // Normalize ordered list markers so that lines starting with "1) " are
284+ // converted to the CommonMark style "1. ". This helps react-markdown parse
285+ // them as ordered lists. We avoid transforming content inside fenced code blocks.
286+ const normalizeOrderedListMarkers = ( markdown : string ) => {
287+ let inCodeFence = false
288+ const fenceRegex = / ^ \s * ` ` ` /
289+ return markdown
290+ . split ( '\n' )
291+ . map ( line => {
292+ if ( fenceRegex . test ( line ) ) {
293+ inCodeFence = ! inCodeFence
294+ return line
295+ }
296+ if ( inCodeFence ) return line
297+ return line . replace ( / ^ ( \s * ) ( \d + ) \) \s + / , '$1$2. ' )
298+ } )
299+ . join ( '\n' )
300+ }
301+
283302const MessageMarkdown = ( {
284303 children,
285304 className,
@@ -291,6 +310,7 @@ const MessageMarkdown = ({
291310 allowHtml ?: boolean
292311 textSize ?: MarkdownTextSize
293312} ) => {
313+ const normalizedChildren = normalizeOrderedListMarkers ( children )
294314 return (
295315 < MarkdownContext . Provider value = { textSize } >
296316 < MemoizedReactMarkdown
@@ -307,7 +327,7 @@ const MessageMarkdown = ({
307327 }
308328 components = { markdownComponents }
309329 >
310- { children }
330+ { normalizedChildren }
311331 </ MemoizedReactMarkdown >
312332 </ MarkdownContext . Provider >
313333 )
You can’t perform that action at this time.
0 commit comments