Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function conv (anchor, txt) {
/* convert types */
txt = xre.replace(txt, xre("R<([^/].*?)>", "sg"), function (m0, m1) { return "<span class="\"R\"">" + mklink(anchor, m1) + "</span>"; });
txt = xre.replace(txt, xre("M<([^/].*?)>", "sg"), function (m0, m1) { return "<span class="\"M\"">" + mklink(anchor, m1) + "</span>"; });
txt = xre.replace(txt, xre("P<([^/].*?)>", "sg"), "<span class="\"P\"">$1</span>");
txt = xre.replace(txt, xre("F<([^/].*?)>", "sg"), "<span class="\"F\"">$1</span>");
txt = xre.replace(txt, xre("T<([^/].*?)>", "sg"), "<span class="\"T\"">$1</span>");
txt = xre.replace(txt, xre("O<([^/].*?)>", "sg"), "<span class="\"O\"">$1</span>");
txt = xre.replace(txt, xre("C<([^/].*?)>", "sg"), "<code>$1</code>");
txt = xre.replace(txt, xre("I<([^/].*?):(\\d+)>", "sg"), "<img width="\"$2\"/" src="\"$1\"" style="\"float:">");
/* convert typography aspects */
txt = xre.replace(txt, xre("->", "sg"), "→");
txt = xre.replace(txt, xre("<-", "sg"), "←");
txt = xre.replace(txt, xre("--", "sg"), "—");
txt = xre.replace(txt, xre("(FIXME|TODO)", "sg"), "<span class="\"$1\"">$1</span>");
return txt;
}
function parse4 (title, synopsis, body) {
html_spec += "<li>";
/* parse fifth-level structure (part 1) */
var txt = synopsis;
txt = xre.replace(txt, xre("M<(.+?)>", "sg"), function (m0, m1) {
parse5a(title, m1);
});
/* process fifth-level structure */
function parse5a (title, txt) {
if (!cache[title + ":" + txt]) {
html_navi += "</li><li>" + mklink(0, txt) + "</li>";
cache[title + ":" + txt] = true;
}
}
/* generate synopsis */
html_spec += "<div class="\"synopsis\"">";
synopsis = xre.replace(synopsis, xre("[ \\t]{2,}", "sg"), " ");
synopsis = conv(1, synopsis);
synopsis = xre.replace(synopsis, xre("(\\[|\\]|:|\\s+=\\s+)", "sg"), "<span class="\"meta\"">$1</span>");</div>
}
}
text = ` ${text} `;
const whitelist = this.cListsWhitelist;
for (const value of whitelist.map(o => o.trim().replace(/\*/g, '[\\pL0-9\\S]*').replace(/\+/g, '[\\pL0-9\\S]+'))) {
if (value.length > 0) {
let regexp;
if (value.startsWith('domain:')) {
regexp = XRegExp(` [\\S]*${XRegExp.escape(value.replace('domain:', ''))}[\\S]* `, 'gi');
} else { // default regexp behavior
regexp = XRegExp(` [^\\s\\pL0-9\\w]?${value}[^\\s\\pL0-9\\w]? `, 'gi');
}
// we need to change 'text' to ' text ' for regexp to correctly work
text = XRegExp.replace(` ${text} `, regexp, '').trim();
}
}
return text.trim();
}
var txt = synopsis;
txt = xre.replace(txt, xre("M<(.+?)>", "sg"), function (m0, m1) {
parse5a(title, m1);
});
/* process fifth-level structure */
function parse5a (title, txt) {
if (!cache[title + ":" + txt]) {
html_navi += "<li>" + mklink(0, txt) + "</li>";
cache[title + ":" + txt] = true;
}
}
/* generate synopsis */
html_spec += "<div class="\"synopsis\"">";
synopsis = xre.replace(synopsis, xre("[ \\t]{2,}", "sg"), " ");
synopsis = conv(1, synopsis);
synopsis = xre.replace(synopsis, xre("(\\[|\\]|:|\\s+=\\s+)", "sg"), "<span class="\"meta\"">$1</span>");
synopsis = xre.replace(synopsis, xre(";", "sg"), "</div><div class="\"synopsis\"">");
synopsis = xre.replace(synopsis, xre("\\(\\s+", "sg"), "(");
synopsis = xre.replace(synopsis, xre("\\s+\\)", "sg"), ")");
html_spec += synopsis + "\n";
html_spec += "</div>";
/* parse fifth-level structure (part 2) */
txt = body + "\n";
txt = xre.replace(txt, xre(
"(.+?\\n)" +
"(?= \\n | $ )",
"sgx"), function (m0, m1) {
parse5b(m1);
});
body = xre.replace(body, xre(
"^(.+?\\n)" + // intro paragraph
"(?=\\n-[ \\t]+\\S+)", // start of first function
"s"), function (m0, m1) {
html_spec += "<div class="\"intro\"">" + addpara(conv(0, m1)) + "</div>";
});
function addpara (txt) {
txt = xre.replace(txt, xre("(\\n).[ \\t]+([^\\n]*(?:\\n[ \\t]+[^\\n]+)*)", "sg"), "$1<li>$2</li>");
txt = xre.replace(txt, xre("(\\n\\n)(<li>)", "sg"), "$1<ul>$2");
txt = xre.replace(txt, xre("(<\/li>)(\\n\\n)", "sg"), "$1</ul>$2");
txt = xre.replace(txt, xre("\\n{2,}", "sg"), "<p>\n");
return txt;
}
/* parse second-level structure (part 2) */
body = xre.replace(body, xre(
"-[ \\t]+(\\S+.+?)" + // function start
"(?=-[ \\t]+\\S+" + // start of next function
"|$)", // or end of file
"sg"), function (m0, m1) {
parse3(title, m1);
});
/* process third-level structure */
function parse3 (title, body) {
html_spec += "</p><ul>\n";
/* parse forth-level structure */
body = xre.replace(body, xre(
"^" +
"(.+?)\\n" + // synopsis
"\\n" + // blank line</ul></li>
function splitCamelCaseWord(word) {
const wPrime = word.replace(regExUpperSOrIng, s => s[0] + s.substr(1).toLowerCase());
const separator = '_<^*_*^>_';
const pass1 = XRegExp.replace(wPrime, regExSplitWords, '$1' + separator + '$2');
const pass2 = XRegExp.replace(pass1, regExSplitWords2, '$1' + separator + '$2');
return XRegExp.split(pass2, separator);
}
exports.splitCamelCaseWord = splitCamelCaseWord;
function autolinkEmails(text, tokens) {
function replaceEmailWithToken(fullMatch, prefix, email) {
const index = tokens.size;
const alias = `$MM_EMAIL${index}$`;
tokens.set(alias, {
value: `<a href="mailto:${email}" class="theme">${email}</a>`,
originalText: email,
});
return prefix + alias;
}
let output = text;
output = XRegExp.replace(text, reEmail, replaceEmailWithToken);
return output;
}
function mkid (id) {
id = id.toLowerCase();
id = xre.replace(id, xre("\\s+", "sg"), "_");
id = xre.replace(id, xre("-", "sg"), "_");
return id;
}