A web application allowing people to create an account, configure a profile, and share a list of URLs on that profile.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
785 B

// markdown.js
// Copyright (C) 2021 Digital Telepresence, LLC
// License: Apache-2.0
'use strict';
const fs = require('fs');
const { SiteService } = require('../../lib/site-lib');
const marked = require('marked');
class MarkdownService extends SiteService {
constructor (dtp) {
super(dtp, module.exports);
}
async start ( ) {
this.markedRenderer = new marked.Renderer();
}
async renderMarkdownFile (documentFile) {
const markdown = await fs.promises.readFile(documentFile, 'utf8');
return this.renderMarkdown(markdown);
}
async renderMarkdown (markdown) {
return marked(markdown, { renderer: this.markedRenderer });
}
}
module.exports = {
slug: 'markdown',
name: 'markdown',
create: (dtp) => { return new MarkdownService(dtp); },
};