commit 0638e97cef636f94be5e5335445366aca8623843 Author: Hans Fast Date: Wed Mar 18 14:07:57 2026 +0100 initial commit: working repoduction diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f2eb50 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ + +* `addFilenameData.js` called twice at startup (it logs the key) +* called again when `allfiles/ad_hello_pub.md` requested, but now the key has a trailing slash. +* note: again, it's called twice, but the **first** time the key doesn't have a slash, and the **second** time, it does, which causes + * this looks like a server redirect causing issues ... + * but when I use the cli the key gets logged _three_ times: `ori pipeline.ori()/allfiles/ad_hello_pub.md` +* the parser (PeggyJS grammmar) doesn't expect a trailing slash and errors. +* when `renderedPages/hello.html` is requested, the parser sees the filename _without_ trailing slash, and runs successfully. + +It also seems like addFilenameData.js is being called for every entry in the original map: all three markdown files in the directory. huh? +It seems like the key which the server requests is propagating up the pipeline. Huh? + + + +server log: + +``` +$ ori "serve watch ., =debug ./pipeline.ori()" +key: ad_hello_pub.md +key: ad_hello_pub.md +Server running at http://localhost:5000. Press Ctrl+C to stop. +/renderedPages/hello.html +key: ad_hello_pub.md +/allfiles/ad_hello_pub.md +key: ad_hello_pub.md +/allfiles/ad_hello_pub.md/ +key: ad_hello_pub.md/ +SyntaxError: Expected ".", [a-z0-9], or end of input but "/" found. + at peg$buildStructuredError (file:///home/hans/exp/ori-repro-earlier-bug/filenameparser.js:356:12) + at peg$throw (file:///home/hans/exp/ori-repro-earlier-bug/filenameparser.js:694:11) + at peg$parse (file:///home/hans/exp/ori-repro-earlier-bug/filenameparser.js:716:5) + at OrigamiFileMap.default (file:///home/hans/exp/ori-repro-earlier-bug/addFilenameData.js?cacheBust=1773838110056:5:15) +evaluating: addFilenameData.js(value, key) + at pipeline.ori:14:58 +``` diff --git a/_index.md b/_index.md new file mode 100644 index 0000000..6c02fce --- /dev/null +++ b/_index.md @@ -0,0 +1 @@ +_This content will go on the homepage._ diff --git a/ad_hello_pub.md b/ad_hello_pub.md new file mode 100644 index 0000000..5551c0b --- /dev/null +++ b/ad_hello_pub.md @@ -0,0 +1,5 @@ +--- +title: Hello +--- + +Hello, world. diff --git a/addFilenameData.js b/addFilenameData.js new file mode 100644 index 0000000..067161c --- /dev/null +++ b/addFilenameData.js @@ -0,0 +1,7 @@ +import {parse} from './filenameparser.js'; + +export default (value, key) => { + console.log(`key: ${key}`); + const fnd = parse(key); + return {...value, fnd}; +} diff --git a/addMoreFilenameData.js b/addMoreFilenameData.js new file mode 100644 index 0000000..ebd10b9 --- /dev/null +++ b/addMoreFilenameData.js @@ -0,0 +1,8 @@ +import {parse} from './filenameparser.js'; + +export default (value, key) => { + console.log(`morekey: ${key}`); + const fnd = parse(key); + return {...value, fnd}; +} + diff --git a/base_html.ori b/base_html.ori new file mode 100644 index 0000000..39b5503 --- /dev/null +++ b/base_html.ori @@ -0,0 +1,13 @@ +//base page template +(page) => Tree.indent` + + + + + ${page.title} + + + ${page.indexPage ? '' : '↖index'} + ${page._body} + +` diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..30dfcc1 --- /dev/null +++ b/css/style.css @@ -0,0 +1,3 @@ +body { + font-family: "Jost*"; +} diff --git a/extractSummary.js b/extractSummary.js new file mode 100644 index 0000000..1002a65 --- /dev/null +++ b/extractSummary.js @@ -0,0 +1,8 @@ +const reg = /^(?.+)?/s +export default (doc) => { + const result = reg.exec(doc._body); + if (result) { + doc.summary = result.groups.summary; + } + return doc; +} diff --git a/filenameparser.js b/filenameparser.js new file mode 100644 index 0000000..ab164df --- /dev/null +++ b/filenameparser.js @@ -0,0 +1,728 @@ +// @generated by Peggy 5.1.0. +// +// https://peggyjs.org/ + + +class peg$SyntaxError extends SyntaxError { + constructor(message, expected, found, location) { + super(message); + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + } + + format(sources) { + let str = "Error: " + this.message; + if (this.location) { + let src = null; + const st = sources.find(s => s.source === this.location.source); + if (st) { + src = st.text.split(/\r\n|\n|\r/g); + } + const s = this.location.start; + const offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; + if (src) { + const e = this.location.end; + const filler = "".padEnd(offset_s.line.toString().length, " "); + const line = src[s.line - 1]; + const last = s.line === e.line ? e.column : line.length + 1; + const hatLen = (last - s.column) || 1; + str += "\n --> " + loc + "\n" + + filler + " |\n" + + offset_s.line + " | " + line + "\n" + + filler + " | " + "".padEnd(s.column - 1, " ") + + "".padEnd(hatLen, "^"); + } else { + str += "\n at " + loc; + } + } + return str; + } + + static buildMessage(expected, found) { + function hex(ch) { + return ch.codePointAt(0).toString(16).toUpperCase(); + } + + const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") + ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") + : null; + function unicodeEscape(s) { + if (nonPrintable) { + return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}"); + } + return s; + } + + function literalEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/"/g, "\\\"") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } + + function classEscape(s) { + return unicodeEscape(s + .replace(/\\/g, "\\\\") + .replace(/\]/g, "\\]") + .replace(/\^/g, "\\^") + .replace(/-/g, "\\-") + .replace(/\0/g, "\\0") + .replace(/\t/g, "\\t") + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) + .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); + } + + const DESCRIBE_EXPECTATION_FNS = { + literal(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + + class(expectation) { + const escapedParts = expectation.parts.map( + part => (Array.isArray(part) + ? classEscape(part[0]) + "-" + classEscape(part[1]) + : classEscape(part)) + ); + + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : ""); + }, + + any() { + return "any character"; + }, + + end() { + return "end of input"; + }, + + other(expectation) { + return expectation.description; + }, + }; + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + const descriptions = expected.map(describeExpectation); + descriptions.sort(); + + if (descriptions.length > 0) { + let j = 1; + for (let i = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } + } + descriptions.length = j; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + } +} + +function peg$parse(input, options) { + options = options !== undefined ? options : {}; + + const peg$FAILED = {}; + const peg$source = options.grammarSource; + + const peg$startRuleFunctions = { + line: peg$parseline, + }; + let peg$startRuleFunction = peg$parseline; + + const peg$c0 = "."; + const peg$c1 = ":"; + const peg$c2 = "_"; + + const peg$r0 = /^[a-z0-9]/; + const peg$r1 = /^[^:.]/; + const peg$r2 = /^[a-p]/; + const peg$r3 = /^[^_.]/i; + + const peg$e0 = peg$literalExpectation(".", false); + const peg$e1 = peg$classExpectation([["a", "z"], ["0", "9"]], false, false, false); + const peg$e2 = peg$literalExpectation(":", false); + const peg$e3 = peg$classExpectation([":", "."], true, false, false); + const peg$e4 = peg$classExpectation([["a", "p"]], false, false, false); + const peg$e5 = peg$classExpectation(["_", "."], true, true, false); + const peg$e6 = peg$literalExpectation("_", false); + + function peg$f0(addr, name, tags, ext) {return { + addr: addr.value, + name: name.value, + tags: tags?.tags, + ext: ext.value +} } + function peg$f1(value) {return {type: "extension", value} } + function peg$f2(tags) {return {type: "tags", tags} } + function peg$f3(value) {return {type: "address", value} } + function peg$f4(value) {return {type: "name", value} } + let peg$currPos = options.peg$currPos | 0; + let peg$savedPos = peg$currPos; + const peg$posDetailsCache = [{ line: 1, column: 1 }]; + let peg$maxFailPos = peg$currPos; + let peg$maxFailExpected = options.peg$maxFailExpected || []; + let peg$silentFails = options.peg$silentFails | 0; + + let peg$result; + + if (options.startRule) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function offset() { + return peg$savedPos; + } + + function range() { + return { + source: peg$source, + start: peg$savedPos, + end: peg$currPos, + }; + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); + + throw peg$buildSimpleError(message, location); + } + + function peg$getUnicode(pos = peg$currPos) { + const cp = input.codePointAt(pos); + if (cp === undefined) { + return ""; + } + return String.fromCodePoint(cp); + } + + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text, ignoreCase }; + } + + function peg$classExpectation(parts, inverted, ignoreCase, unicode) { + return { type: "class", parts, inverted, ignoreCase, unicode }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description }; + } + + function peg$computePosDetails(pos) { + let details = peg$posDetailsCache[pos]; + let p; + + if (details) { + return details; + } else { + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column, + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + + return details; + } + } + + function peg$computeLocation(startPos, endPos, offset) { + const startPosDetails = peg$computePosDetails(startPos); + const endPosDetails = peg$computePosDetails(endPos); + + const res = { + source: peg$source, + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column, + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column, + }, + }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parseline() { + let s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseaddr(); + if (s1 !== peg$FAILED) { + s2 = peg$parsename(); + if (s2 !== peg$FAILED) { + s3 = peg$parsetags(); + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = peg$parseext(); + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f0(s1, s2, s3, s4); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseext() { + let s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = []; + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c0; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r0.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r0.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c0; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e0); } + } + if (s4 !== peg$FAILED) { + s5 = []; + s6 = input.charAt(peg$currPos); + if (peg$r0.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + s6 = input.charAt(peg$currPos); + if (peg$r0.test(s6)) { + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + } + } else { + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = input.substring(s1, peg$currPos); + } else { + s1 = s2; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f1(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsetags() { + let s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsetag(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c1; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s4 !== peg$FAILED) { + s4 = peg$parsetag(); + if (s4 === peg$FAILED) { + peg$currPos = s3; + s3 = peg$FAILED; + } else { + s3 = s4; + } + } else { + s3 = s4; + } + } + peg$savedPos = s0; + s0 = peg$f2(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsetag() { + let s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e3); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s0 = input.substring(s0, peg$currPos); + } else { + s0 = s1; + } + + return s0; + } + + function peg$parseaddr() { + let s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = []; + s3 = input.charAt(peg$currPos); + if (peg$r2.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = input.charAt(peg$currPos); + if (peg$r2.test(s3)) { + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e4); } + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = input.substring(s1, peg$currPos); + } else { + s1 = s2; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f3(s1); + } + s0 = s1; + + return s0; + } + + function peg$parsename() { + let s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = []; + s4 = input.charAt(peg$currPos); + if (peg$r3.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = input.charAt(peg$currPos); + if (peg$r3.test(s4)) { + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e5); } + } + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + s2 = input.substring(s2, peg$currPos); + } else { + s2 = s3; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f4(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parse_() { + let s0; + + if (input.charCodeAt(peg$currPos) === 95) { + s0 = peg$c2; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e6); } + } + + return s0; + } + + peg$result = peg$startRuleFunction(); + + const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length); + function peg$throw() { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos, + peg$success, + peg$throw: peg$success ? undefined : peg$throw, + }); + } + if (peg$success) { + return peg$result; + } else { + peg$throw(); + } +} + +const peg$allowedStartRules = [ + "line" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse +}; diff --git a/indexPage.ori b/indexPage.ori new file mode 100644 index 0000000..d3ce798 --- /dev/null +++ b/indexPage.ori @@ -0,0 +1,11 @@ +(pages, all) => base_html.ori({ + indexPage: true + all: all + title: 'Hans Fast' + _body: Tree.indent` +

Hans Fast

+ ${Origami.mdHtml(_index.md)} + ${Tree.map(pages, (value, key) => pageSummaries.ori.html(value, key))} + +` +}) diff --git a/page.ori b/page.ori new file mode 100644 index 0000000..df7e33c --- /dev/null +++ b/page.ori @@ -0,0 +1,9 @@ +(page) => base_html.ori({ + indexPage: false + title: page.title + _body: Tree.indent` +

${page.title}

+ ${page._body} + ↖index +` +}) diff --git a/pageSummaries.ori.html b/pageSummaries.ori.html new file mode 100644 index 0000000..141ce2f --- /dev/null +++ b/pageSummaries.ori.html @@ -0,0 +1,7 @@ +--- +(value, key) => _template() +--- + diff --git a/parseHtml.js b/parseHtml.js new file mode 100644 index 0000000..87b0cf7 --- /dev/null +++ b/parseHtml.js @@ -0,0 +1,14 @@ +import {fromHtml} from 'hast-util-from-html'; +import {visit} from 'unist-util-visit'; + +export default async function(value) { + const tree = fromHtml(value); + const links = []; + visit(tree, [{tagName: 'link'}, {tagName: 'img'}], function(node) { + links.push(node); + }) + const hrefs = links.map(link => link.properties.href || link.properties.src) + + return hrefs; + // return tree; +} diff --git a/pipeline.ori b/pipeline.ori new file mode 100644 index 0000000..9ccec32 --- /dev/null +++ b/pipeline.ori @@ -0,0 +1,25 @@ +{ + //put the file selection part in a closure, so that the list of all files is kept private. + /* + select markdown files not beginning with `_`, force contents to Document, and add data parsed from filename. + */ + allfiles: Tree.filter(., (val, key) => key.endsWith('.md') && !key.startsWith('_') && key !== 'README.md') + → (items) => Tree.map(items, {value: (value) => Origami.document(value)}) //if I don't use the verbose syntax I get the filename characters as part of value! + → (items) => Tree.map(items, {value: (value, key) => addFilenameData.js(value, key)}) + + /* + Now convert to html. + */ + asHtml: Tree.map(allfiles, { + value: (value) => Origami.mdHtml(value) + key: (value, key) => `${value.fnd.name}.html` + }) + + renderedPages: Tree.map(asHtml, (page) => (page)) + + /* + Now, I think I have enough to build both the individual pages and the index page! + */ + index.html: indexPage.ori(asHtml) + ...renderedPages +} diff --git a/removePrivate.js b/removePrivate.js new file mode 100644 index 0000000..b3739fc --- /dev/null +++ b/removePrivate.js @@ -0,0 +1,9 @@ +const reg = /^(?.+).+$/s +export default (doc) => { + const result = reg.exec(doc._body); + if (result) { + doc._body = result.groups.public; + } + return doc; +} +