MDC File Format Specification
Complete specification for MDC (Markdown Components) file format, syntax, and features
📋 MDC File Format Specification
MDC (Markdown Components) is an advanced documentation format that extends traditional Markdown with interactive components, AI integration, and structured metadata. This specification defines the complete format and syntax for MDC files.
🎯 Overview
MDC files combine:
- Traditional Markdown: Standard markdown syntax for content
- Interactive Components: Embedded Angular components and widgets
- AI Integration: Structured metadata for AI processing
- Enhanced Frontmatter: Rich metadata and configuration options
- Dynamic Content: Real-time data and conditional rendering
📁 File Structure
Basic Structure
---
# Frontmatter (YAML)
title: "Document Title"
description: "Document description"
# ... additional metadata
---
# Markdown Content
Regular markdown content with **formatting** and [links](/other-page).
## Interactive Components
<mdc:component-name prop1="value" prop2="value">
Optional content
</mdc:component-name>
More markdown content...
File Extensions
.mdc: Primary MDC file extension.md: Traditional markdown (backward compatible)
🔧 Frontmatter Specification
Core Metadata Fields
Required Fields
title: string # Document title
type: "mdc" # Always "mdc" for MDC files
Standard Fields
description: string # Brief description
author: string # Content author
lastUpdated: string # Last update date (ISO format)
version: string # Document version
language: string # Content language (en/es)
Content Organization
category: string # Main category
subcategory: string # Sub-category
tags: string[] # Array of tags
order: number # Display order
status: string # Content status (draft/published/archived)
difficulty: string # Difficulty level (beginner/intermediate/advanced)
estimatedReadTime: number # Reading time in minutes
Navigation Control
toc: boolean # Show table of contents
searchable: boolean # Include in search
breadcrumbs: boolean # Show breadcrumbs
sidebar: boolean # Include in sidebar
MDC-Specific Fields
Component Definitions
components:
- name: string # Component name
version: string # Component version
required: boolean # Whether component is required
props: object # Default properties
AI Integration
ai:
generated: boolean # AI-generated content flag
lastUpdate: string # Last AI update (ISO format)
prompts: string[] # AI prompts used
confidence: number # AI confidence score (0-1)
reviewStatus: string # Review status (pending/approved/needs-revision)
model:
name: string # AI model name
version: string # Model version
provider: string # AI provider
UI Configuration
ui:
showMetadata: boolean # Show metadata panel
showAIPanel: boolean # Show AI panel
enableInteraction: boolean # Enable interactive features
compactMode: boolean # Use compact layout
showComponentInfo: boolean # Show component information
showDebugInfo: boolean # Show debug information
Performance Settings
performance:
lazyLoad: boolean # Enable lazy loading
preload: boolean # Enable preloading
cacheStrategy: string # Caching strategy (normal/aggressive/minimal)
enableProfiling: boolean # Enable performance profiling
maxRenderTime: number # Maximum render time (ms)
componentTimeout: number # Component timeout (ms)
Theme Configuration
theme:
variant: string # Theme variant (modern/classic/minimal)
colorScheme: string # Color scheme (light/dark/adaptive)
animations: string # Animation setting (enabled/disabled/reduced)
🧩 Component Syntax
Basic Component Syntax
<mdc:component-name prop1="value" prop2="value">
Optional content
</mdc:component-name>
Self-Closing Components
<mdc:component-name prop1="value" prop2="value" />
Component with JSON Props
<mdc:interactive-demo
component="ButtonComponent"
:props='{"variant": "primary", "size": "large"}'
sandbox="true">
This demonstrates the button component.
</mdc:interactive-demo>
Conditional Components
<mdc:conditional
condition="user.role === 'developer'"
fallback="Sign in as a developer to see this content">
Developer-only content here.
</mdc:conditional>
🎨 Available Component Types
Core Components
Code Display
<mdc:code-block
language="typescript"
interactive="true"
ai-generated="false">
```typescript
export class ExampleComponent {
@Input() title = 'Hello World';
}
#### Interactive Demos
```markdown
<mdc:interactive-demo
component="ButtonComponent"
:props='{"variant": "primary"}'
sandbox="true"
height="300px">
Try interacting with this button!
</mdc:interactive-demo>
Diagrams
<mdc:diagram
type="flowchart"
ai-prompt="Create a flowchart showing the process"
auto-update="true"
theme="modern">
</mdc:diagram>
AI-Generated Content
<mdc:ai-content
prompt="Explain the benefits of this approach"
generated-at="2025-01-25T10:30:00Z"
confidence="0.95"
model="claude-3.5-sonnet">
AI-generated content appears here.
</mdc:ai-content>
Live Data
<mdc:live-data
source="/api/stats"
refresh="30s"
template="stats-display"
fallback="Loading statistics...">
</mdc:live-data>
Widget Integration
<mdc:widget
type="theme-preview"
:config='{"theme": "dark", "components": ["button", "card"]}'>
</mdc:widget>
Advanced Components
Code Playground
<mdc:code-playground
language="typescript"
template="angular-component"
theme="vs-dark"
interactive="true">
// Your code here
import { Component } from '@angular/core';
@Component({
selector: 'app-example',
template: '<h1>{{ title }}</h1>'
})
export class ExampleComponent {
title = 'Hello World';
}
</mdc:code-playground>
Template Components
<mdc:template
name="custom-template"
:context='{"title": "Custom Title", "items": ["item1", "item2"]}'>
<h2>{{ title }}</h2>
<ul>
@for (item of items; track item) {
<li>{{ item }}</li>
}
</ul>
</mdc:template>
🔍 Component Properties
Common Properties
id: Unique identifier for the componentclass: CSS classes to applystyle: Inline stylesdata-*: Custom data attributes
Component-Specific Properties
Code Block Properties
language: Programming language for syntax highlightinginteractive: Enable interactive featuresai-generated: Mark as AI-generated contenttheme: Code editor themeshowLineNumbers: Display line numbers
Interactive Demo Properties
component: Angular component to displayprops: Component properties (JSON object)sandbox: Enable sandbox modeheight: Container heightwidth: Container width
Diagram Properties
type: Diagram type (flowchart, sequence, etc.)ai-prompt: AI prompt for diagram generationauto-update: Enable automatic updatestheme: Diagram theme
🤖 AI Integration
AI Metadata Structure
ai:
generated: boolean # Whether content is AI-generated
lastUpdate: string # Last AI update timestamp
prompts: string[] # AI prompts used
confidence: number # Confidence score (0-1)
reviewStatus: string # Review status
model:
name: string # AI model name
version: string # Model version
provider: string # AI provider
suggestions: # AI suggestions for improvement
- message: string
type: string
replacement: string
AI-Enhanced Components
mdc:ai-content: AI-generated content sectionsmdc:ai-suggestions: AI-powered suggestionsmdc:ai-translation: AI translation componentsmdc:ai-summary: AI-generated summaries
🎨 Styling and Theming
CSS Classes
MDC components automatically receive CSS classes:
.mdc-component: Base component class.mdc-{component-type}: Component-specific class.mdc-interactive: Interactive component class.mdc-ai-generated: AI-generated content class
Theme Variables
Components inherit theme variables:
.mdc-component {
background: var(--ux-surface);
color: var(--ux-on-surface);
border-radius: var(--ux-border-radius);
}
Responsive Design
Components automatically adapt to screen sizes:
@media (max-width: 768px) {
.mdc-component {
/* Mobile-specific styles */
}
}
🔧 Validation and Error Handling
Component Validation
- Required Properties: Validate required component properties
- Type Checking: Validate property types
- Dependency Checking: Ensure component dependencies exist
- Syntax Validation: Validate component syntax
Error Handling
- Graceful Degradation: Fallback to static content on errors
- Error Reporting: Display helpful error messages
- Debug Mode: Show detailed error information in development
Validation Rules
validation:
strictMode: boolean # Enable strict validation
allowUnknownComponents: boolean # Allow unknown components
validateComponents: boolean # Validate component properties
maxFileSize: number # Maximum file size (bytes)
timeout: number # Processing timeout (ms)
📊 Performance Considerations
Lazy Loading
- Components are loaded on-demand
- Reduces initial bundle size
- Improves page load performance
Caching
- Content is cached for performance
- Cache invalidation on updates
- Configurable cache strategies
Optimization
- Tree-shaking for unused components
- Code splitting for large components
- Performance monitoring and profiling
🔄 Migration from Markdown
Automatic Migration
- MDC files are backward compatible with Markdown
- Automatic detection of file type
- Graceful fallback for unsupported features
Migration Steps
- Rename: Change
.mdto.mdc - Add Frontmatter: Add MDC-specific frontmatter
- Add Components: Embed interactive components
- Test: Validate component rendering
- Deploy: Update routing and navigation
Migration Tools
- Scanner: Automatically detect MDC files
- Validator: Validate MDC syntax and components
- Converter: Convert Markdown to MDC format
🚀 Best Practices
File Organization
- Use descriptive filenames
- Organize by category and subcategory
- Maintain consistent frontmatter structure
Component Usage
- Use components sparingly and purposefully
- Provide fallback content for components
- Test components across different devices
Performance
- Enable lazy loading for large components
- Use appropriate caching strategies
- Monitor performance metrics
Accessibility
- Ensure components are keyboard accessible
- Provide appropriate ARIA labels
- Test with screen readers
🔗 Related Resources
- MDC Component Library
- AI Integration Guide
- Migration Guide
- Performance Optimization
- Accessibility Guidelines
This specification is maintained by the GoGrab Development Team and is updated regularly to reflect new features and improvements.