@@ -0,1 +1,3 @@ | ||
| const crypto = require('crypto'); | ||
| var disableRadio = false; | ||
@@ -21,3 +23,6 @@ var useLabelWrapper = true; | ||
| } else { | ||
| group = Math.random().toString(36).substr(2, 5); // generate a new group id | ||
| group = crypto.createHash('md5') | ||
| .update(tokens[i-5].content) | ||
| .update(tokens[i-4].content) | ||
| .update(tokens[i].content).digest('hex').substr(2, 5); // generate a deterministic group id | ||
| } | ||
@@ -114,2 +119,2 @@ radioify(tokens[i], state.Token, group); | ||
| return token.content.indexOf('( ) ') === 0 || token.content.indexOf('(x) ') === 0 || token.content.indexOf('(X) ') === 0; | ||
| } | ||
| } |
+31
-5
@@ -40,3 +40,3 @@ 'use strict'; | ||
| Parser.prototype._preprocess = function (element, context) { | ||
| Parser.prototype._preprocess = function (element, context, config) { | ||
| let self = this; | ||
@@ -102,2 +102,3 @@ element.attribs = element.attribs || {}; | ||
| : md.render(htmlContent); | ||
| actualContent = self._rebaseReferenceForStaticIncludes(actualContent, element, config); | ||
| if (!isIncludeSrcMd) { | ||
@@ -126,3 +127,3 @@ // Include HTML. Just let it be. | ||
| element.children = element.children.map((e) => { | ||
| return self._preprocess(e, childContext); | ||
| return self._preprocess(e, childContext, config); | ||
| }); | ||
@@ -165,3 +166,3 @@ } | ||
| element.children = element.children.map((e) => { | ||
| return self._preprocess(e, context); | ||
| return self._preprocess(e, context, config); | ||
| }); | ||
@@ -282,3 +283,3 @@ } | ||
| Parser.prototype.includeFile = function (file, cb) { | ||
| Parser.prototype.includeFile = function (file, config, cb) { | ||
| cb = cb || function () {}; // create empty callback | ||
@@ -298,3 +299,3 @@ | ||
| let nodes = dom.map(d => { | ||
| return this._preprocess(d, context); | ||
| return this._preprocess(d, context, config); | ||
| }); | ||
@@ -475,2 +476,27 @@ resolve(cheerio.html(nodes)); | ||
| Parser.prototype._rebaseReferenceForStaticIncludes = function (pageData, element, config) { | ||
| if (!config) { | ||
| return pageData; | ||
| } | ||
| if (!pageData.includes('{{baseUrl}}')) { | ||
| return pageData; | ||
| } | ||
| let filePath = element.attribs[ATTRIB_INCLUDE_PATH]; | ||
| let fileBase = calculateNewBaseUrl(filePath, config.rootPath, config.baseUrlMap); | ||
| if (!fileBase.relative) { | ||
| return pageData; | ||
| } | ||
| let currentPath = element.attribs[ATTRIB_CWF]; | ||
| let currentBase = calculateNewBaseUrl(currentPath, config.rootPath, config.baseUrlMap); | ||
| if (currentBase.relative === fileBase.relative) { | ||
| return pageData; | ||
| } | ||
| let newBase = fileBase.relative; | ||
| return nunjucks.renderString(pageData, { baseUrl: `{{hostBaseUrl}}/${newBase}` }); | ||
| }; | ||
| function calculateNewBaseUrl(filePath, root, lookUp) { | ||
@@ -477,0 +503,0 @@ function calculate(file, result) { |
+1
-1
| { | ||
| "name": "markbind", | ||
| "version": "1.1.5", | ||
| "version": "1.1.6", | ||
| "description": "MarkBind core module.", | ||
@@ -5,0 +5,0 @@ "main": "lib/parser.js", |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
104249
0.48%1126
2.36%21
-4.55%