aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-04-23 21:28:41 +0200
committerache <ache@ache.one>2018-04-23 21:28:54 +0200
commit0fd2dd74000bbf66bafb6fe95e4903b8bdd20884 (patch)
treeb74416ac98ab440124dc4bb6030d04e62d7d63d9
parentCan use script inside a md file (diff)
xo advises
-rw-r--r--app.js17
-rw-r--r--public/js/script.js20
-rw-r--r--rollup.config.js18
-rw-r--r--tohtml.js17
4 files changed, 27 insertions, 45 deletions
diff --git a/app.js b/app.js
index 3789c2a..9b49378 100644
--- a/app.js
+++ b/app.js
@@ -3,6 +3,7 @@
const fs = require('fs');
const dirTree = require('directory-tree');
const express = require('express');
+const report = require('vfile-reporter');
const hmd = require('./tohtml');
@@ -13,13 +14,9 @@ process.on('uncaughtException', err => {
console.error(`[${new Date()}] > Error - ${err}`);
});
-const report = require('vfile-reporter');
-
const useLandScript = '';
const rawButton = '<button class="raw_button" ><div><div>Raw</div></div></button></form>';
-
-
app.use(express.static('public'));
app.get(`/${path}/*`, (req, res) => {
@@ -50,18 +47,6 @@ app.get(`/${path}/*`, (req, res) => {
return console.log(err);
}
- // Remark()
- /* Debbug comment
- const a = unified()
- .use(remark)
- .use(lineInput)
- .use(textInput)
- .use(html, {allowDangerousHTML: true})
- .use(raw)
- .parse(data)
- console.log(inspect(a));
- */
-
hmd(data, (err, file) => {
res.send(`${String(file) + useLandScript
}<a href="${url}?raw=true" class="no-style">${rawButton}</a>`);
diff --git a/public/js/script.js b/public/js/script.js
index e7c836e..3738774 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -2,25 +2,23 @@
/* global document XMLHttpRequest */
-
function nodeScriptReplace(node) {
- if ( node.tagName === 'SCRIPT' ) {
- node.parentNode.replaceChild( nodeScriptClone(node) , node );
- }
- else if(node.children) {
- for ( const child of node.children ) {
- nodeScriptReplace( child );
+ if (node.tagName === 'SCRIPT') {
+ node.parentNode.replaceChild(nodeScriptClone(node), node);
+ } else if (node.children) {
+ for (const child of node.children) {
+ nodeScriptReplace(child);
}
}
return node;
}
-function nodeScriptClone(node){
- const script = document.createElement("script");
+function nodeScriptClone(node) {
+ const script = document.createElement('script');
script.text = node.innerHTML;
- [ ...node.attributes].forEach( attr => {
- script.setAttribute( attr.name, attr.value );
+ [...node.attributes].forEach(attr => {
+ script.setAttribute(attr.name, attr.value);
});
return script;
}
diff --git a/rollup.config.js b/rollup.config.js
index 20621c9..e944279 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,11 +1,9 @@
-import uglify from 'rollup-plugin-uglify'
-import builtins from 'rollup-plugin-node-builtins'
-import json from 'rollup-plugin-json'
-import commonjs from 'rollup-plugin-commonjs'
-import resolve from 'rollup-plugin-node-resolve'
-import globals from 'rollup-plugin-node-globals'
-
-
+import uglify from 'rollup-plugin-uglify';
+import builtins from 'rollup-plugin-node-builtins';
+import json from 'rollup-plugin-json';
+import commonjs from 'rollup-plugin-commonjs';
+import resolve from 'rollup-plugin-node-resolve';
+import globals from 'rollup-plugin-node-globals';
export default {
input: 'tohtml.js',
@@ -13,7 +11,7 @@ export default {
file: 'public/js/hmd.min.js',
format: 'iife',
sourcemap: 'inline',
- name: 'hmd'
+ name: 'hmd',
},
plugins: [
resolve({
@@ -28,6 +26,6 @@ export default {
}),
globals(),
uglify(),
- ]
+ ],
};
diff --git a/tohtml.js b/tohtml.js
index b18c944..35173b4 100644
--- a/tohtml.js
+++ b/tohtml.js
@@ -1,6 +1,4 @@
-const path = 'md';
-
-const report = require('vfile-reporter');
+'use-strict';
/* TODO : Send the result of guide :
const guide = require('remark-preset-lint-markdown-style-guide');
@@ -22,7 +20,6 @@ const unified = require('unified');
const remark = require('remark-parse');
const customBlocks = require('remark-custom-blocks');
-
function toHTML(data, fnc) {
unified()
.use(remark)
@@ -36,23 +33,27 @@ function toHTML(data, fnc) {
.use(customBlocks, {
information: {
classes: 'special-box information',
- title: 'optional'
+ title: 'optional',
},
comment: {
classes: 'special-box comment',
- title: 'optional'
+ title: 'optional',
},
attention: {
classes: 'special-box attention',
- title: 'optional'
+ title: 'optional',
},
question: {
classes: 'special-box question',
- title: 'optional'
+ title: 'optional',
},
good: {
classes: 'special-box good',
},
+ secret: {
+ classes: 'special-box secret',
+ title: 'optional',
+ },
bad: {
classes: 'special-box bad',
}})