Skip to content

Commit 89c4144

Browse files
committed
Adding content transformations for GitHub-style callouts.
Signed-off-by: Pete Cheslock <[email protected]>
1 parent 3f483d5 commit 89c4144

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

remote-content/remote-sources/repo-transforms.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@
66
*/
77

88
/**
9-
* Apply essential MDX compatibility fixes
9+
* Apply essential MDX compatibility fixes and content transformations
10+
* Combines all content-only transformations that don't require repository information
1011
*/
1112
function applyBasicMdxFixes(content) {
1213
return content
14+
// Convert GitHub-style callouts to Docusaurus admonitions
15+
.replace(/^> \[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*\n((?:> .*\n?)*)/gm, (match, type, content) => {
16+
// Map GitHub callout types to Docusaurus admonition types
17+
const typeMap = {
18+
'NOTE': 'note',
19+
'TIP': 'tip',
20+
'IMPORTANT': 'info',
21+
'WARNING': 'warning',
22+
'CAUTION': 'danger'
23+
};
24+
25+
const docusaurusType = typeMap[type] || type.toLowerCase();
26+
27+
// Remove the '> ' prefix from each line of content
28+
const cleanContent = content.replace(/^> ?/gm, '').trim();
29+
30+
return `:::${docusaurusType}\n${cleanContent}\n:::\n`;
31+
})
32+
// Fix HTML tags for MDX compatibility
1333
.replace(/<br>/g, '<br />')
1434
.replace(/<br([^/>]*?)>/g, '<br$1 />')
1535
.replace(/<picture[^>]*>/g, '')

0 commit comments

Comments
 (0)