import * as marked from 'marked' import {isNamedSection, MarkMark} from './types' export class HtmlRenderer { public render(mm: MarkMark): string { let mmLines: string[] = [] for ( const section of mm.sections ) { mmLines.push('
') // if this section has a title/description, write those out if ( isNamedSection(section) ) { mmLines.push(`

${marked.marked.parse(section.title)}

`) if ( section.description ) { mmLines.push(`

${marked.marked.parse(section.description)}

`) } } mmLines.push('') mmLines.push('
') } return mmLines.join('\n') } private formatDate(date: Date): string { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; } }