From e15366a725734e31eeaaab2ba44084a7a8498868 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 16 Dec 2015 16:52:50 -0800 Subject: [PATCH] Node.js update to disable converting a Jekyll-style machine to an actual machine if a machine XML file was already processed --- modules/htmlout/lib/htmlout.js | 9 +++++---- modules/markout/lib/markout.js | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/htmlout/lib/htmlout.js b/modules/htmlout/lib/htmlout.js index 855897dff..2e35b6777 100644 --- a/modules/htmlout/lib/htmlout.js +++ b/modules/htmlout/lib/htmlout.js @@ -1400,7 +1400,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS s = m.convertMD(" ").trim(); obj.processMachines(m.getMachines(), function doneProcessXMLMachines() { - obj.getReadMe(sToken, sIndent, aParms, s); + obj.getReadMe(sToken, sIndent, aParms, s, true); }); 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. * @@ -1635,8 +1635,9 @@ HTMLOut.prototype.getManifestXML = function(sToken, sIndent, aParms) * @param {string} [sIndent] * @param {Array.} [aParms] * @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 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 } } 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(); /* * If the Markdown document begins with a heading, stuff that into the tag; diff --git a/modules/markout/lib/markout.js b/modules/markout/lib/markout.js index a9409c78a..217968e0c 100644 --- a/modules/markout/lib/markout.js +++ b/modules/markout/lib/markout.js @@ -95,8 +95,9 @@ var sDefaultFile = "./README.md"; * @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 {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.sIndent = (sIndent || ""); @@ -109,6 +110,7 @@ function MarkOut(sMD, sIndent, req, aParms, fDebug) this.sClassImageLabel = this.sClassImage + "-label"; } this.fDebug = fDebug; + this.fMachineXML = fMachineXML; this.sHTML = null; 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 @@ -993,9 +995,9 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock) var reIncludes = /\{%\s*include machine\.html\s+id="(.*?)"\s*%}/g; while ((aMatch = reIncludes.exec(sBlock))) { + sReplacement = ""; sMachineID = aMatch[1]; - sReplacement = "[Embedded PC]"; - if (this.aMachineDefs[sMachineID]) { + if (!this.fMachineXML && this.aMachineDefs[sMachineID]) { var machine = this.aMachineDefs[sMachineID]; sMachine = machine['type'] || "pc"; sMachineOptions = (sMachine.indexOf("-dbg") > 0? "debugger" : ""); @@ -1004,7 +1006,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock) sMachineXSLFile = machine['template'] || ""; sMachineVersion = (machine['uncompiled'] && machine['uncompiled'] == "true"? "uncompiled" : ""); 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); reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over