callouts: container directive support, mono tags

This commit is contained in:
kbot
2026-07-06 22:07:00 -05:00
parent fb1d6bf69a
commit 974f60ffac
2 changed files with 21 additions and 16 deletions

View File

@@ -3,8 +3,12 @@ import { visit } from 'unist-util-visit';
export default function calloutDirective() {
return (tree) => {
visit(tree, (node) => {
// Handle textDirective (has content) and leafDirective (no content)
if (node.type === 'textDirective' || node.type === 'leafDirective') {
// Handle textDirective, leafDirective, and containerDirective callouts
if (
node.type === 'textDirective' ||
node.type === 'leafDirective' ||
node.type === 'containerDirective'
) {
const name = node.name;
// Only handle known callout types
@@ -12,11 +16,10 @@ export default function calloutDirective() {
if (!validTypes.includes(name)) return;
// Extract attributes (e.g., title="...")
const attributes = node.attributes || [];
const attrs = attributes.map((attr) => ({
const attrs = Object.entries(node.attributes ?? {}).map(([name, value]) => ({
type: 'mdxJsxAttribute',
name: attr.name,
value: attr.value,
name,
value,
}));
// Add type attribute