]*>[\s\S]*?
]*alt="logo"[^>]*>[\s\S]*?<\/a>/g;
if (content.match(logoContainerRegex)) {
content = content.replace(logoContainerRegex, '');
changed = true;
}
// Fix mermaid - suppress errors and show diagrams as formatted code when they fail
if (content.includes('class="mermaid"')) {
// Replace mermaid script with error-handling version
content = content.replace(
/
`
);
// Fix flowchart syntax - add direction (TD = top-down) if missing
content = content.replace(/(]*>)\s*flowchart\s*\n/g, '$1\nflowchart TD\n');
// Also fix "graph" syntax which needs direction
content = content.replace(/(]*>)\s*graph\s*\n/g, '$1\ngraph TD\n');
changed = true;
}
if (changed) {
fs.writeFileSync(filePath, content, 'utf8');
console.log(` ✅ Rebranded/Fixed preload: ${filePath}`);
} else {
console.log(` - No changes in: ${filePath}`);
}
}
function traverseDir(dirPath) {
if (!fs.existsSync(dirPath)) {
console.warn(`Rebranding: Directory not found: ${dirPath}`);
return;
}
const items = fs.readdirSync(dirPath);
for (const item of items) {
const fullPath = path.join(dirPath, item);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
traverseDir(fullPath);
} else if (item.endsWith('.html') || item.endsWith('.css') || item.endsWith('.js')) {
rebrandFile(fullPath);
}
}
}
const rustdocOutput = process.argv[2]; // Path to the built rustdoc output directory
if (!rustdocOutput) {
console.error('Usage: node rebrand-rustdoc.js ');
process.exit(1);
}
console.log(`\n--- Starting Rustdoc Rebranding for: ${rustdocOutput} ---`);
traverseDir(rustdocOutput);
console.log('--- Rustdoc Rebranding Complete ---');