Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/src/components/assistant-ui/markdown-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
type CodeHeaderProps,
} from '@assistant-ui/react-markdown'
import remarkGfm from 'remark-gfm'
import remarkDisableIndentedCode from '@/lib/remark-disable-indented-code'
import { cn } from '@/lib/utils'
import { SyntaxHighlighter } from '@/components/assistant-ui/shiki-highlighter'
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard'
import { CopyIcon, CheckIcon } from '@/components/icons'

export const MARKDOWN_PLUGINS = [remarkGfm]
export const MARKDOWN_PLUGINS = [remarkGfm, remarkDisableIndentedCode]

function CodeHeader(props: CodeHeaderProps) {
const { copied, copy } = useCopyToClipboard()
Expand Down
14 changes: 14 additions & 0 deletions web/src/lib/remark-disable-indented-code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Remark plugin that disables indented code blocks (4-space indent).
*
* In CommonMark, text indented by 4+ spaces becomes a code block. This
* frequently misparses LLM output where numbered-list items with nested
* content or quoted text are indented. Fenced code blocks (``` … ```)
* still work normally.
*/
export default function remarkDisableIndentedCode(this: unknown) {
const processor = this as { data(key: string, value?: unknown): unknown }
const micromarkExtensions = (processor.data('micromarkExtensions') ?? []) as unknown[]
micromarkExtensions.push({ disable: { null: ['codeIndented'] } })
processor.data('micromarkExtensions', micromarkExtensions)
}
Loading