Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit c00667f

Browse files
committed
feat(plugins/plugin-client-common): add ansi language tag support for markdown code blocks
This allows us to display ansi-colored text. e.g. ```ansi --8<-- "some-log-file-with-ansi-characters.txt" ```
1 parent 6cb2f99 commit c00667f

File tree

1 file changed

+5
-0
lines changed
  • plugins/plugin-client-common/src/components/Content/Markdown/components/code

1 file changed

+5
-0
lines changed

plugins/plugin-client-common/src/components/Content/Markdown/components/code/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Props } from '../../../Markdown'
2222
import { tryFrontmatter } from '../../frontmatter'
2323
import { CodeBlockResponseFn } from '../../components'
2424

25+
import Ansi from '../../../Scalar/Ansi'
2526
import CodeBlock from '../../../../Views/Terminal/Block/Inputv2'
2627

2728
const SimpleEditor = React.lazy(() => import('../../../Editor/SimpleEditor'))
@@ -49,6 +50,10 @@ export default function codeWrapper(
4950
const match = /language-(\w+)/.exec(props.className || '')
5051
const language = match ? match[1] : undefined
5152

53+
if (language === 'ansi') {
54+
return <Ansi>{body}</Ansi>
55+
}
56+
5257
if (mdprops.nested && props.codeIdx && mdprops.executableCodeBlocks !== false) {
5358
// onContentChange={body => this.splice(codeWithResponseFrontmatter(body, attributes.response), props.node.position.start.offset, props.node.position.end.offset)}
5459
const myCodeIdx = parseInt(props.codeIdx)

0 commit comments

Comments
 (0)