From 0fd2dd74000bbf66bafb6fe95e4903b8bdd20884 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 23 Apr 2018 21:28:41 +0200 Subject: xo advises --- app.js | 17 +---------------- public/js/script.js | 20 +++++++++----------- rollup.config.js | 18 ++++++++---------- tohtml.js | 17 +++++++++-------- 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 = ''; - - 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 }${rawButton}`); 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', }}) -- cgit v1.2.3