refactor: move `stripParens` to next upper closure

pull/11/head
David Ordás 2022-09-17 12:43:21 +02:00
parent db5f8992ef
commit 8f9bd348ea
No known key found for this signature in database
GPG Key ID: 6FD751229911593E
1 changed files with 10 additions and 4 deletions

View File

@ -22,6 +22,16 @@ const excludes = [
"SUMMARY.md",
];
/**
* Strip wrapped parenthesis from a string.
* @param {string} s - the string to process
* @returns {string} the stripped string if parens found, the input string if don't
*/
function stripParens(s) {
if (s.slice(0, 1) === "(" && s.slice(-1) === ")") return s.slice(1, -1);
return s;
}
/**
* Wraps a string between other that acts as token.
* @param {string} text - the text to wrap
@ -106,10 +116,6 @@ function getLinkTextFromLinkNodes(children) {
* @return {Object} Returns an Object containing details about the piece of media.
*/
function parseListItem(listItem) {
let stripParens = function (s) {
if (s.slice(0, 1) === "(" && s.slice(-1) === ")") return s.slice(1, -1);
return s;
};
let entry = {};
let s = ""; // If we need to build up a string over multiple listItem elements
let leftParen,