import Showdown from 'showdown'; export const fragmentFormats = { V_HTML: ".vs.html", V_MARKDOWN: ".vs.md", }; export class Fragment { format; sourceContent; constructor(format, sourceContent) { this.format = format; this.sourceContent = sourceContent; } toHtml() { if(this.format === fragmentFormats.V_MARKDOWN) { const converter = new Showdown.Converter(); const htmlContent = converter.makeHtml(this.sourceContent); return new Fragment( fragmentFormats.V_HTML, htmlContent ); } else { return new Fragment( this.format, this.sourceContent ); } } }