|
@@ -1,6 +1,9 @@
|
|
|
const TagContext = require('../model/tag-context');
|
|
const TagContext = require('../model/tag-context');
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @private
|
|
|
|
|
+ *
|
|
|
|
|
+ * create random strings
|
|
|
* @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
|
|
* @see http://qiita.com/ryounagaoka/items/4736c225bdd86a74d59c
|
|
|
*
|
|
*
|
|
|
* @param {number} length
|
|
* @param {number} length
|
|
@@ -15,11 +18,20 @@ function createRandomStr(length) {
|
|
|
return generated;
|
|
return generated;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @typedef FindTagAndReplaceResult
|
|
|
|
|
+ * @property {string} html - HTML string
|
|
|
|
|
+ * @property {Object} tagContextMap - Object.<string, [TagContext]{@link ../model/tag-context.html#TagContext}>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @memberof customTagUtils
|
|
|
|
|
+ */
|
|
|
/**
|
|
/**
|
|
|
* @param {RegExp} tagPattern
|
|
* @param {RegExp} tagPattern
|
|
|
* @param {string} html
|
|
* @param {string} html
|
|
|
* @param {function} replace replace function
|
|
* @param {function} replace replace function
|
|
|
- * @return {{html: string, tagContextMap: Object.<string, TagContext>}}
|
|
|
|
|
|
|
+ * @return {FindTagAndReplaceResult}
|
|
|
|
|
+ *
|
|
|
|
|
+ * @memberof customTagUtils
|
|
|
*/
|
|
*/
|
|
|
function findTagAndReplace(tagPattern, html, replace) {
|
|
function findTagAndReplace(tagPattern, html, replace) {
|
|
|
let replacedHtml = html;
|
|
let replacedHtml = html;
|
|
@@ -53,9 +65,24 @@ function findTagAndReplace(tagPattern, html, replace) {
|
|
|
return { html: replacedHtml, tagContextMap };
|
|
return { html: replacedHtml, tagContextMap };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @namespace customTagUtils
|
|
|
|
|
+ */
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
findTagAndReplace,
|
|
findTagAndReplace,
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Context class used by findTagAndReplace
|
|
|
|
|
+ * @memberof customTagUtils
|
|
|
|
|
+ */
|
|
|
TagContext,
|
|
TagContext,
|
|
|
|
|
+ /**
|
|
|
|
|
+ * [ArgsParser]{@link ./args-parser#ArgsParser}
|
|
|
|
|
+ * @memberof customTagUtils
|
|
|
|
|
+ */
|
|
|
ArgsParser: require('./args-parser'),
|
|
ArgsParser: require('./args-parser'),
|
|
|
|
|
+ /**
|
|
|
|
|
+ * [OptionParser]{@link ./option-parser#OptionParser}
|
|
|
|
|
+ * @memberof customTagUtils
|
|
|
|
|
+ */
|
|
|
OptionParser: require('./option-parser'),
|
|
OptionParser: require('./option-parser'),
|
|
|
};
|
|
};
|