edicek
Version:
CLI tool for exporting knowledge from Edicek to Markdown files
46 lines • 1.88 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryMarkdownGenerator = void 0;
class EntryMarkdownGenerator {
static generateEntryMarkdown(entry) {
const lines = [];
lines.push('# Entry');
lines.push('');
lines.push(`**Title:** ${entry.title || 'N/A'}`);
lines.push(`**Description:** ${entry.description || 'N/A'}`);
lines.push(`**Created At:** ${entry.createdAt}`);
lines.push('');
// Process atoms with hierarchical structure
for (const atom of entry.atoms) {
// Atom header with optional title
const atomTitle = 'title' in atom && atom.title ? atom.title : '';
const atomHeader = atomTitle ? `[${atom.type}] ${atomTitle}` : `[${atom.type}]`;
lines.push(`## ${atomHeader}`);
lines.push('');
// Atom fields as ### subheadings
const atomKeys = Object.keys(atom);
for (const key of atomKeys) {
const value = atom[key];
if (value == null || value == undefined) {
continue;
}
lines.push(`### ${key}`);
lines.push('```');
lines.push(String(value));
lines.push('```');
lines.push('');
}
}
return lines.join('\n').trim();
}
static sanitizeFilename(filename) {
return filename
.replace(/[<>:"/\\|?*]/g, '-') // Replace invalid chars
.replace(/\s+/g, '-') // Replace spaces with dashes
.replace(/-+/g, '-') // Replace multiple dashes with single
.replace(/^-|-$/g, '') // Remove leading/trailing dashes
.toLowerCase();
}
}
exports.EntryMarkdownGenerator = EntryMarkdownGenerator;
//# sourceMappingURL=MarkdownGenerator.js.map
;