From 8f0fa3a2c9472022869703fc27c6f66ea596af10 Mon Sep 17 00:00:00 2001 From: ache Date: Thu, 4 Jan 2018 12:10:31 +0100 Subject: Fix 404 Markdown interpreter --- app.js | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/app.js b/app.js index f747fca..f2a5f8e 100644 --- a/app.js +++ b/app.js @@ -38,6 +38,28 @@ const inspect = require('unist-util-inspect'); const useLandScript = " " const userSide_Button = '' +function to_HTML( data, fnc ) { + unified() + .use(remark) +// .use(guide) + .use(mermaid) + .use(lineInput) +// .use(textInput) + .use(math) + .use(kbd) + .use(sb) + .use(qcm) + .use(highlight) + .use(html, {allowDangerousHTML: true}) + .use(rehypeKatex) + .use(raw) + .use(rehypeStringify) + + .process(data, fnc ); +} + + + app.use(express.static('public')); app.get('/' + path + '/*', function(req, res) { @@ -76,23 +98,7 @@ app.get('/' + path + '/*', function(req, res) { console.log(inspect(a)); */ - unified() - .use(remark) -// .use(guide) - .use(mermaid) - .use(lineInput) -// .use(textInput) - .use(math) - .use(kbd) - .use(sb) - .use(qcm) - .use(highlight) - .use(html, {allowDangerousHTML: true}) - .use(rehypeKatex) - .use(raw) - .use(rehypeStringify) - - .process(data, function (err, file) { + to_HTML(data, function (err, file) { res.send(String(file) + useLandScript + '' + userSide_Button + ''); console.error(report(err || file)); @@ -138,15 +144,17 @@ app.get('*', function(req, res) { if (err) return console.log(err); fs.readFile('public/css/style.css', 'utf8', function(err, style) { - var html = ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += converter.makeHtml(data); - html += ''; - html += ''; - res.status(404).send(html); + to_HTML( data, function( err, file ) { + var html = ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += String(file); + html += ''; + html += ''; + res.status(404).send(html); + }); }); }); }); -- cgit v1.2.3