diff --git a/compile.js b/compile.js index 776bcad..b9bfe3b 100644 --- a/compile.js +++ b/compile.js @@ -18,6 +18,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +// local +const Package = require("./package.json"); + // npm const Remarkable = require("remarkable").Remarkable; // remove .Remarkable if you're using Remarkable ^1.0.0! const TOCGenerator = require("markdown-toc"); @@ -55,9 +58,17 @@ function format(data, name) { return HTMLFormatter(data, formatterRules) .split("\n") /* split by every newline */ .join("\n\t\t\t") /* then add padding and convert back into string */ - .replace( /* link text node fix (should really just encase all text with , but whatever) */ - /(\t*)()\n\t*(.*)\n\t*(<\/a>)/g, - "$1 $2$3$4 " + .replace( /* multitag text node fix (should really just encase all text with , but whatever) */ + /(\t*)(<(?:code|a href=".*")>)\n\t*(.*)\n\t*(<\/(?:code|a)>)/g, + "$1$2$3$4" + ) + .replace( /* link prefix spacing fix for ( and [ */ + /([(\[])\n\t*(.*<\/a>)/g, + "$1$2" + ) + .replace( /* multitag suffix fix for special characters. */ + /(<\/(?:a|code)>)\n\t*([.)\];:,])/g, + "$1$2" ); } // probably should bring in a better templating engine but whatever @@ -81,10 +92,14 @@ function format(data, name) {
${render()}
+
+ ` ); /* eslint-enable indent */ } let content = render(Filesystem.readFileSync(Process.argv[2]).toString()); -Filesystem.writeFileSync(Process.argv[3], format(content, Path.basename(Process.argv[3], ".htm"))); +Filesystem.writeFileSync(Process.argv[3], format(content, Path.basename(Process.argv[3], ".html").replace(/_/g, " "))); diff --git a/package-lock.json b/package-lock.json index b9c5635..fd83900 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "yiki", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yiki", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "dependencies": { "@liquify/prettify": "^0.5.5-beta.1", diff --git a/package.json b/package.json index 3e2465d..bc5e505 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yiki", - "version": "0.0.4", + "version": "0.0.5", "description": "The yellows111 wiki system", "main": "compile.js", "scripts": {