GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/tools/doc/preprocess.js at master · feugy/node Expand file tree/ Copy pathpreprocess.jsMore file actions 58 lines (49 loc) · 1.71 KB / Copy pathpreprocess.jsFile metadata and controls58 lines (49 loc) · 1.71 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 'use strict'; module.exports = preprocess; const path = require('path'); const fs = require('fs'); const includeExpr = /^@include\s+([A-Za-z0-9-_]+)(?:\.)?([a-zA-Z]*)$/gmi; const includeData = {}; function preprocess(inputFile, input, cb) { input = stripComments(input); processIncludes(inputFile, input, cb); } function stripComments(input) { return input.replace(/^@\/\/.*$/gmi, ''); } function processIncludes(inputFile, input, cb) { const includes = input.match(includeExpr); if (includes === null) return cb(null, input); var errState = null; var incCount = includes.length; if (incCount === 0) cb(null, input); includes.forEach(function(include) { var fname = include.replace(/^@include\s+/, ''); if (!fname.match(/\.md$/)) fname = `${fname}.md`; if (includeData.hasOwnProperty(fname)) { input = input.split(include).join(includeData[fname]); incCount--; if (incCount === 0) { return cb(null, input); } } const fullFname = path.resolve(path.dirname(inputFile), fname); fs.readFile(fullFname, 'utf8', function(er, inc) { if (errState) return; if (er) return cb(errState = er); preprocess(inputFile, inc, function(er, inc) { if (errState) return; if (er) return cb(errState = er); incCount--; // Add comments to let the HTML generator know how the anchors for // headings should look like. includeData[fname] = `<!-- [start-include:${fname}] -->\n` + `${inc}\n<!-- [end-include:${fname}] -->\n`; input = input.split(`${include}\n`).join(`${includeData[fname]}\n`); if (incCount === 0) { return cb(null, input); } }); }); }); } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |