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
This commit is contained in:
yellows111 2024-04-17 12:39:36 +01:00
parent c10aa967d1
commit f931edbfa5
5 changed files with 51 additions and 6 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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 (`<!doctype html>\r\n<html><head<meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>${name} - Documentation</title><link rel="stylesheet" type="text/css" href="/yiki.css"></head><body><nav><span>${wikiName}</span><span> | </span><a href="/index.htm">home</a></nav><hr>${data}</body></html>`);
return ( /* eslint-disable indent */
`<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${name} - Documentation</title>
<link rel="stylesheet" type="text/css" href="${rootPrefix}yiki.css">
</head>
<body>
<nav>
<span>${wikiName}</span>
<span> | </span>
<a href="${rootPrefix}index.html">home</a>
</nav>
<hr>
<main>
${HTMLFormatter(data, formatterRules).split("\n").join("\n\t\t\t")}
</main>
</body>
</html>`
); /* eslint-enable indent */
}
let content = render(Filesystem.readFileSync(Process.argv[2]).toString());

14
package-lock.json generated
View File

@ -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",

View File

@ -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"