diff --git a/core-plugins/html.js b/core-plugins/html.js index 4c09626..0046394 100644 --- a/core-plugins/html.js +++ b/core-plugins/html.js @@ -1,6 +1,7 @@ 'use strict'; const chalk = require('chalk'); + module.exports = (text) => ( new Promise((resolve, reject) => { @@ -14,13 +15,43 @@ module.exports = (text) => ( let first = false let escaped = false let doubleQuotesUsed = false; + let boom = '' + let isJs = false + for (let c of text) { + + if(!isJs) { + boom += c; + if(boom === '') { + buildML = buildML.slice(0, -8); + buildML += chalk.magenta('<') + chalk.red('/script') + chalk.magenta('>') + isJs = false + boom = '' + continue + } else if(!(boom === '<' || boom === '") { - + if(buildWord) { buildTag += chalk.green(buildWord) @@ -49,7 +80,7 @@ module.exports = (text) => ( } else { doubleQuotesUsed = false } - } + } else { buildWord += c if (escaped) { @@ -70,11 +101,11 @@ module.exports = (text) => ( buildWord += c if (escaped) { escaped = false - } + } else { escaped = true } - } + } else { buildTag += c } @@ -108,7 +139,7 @@ module.exports = (text) => ( } else if (c === "!") { if(first){ buildTag += c - commentStart = true + commentStart = true } else { buildWord += c } @@ -132,4 +163,4 @@ module.exports = (text) => ( resolve(buildML) }) -); \ No newline at end of file +);