From f931edbfa5b89b839fdac5532110d48be273fb5a Mon Sep 17 00:00:00 2001 From: yellows111 Date: Wed, 17 Apr 2024 12:39:36 +0100 Subject: [PATCH] 0.0.3 - "mmm cheese" * Formatted the default template * Markdown content is now formatted using `@liquify/prettify` (not `esthetic` due to implementation issues) + Added the ability to specify the virtual prefix for the rendered pages * Changed GNUmakefile to use double quotes instead of singles. AC: gak gak gak gak gak gak gak gak gak gak gak gak gak gak gak --- GNUmakefile | 4 ++-- README.md | 5 +++++ compile.js | 31 ++++++++++++++++++++++++++++++- package-lock.json | 14 ++++++++++++-- package.json | 3 ++- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 73def55..6e26612 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -22,8 +22,8 @@ MARKER = node compile BUILD_DIR = ./build SRC_DIRS = ./docs -MARKDOWN_L = $(patsubst %.md,%.html,$(shell find $(SRC_DIRS) -name '*.md')) -COPY_L = $(patsubst %.css,%.justcopytobuilddir,$(shell find $(SRC_DIRS) -name '*.css')) +MARKDOWN_L = $(patsubst %.md,%.html,$(shell find $(SRC_DIRS) -name "*.md")) +COPY_L = $(patsubst %.css,%.justcopytobuilddir,$(shell find $(SRC_DIRS) -name "*.css")) all: $(MARKDOWN_L) $(COPY_L) diff --git a/README.md b/README.md index 78ec184..5b9fcb8 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,11 @@ Otherwise, if you just want to use `yiki` to render one file: Example: `gmake WIKINAME="I love options!"` +`VPREFIX` Specify the virtual root of that the default template links to +for the `yiki.css` and the `index.html` files. + +Example: `gmake VPREFIX:="/yiki/"` + ## Contributing I request (but not require) that you modify files without Carriage Returns, diff --git a/compile.js b/compile.js index ff31aad..a4e9106 100644 --- a/compile.js +++ b/compile.js @@ -22,6 +22,7 @@ const Remarkable = require("remarkable").Remarkable; // remove .Remarkable if you're using Remarkable ^1.0.0! const TOCGenerator = require("markdown-toc"); const RemarkableHeaderIDs = require("remarkable-header-ids"); +const HTMLFormatter = require("@liquify/prettify").formatSync; // natives const Process = require("process"); @@ -41,11 +42,39 @@ function render(input, options) { function format(data, name) { var wikiName = "A new yiki!"; + var rootPrefix = "/"; if(process.env["WIKINAME"]) { wikiName = process.env["WIKINAME"]; } + if(process.env["VPREFIX"]) { + rootPrefix = process.env["VPREFIX"]; + } + // forceIndent screws with text nodes pretty bad but the alternative is to not allow the full document to be formatted + const formatterRules = {"indentChar": "\t", "indentSize": 1, "markup": {"forceAttribute": false, "forceIndent": true}}; // probably should bring in a better templating engine but whatever - return (`\r\n${name} - Documentation
${data}`); + return ( /* eslint-disable indent */ +` + + + + + + ${name} - Documentation + + + + +
+
+ ${HTMLFormatter(data, formatterRules).split("\n").join("\n\t\t\t")} +
+ +` + ); /* eslint-enable indent */ } let content = render(Filesystem.readFileSync(Process.argv[2]).toString()); diff --git a/package-lock.json b/package-lock.json index 03df5e2..fbb0de7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,29 @@ { "name": "yiki", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yiki", - "version": "0.0.1", + "version": "0.0.3", "license": "MIT", "dependencies": { + "@liquify/prettify": "^0.5.5-beta.1", "markdown-toc": "^1.2.0", "remarkable": "^2.0.1", "remarkable-header-ids": "^0.2.0" } }, + "node_modules/@liquify/prettify": { + "version": "0.5.5-beta.1", + "resolved": "https://registry.npmjs.org/@liquify/prettify/-/prettify-0.5.5-beta.1.tgz", + "integrity": "sha512-VOJiXf6OEpXFQoF0W1hwGvolMURzWLurATnekVs8TcsrE0aSuCsdfWdk7bw8U/dSmsXe05PIq5VtmYMcecIIyw==", + "engines": { + "node": ">=12", + "pnpm": ">=4" + } + }, "node_modules/ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", diff --git a/package.json b/package.json index 5494536..2281057 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yiki", - "version": "0.0.2", + "version": "0.0.3", "description": "The yellows111 wiki system", "main": "compile.js", "scripts": { @@ -12,6 +12,7 @@ "author": "yellows111", "license": "MIT", "dependencies": { + "@liquify/prettify": "^0.5.5-beta.1", "markdown-toc": "^1.2.0", "remarkable": "^2.0.1", "remarkable-header-ids": "^0.2.0"