diff --git a/src/index.ts b/src/index.ts
index cd886eb..4b937eb 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -276,8 +276,9 @@ function createAlertComponent(
.filter(Boolean)
.join(' ')
+ // For component mode, we need to include raw HTML as an html node type
const iconChildren = config.iconElementHtml
- ? [{ type: 'text', value: config.iconElementHtml }]
+ ? [{ type: 'html', value: config.iconElementHtml }]
: []
return {
diff --git a/test/index.test.ts b/test/index.test.ts
index 41bed48..df4d1e3 100644
--- a/test/index.test.ts
+++ b/test/index.test.ts
@@ -556,13 +556,89 @@ describe('remarkGitHubAlerts', () => {
mode: 'component',
alerts: {
tip: {
- iconElementHtml: '',
+ iconElementHtml:
+ '',
},
},
}
const result = await processMarkdown(markdown, options)
- expect(result).toContain('tip-icon')
+ expect(result).toContain(''
+ )
+ expect(result).toContain('')
+ })
+
+ it('should handle complex SVG icons in both modes', async () => {
+ const complexSvg =
+ ''
+ const markdown = `> [!WARNING]
+> Complex SVG test.`
+
+ // Test HTML mode
+ const htmlResult = await processMarkdown(markdown, {
+ mode: 'html',
+ alerts: {
+ warning: {
+ iconElementHtml: complexSvg,
+ },
+ },
+ })
+
+ expect(htmlResult).toContain(complexSvg)
+ expect(htmlResult).not.toContain('<svg')
+ expect(htmlResult).not.toContain('data-alert-type')
+
+ // Test component mode
+ const componentResult = await processMarkdown(markdown, {
+ mode: 'component',
+ alerts: {
+ warning: {
+ iconElementHtml: complexSvg,
+ },
+ },
+ })
+
+ expect(componentResult).toContain('