Convert Darkdown format to GitBook-compatible Markdown with comprehensive migration tools.
Darkdown is a custom markdown format used by platforms like DeveloperHub. This package migrates Darkdown syntax to standard GitBook-compatible markdown.
Darkdown is an extended markdown format that includes custom syntax for:
- Custom callouts (info, warning, danger boxes)
- Tab groups and code blocks
- Auto-linking
- Plugin blocks
- Custom image syntax
- Variables
This package converts all these custom formats to GitBook-compatible syntax.
- 🔄 Complete Migration - Convert Darkdown syntax to standard/Gitbook Markdown
- 🔗 Smart Link Resolution - Automatically fix and track internal links
- 🖼️ Image Handling - Download and organize external images
- 📊 Comprehensive Reporting - Detailed HTML and JSON audit reports
- 📚 SUMMARY.md Generation - Automatic table of contents creation
- ⚙️ Highly Configurable - Customize every aspect of the migration
- 🧩 Modular Architecture - Use individual transformers programmatically
- ✅ Validation Tools - Verify documentation integrity post-migration
npm install -g darkdown-to-markdownnpm install darkdown-to-markdown# Basic migration
darkdown-to-markdown migrate ./source ./destination
# Generate SUMMARY.md
darkdown-to-markdown summary ./docs
# Validate documentation
darkdown-to-markdown validate ./docs
# Initialize configuration
darkdown-to-markdown initconst { migrate, generateSummary } = require('darkdown-to-markdown');
// Migrate files
await migrate({
source: './source',
destination: './docs',
headingStrategy: 'gitbook_standard',
downloadImages: true,
generateReports: true
});
// Generate SUMMARY.md
await generateSummary({
docsDir: './docs',
outputFile: 'SUMMARY.md'
});Migrate Darkdown files to Markdown.
Options:
-c, --config <path>- Path to config file--no-reports- Skip generating audit reports--no-images- Skip downloading images--heading-strategy <strategy>- Heading adjustment strategy (default: gitbook_standard)--preserve-structure- Preserve original directory structure-v, --verbose- Enable verbose logging
Examples:
# Migrate to current directory
darkdown-to-markdown migrate ./source
# Migrate to specific destination
darkdown-to-markdown migrate ./source ./docs
# Skip image downloads
darkdown-to-markdown migrate ./source --no-images
# Use custom config
darkdown-to-markdown migrate ./source -c ./custom-config.jsonGenerate SUMMARY.md from documentation structure.
Options:
-o, --output <file>- Output file name (default: SUMMARY.md)-s, --structure <file>- Custom doc structure file-v, --verbose- Enable verbose logging
Examples:
# Generate SUMMARY.md
darkdown-to-markdown summary ./docs
# Custom output file
darkdown-to-markdown summary ./docs -o TOC.mdValidate documentation structure and links.
Options:
-s, --structure <file>- Custom doc structure file-v, --verbose- Enable verbose logging
Examples:
# Validate documentation
darkdown-to-markdown validate ./docsCreate a default configuration file.
Options:
-f, --force- Overwrite existing config file
Examples:
# Create .darkdownrc.json
darkdown-to-markdown initCreate a .darkdownrc.json file in your project root:
{
"migration": {
"headingStrategy": "gitbook_standard",
"trackLinks": true,
"downloadImages": true,
"preserveStructure": false
},
"transformers": {
"callouts": {
"typeMap": {
"note": "info",
"error": "danger",
"warning": "warning",
"success": "success"
}
},
"codeBlocks": {
"languageMap": {
"yaml": "YAML",
"json": "JSON",
"xml": "XML"
}
}
},
"reports": {
"outputDir": "migration-reports",
"formats": ["html", "json"],
"detailedIssues": true
},
"summary": {
"outputFile": "SUMMARY.md",
"structureFile": "doc_structure.js"
}
}gitbook_standard- Promote H2→H1, H3→H2, etc. (recommended for GitBook)promote_all- Promote all headings by one leveldemote_h1- Demote only H1 to H2none- Keep headings unchanged
Perform a complete migration.
const { migrate } = require('darkdown-to-markdown');
const result = await migrate({
source: './source',
destination: './docs',
headingStrategy: 'gitbook_standard',
downloadImages: true,
trackLinks: true,
generateReports: true,
preserveStructure: false,
verbose: false
});
console.log(result);
// {
// totalFiles: 150,
// linksFixed: 423,
// linksFailed: 12,
// imagesProcessed: 87,
// reportsPath: './migration-reports'
// }Generate SUMMARY.md file.
const { generateSummary } = require('darkdown-to-markdown');
const result = await generateSummary({
docsDir: './docs',
outputFile: 'SUMMARY.md',
structureFile: 'doc_structure.js'
});
console.log(result);
// {
// stats: {
// totalFiles: 150,
// foundFiles: 148,
// missingFiles: 2,
// coverage: '98.67%'
// }
// }Validate documentation structure.
const { validate } = require('darkdown-to-markdown');
const result = await validate({
docsDir: './docs',
structureFile: 'doc_structure.js'
});
console.log(result);
// {
// isValid: false,
// brokenLinks: 3,
// missingFiles: 2,
// orphanedFiles: 5
// }Simplified migration with sensible defaults.
const { quickMigrate } = require('darkdown-to-markdown');
await quickMigrate('./source', './docs', {
headingStrategy: 'gitbook_standard'
});Simplified summary generation.
const { quickSummary } = require('darkdown-to-markdown');
await quickSummary('./docs', {
outputFile: 'SUMMARY.md'
});const { transformers } = require('darkdown-to-markdown');
let content = fs.readFileSync('file.md', 'utf-8');
// Apply individual transformers
content = transformers.callouts.convert(content, 'file.md');
content = transformers.codeBlocks.normalize(content, 'file.md');
content = transformers.links.fix(content, 'file.md');const { reporters } = require('darkdown-to-markdown');
const htmlReporter = new reporters.HtmlReporter({
outputDir: './reports'
});
await htmlReporter.generate(auditData);- Cleans null/empty values
- Normalizes boolean strings
- Validates YAML structure
- Converts
~~~to standard``` - Normalizes language tags
- Handles plugin code blocks
Converts custom callouts to GitBook hints:
{% callout type="warning" title="Important" %}
Content here
{% /callout %}Becomes:
{% hint style="warning" %}
**Important**
Content here
{% endhint %}- Fixes
[auto$](url)style links - Resolves internal links
- Tracks broken links
- Extracts titles from frontmatter
- Downloads external images
- Organizes in
.gitbook/assets/ - Converts custom image syntax
- Adds figure tags with captions
- Converts custom table syntax
- Preserves standard markdown tables
- Converts tab blocks to GitBook format
- Adds proper language labels
- Handles wrap lines settings
- Converts Font Awesome icons
- Transforms badge syntax
- Decodes common entities
- Fixes escaped characters
- Replaces
%varname%with GitBook expressions - Supports custom variable maps
After migration, comprehensive reports are generated:
- Visual overview of migration
- Statistics and charts
- Clickable file links
- Issue breakdown by file
migration-summary.json- Overall statisticsinternal-links-comprehensive.json- Link analysiscomponent-details.json- Detailed transformationsfile-issues/- Individual file issue reports
- Link success/failure tracking
- Pattern-based analysis
- Missing file detection
- Page state classification
- Detailed issue descriptions
- Suggested fixes
Define your documentation structure in doc_structure.js:
module.exports = [
{
title: "GETTING STARTED",
items: [
{ title: "Introduction", file: "intro.md" },
{
title: "Installation",
file: "installation.md",
items: [
{ title: "Prerequisites", file: "installation/prereqs.md" },
{ title: "Quick Start", file: "installation/quickstart.md" }
]
}
]
},
{
title: "API REFERENCE",
items: [
{ title: "Overview", file: "api/overview.md" }
]
}
];The package automatically detects the appropriate structure file:
doc_structure.js # Default
doc_structure_2025.8.js # Version-specific
doc_structure_troubleshooting.js # Type-specific
doc_structure_api_v2.js # Combined
const { migrate, transformers } = require('darkdown-to-markdown');
// Add custom transformer
const customTransformer = (content, filePath) => {
// Your custom logic
return content.replace(/custom-pattern/g, 'replacement');
};
// Run migration with custom step
await migrate({
source: './source',
destination: './docs',
customTransformers: [customTransformer]
});const { transformers } = require('darkdown-to-markdown');
// Extend callout transformer
transformers.callouts.addTypeMapping({
'my-custom-type': 'info'
});const { migrate } = require('darkdown-to-markdown');
const result = await migrate({
source: './source',
destination: './docs',
onProgress: (event) => {
console.log(`Processing: ${event.file}`);
},
onTransform: (type, details) => {
console.log(`Transformed: ${type}`, details);
}
});Links not resolving:
- Check
doc_structure.jsfile exists - Verify file names match exactly
- Review
internal-links-comprehensive.jsonreport
Images not downloading:
- Check internet connectivity
- Verify image URLs are accessible
- Use
--verboseflag for details
Frontmatter errors:
- Check YAML syntax
- Review
migration-summary.jsonreport - Use YAML validator
Missing files:
- Check
migration_map.json - Review file-issues reports
- Verify source directory structure
# Enable verbose logging
darkdown-to-markdown migrate ./source -v
# Check validation before migration
darkdown-to-markdown validate ./sourceSee the examples/ directory for:
- Basic migration setup
- Custom transformer examples
- Configuration templates
- Report analysis scripts
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
See CHANGELOG.md for version history.
MIT © Your Name
Made with ❤️ for the documentation community