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