Node.js update to disable converting a Jekyll-style machine to an actual machine if a machine XML file was already processed

This commit is contained in:
Jeff Parsons 2015-12-16 16:52:50 -08:00
commit e15366a725
2 changed files with 11 additions and 8 deletions

View file

@ -1400,7 +1400,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
s = m.convertMD(" ").trim(); s = m.convertMD(" ").trim();
obj.processMachines(m.getMachines(), function doneProcessXMLMachines() { obj.processMachines(m.getMachines(), function doneProcessXMLMachines() {
obj.getReadMe(sToken, sIndent, aParms, s); obj.getReadMe(sToken, sIndent, aParms, s, true);
}); });
return; return;
} }
@ -1626,7 +1626,7 @@ HTMLOut.prototype.getManifestXML = function(sToken, sIndent, aParms)
}; };
/** /**
* getReadMe(sToken, sIndent, aParms, sPrevious) * getReadMe(sToken, sIndent, aParms, sPrevious, fMachineXML)
* *
* If a "README.md" exists in the current directory, open it, convert it, and prepare for replacement. * If a "README.md" exists in the current directory, open it, convert it, and prepare for replacement.
* *
@ -1635,8 +1635,9 @@ HTMLOut.prototype.getManifestXML = function(sToken, sIndent, aParms)
* @param {string} [sIndent] * @param {string} [sIndent]
* @param {Array.<string>} [aParms] * @param {Array.<string>} [aParms]
* @param {string|null} [sPrevious] is text, if any, that should precede the README.md * @param {string|null} [sPrevious] is text, if any, that should precede the README.md
* @param {boolean} [fMachineXML] true if a machine.xml file has already been processed by the caller
*/ */
HTMLOut.prototype.getReadMe = function(sToken, sIndent, aParms, sPrevious) HTMLOut.prototype.getReadMe = function(sToken, sIndent, aParms, sPrevious, fMachineXML)
{ {
var obj = this; var obj = this;
var sFile = path.join(this.sDir, sReadMeFile); var sFile = path.join(this.sDir, sReadMeFile);
@ -1663,7 +1664,7 @@ HTMLOut.prototype.getReadMe = function(sToken, sIndent, aParms, sPrevious)
obj.getMachineXML(sToken, sIndent); // we don't pass along aParms, because those are for Markdown files only obj.getMachineXML(sToken, sIndent); // we don't pass along aParms, because those are for Markdown files only
} }
} else { } else {
var m = new MarkOut(s, sIndent, obj.req, aParms, obj.fDebug); var m = new MarkOut(s, sIndent, obj.req, aParms, obj.fDebug, fMachineXML);
s = m.convertMD(" ").trim(); s = m.convertMD(" ").trim();
/* /*
* If the Markdown document begins with a heading, stuff that into the <title> tag; * If the Markdown document begins with a heading, stuff that into the <title> tag;

View file

@ -95,8 +95,9 @@ var sDefaultFile = "./README.md";
* @param {Object} [req] is the web server's (ie, Express) request object, if any * @param {Object} [req] is the web server's (ie, Express) request object, if any
* @param {Array.<string>|null} [aParms] is an array of overrides to use (see below) * @param {Array.<string>|null} [aParms] is an array of overrides to use (see below)
* @param {boolean} [fDebug] turns on debugging features (eg, debug comments, special URL encodings, etc) * @param {boolean} [fDebug] turns on debugging features (eg, debug comments, special URL encodings, etc)
* @param {boolean} [fMachineXML] true if a machine.xml file has already been processed by the caller
*/ */
function MarkOut(sMD, sIndent, req, aParms, fDebug) function MarkOut(sMD, sIndent, req, aParms, fDebug, fMachineXML)
{ {
this.sMD = sMD; this.sMD = sMD;
this.sIndent = (sIndent || ""); this.sIndent = (sIndent || "");
@ -109,6 +110,7 @@ function MarkOut(sMD, sIndent, req, aParms, fDebug)
this.sClassImageLabel = this.sClassImage + "-label"; this.sClassImageLabel = this.sClassImage + "-label";
} }
this.fDebug = fDebug; this.fDebug = fDebug;
this.fMachineXML = fMachineXML;
this.sHTML = null; this.sHTML = null;
this.aIDs = []; // this keeps track of auto-generated ID attributes for page elements, to insure uniqueness this.aIDs = []; // this keeps track of auto-generated ID attributes for page elements, to insure uniqueness
this.aMachines = []; // this keeps track of embedded machines on the page this.aMachines = []; // this keeps track of embedded machines on the page
@ -993,9 +995,9 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
var reIncludes = /\{%\s*include machine\.html\s+id="(.*?)"\s*%}/g; var reIncludes = /\{%\s*include machine\.html\s+id="(.*?)"\s*%}/g;
while ((aMatch = reIncludes.exec(sBlock))) { while ((aMatch = reIncludes.exec(sBlock))) {
sReplacement = "";
sMachineID = aMatch[1]; sMachineID = aMatch[1];
sReplacement = "[Embedded PC]"; if (!this.fMachineXML && this.aMachineDefs[sMachineID]) {
if (this.aMachineDefs[sMachineID]) {
var machine = this.aMachineDefs[sMachineID]; var machine = this.aMachineDefs[sMachineID];
sMachine = machine['type'] || "pc"; sMachine = machine['type'] || "pc";
sMachineOptions = (sMachine.indexOf("-dbg") > 0? "debugger" : ""); sMachineOptions = (sMachine.indexOf("-dbg") > 0? "debugger" : "");
@ -1004,7 +1006,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
sMachineXSLFile = machine['template'] || ""; sMachineXSLFile = machine['template'] || "";
sMachineVersion = (machine['uncompiled'] && machine['uncompiled'] == "true"? "uncompiled" : ""); sMachineVersion = (machine['uncompiled'] && machine['uncompiled'] == "true"? "uncompiled" : "");
sMachineState = machine['state'] || ""; sMachineState = machine['state'] || "";
sReplacement += "(" + sMachineXMLFile + ' "' + sMachine + 'js:' + sMachineID + ':' + sMachineXSLFile + '::' + sMachineOptions + ':' + sMachineState + '")'; sReplacement = "[Embedded PC](" + sMachineXMLFile + ' "' + sMachine + 'js:' + sMachineID + ':' + sMachineXSLFile + '::' + sMachineOptions + ':' + sMachineState + '")';
} }
sBlock = sBlock.replace(aMatch[0], sReplacement); sBlock = sBlock.replace(aMatch[0], sReplacement);
reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over