aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-04-13 12:01:17 +0200
committerache <ache@ache.one>2018-04-13 12:01:17 +0200
commitab5b69f87cca37bffd53c914b66f6540a14e6dd0 (patch)
treead451399a7579cdf5c31188bbc840a3e0f3b0c34 /app.js
parentAdd ada to dependencies (diff)
tohtml is now in a new file
Diffstat (limited to 'app.js')
-rw-r--r--app.js44
1 files changed, 5 insertions, 39 deletions
diff --git a/app.js b/app.js
index 85687e0..2e7c8d0 100644
--- a/app.js
+++ b/app.js
@@ -4,6 +4,8 @@ const fs = require('fs');
const dirTree = require('directory-tree');
const express = require('express');
+const hmd = require('./tohtml');
+
const path = 'md';
const app = express();
@@ -13,46 +15,10 @@ process.on('uncaughtException', err => {
const report = require('vfile-reporter');
-/* TODO : Send the result of guide :
- const guide = require('remark-preset-lint-markdown-style-guide');
-*/
-
-const html = require('remark-rehype');
-const kbd = require('remark-kbd');
-const math = require('remark-math');
-const highlight = require('remark-highlight.js');
-const sb = require('remark-special-box');
-const multiChoice = require('remark-multiple-choice');
-const lineInput = require('remark-line-input');
-const select = require('remark-select');
-const textInput = require('remark-text-input');
-const raw = require('rehype-raw');
-const rehypeKatex = require('rehype-katex');
-const rehypeStringify = require('rehype-stringify');
-const unified = require('unified');
-const remark = require('remark-parse');
-
const useLandScript = '';
const rawButton = '<button class="raw_button" ><div><div>Raw</div></div></button></form>';
-function toHTML(data, fnc) {
- unified()
- .use(remark)
- .use(lineInput)
- .use(textInput)
- .use(select)
- .use(multiChoice)
- .use(math)
- .use(kbd)
- .use(sb)
- .use(highlight)
- .use(html, {allowDangerousHTML: true})
- .use(rehypeKatex)
- .use(raw)
- .use(rehypeStringify)
-
- .process(data, fnc);
-}
+
app.use(express.static('public'));
@@ -96,7 +62,7 @@ app.get(`/${path}/*`, (req, res) => {
console.log(inspect(a));
*/
- toHTML(data, (err, file) => {
+ hmd.toHTML(data, (err, file) => {
res.send(`${String(file) + useLandScript
}<a href="${url}?raw=true" class="no-style">${rawButton}</a>`);
console.error(report(err || file));
@@ -154,7 +120,7 @@ app.get('*', (req, res) => {
res.status(500).send(html);
return;
}
- toHTML(data, (err, file) => {
+ hmd.toHTML(data, (err, file) => {
if (err) {
let html = '<html>';
html += '<body>';