diff --git a/helpers/posting/linkmatch.js b/helpers/posting/linkmatch.js index 01317c35..56dcbbae 100644 --- a/helpers/posting/linkmatch.js +++ b/helpers/posting/linkmatch.js @@ -1,34 +1,20 @@ 'use strict'; -const parenPairRegex = /\((?:[^)(]+|\((?:[^)(]+|\([^)(]\))*\))*\)/g -// , config = require(__dirname+'/../../config.js'); - module.exports = (permLevel, match, p1, p2, p3, offset, string, groups) => { - let { url, label, urlOnly } = groups - , excess = ''; + + let { url, label, urlOnly } = groups; + +console.log(url, label, urlOnly) + url = url || urlOnly; - if (urlOnly) { - const parensPairs = url.match(parenPairRegex); - let trimmedMatch = url; - //naive solution to conflict with detected markdown - if (parensPairs) { - const lastMatch = parensPairs[parensPairs.length-1]; - const lastIndex = url.lastIndexOf(lastMatch); - trimmedMatch = url.substring(0, lastIndex+lastMatch.length); - excess = url.substring(lastIndex+lastMatch.length); - } else if (url.indexOf(')') !== -1){ - trimmedMatch = url.substring(0, url.indexOf(')')); - excess = url.substring(url.indexOf(')')); - } - url = trimmedMatch; - } if (permLevel >= 4) { label = url .replace(/\(/g, '(') .replace(/\)/g, ')'); } url = url.replace(/\(/g, '%28') - .replace(/\)/g, '%29'); + .replace(/\)/g, '%29'); + /* //todo: Something to revisit later const href = url; @@ -41,5 +27,7 @@ module.exports = (permLevel, match, p1, p2, p3, offset, string, groups) => { } catch (e) { } } */ - return `${label || url}${excess}`; + + return `${label || url}`; + }; diff --git a/helpers/posting/markdown.js b/helpers/posting/markdown.js index dccfebb6..2c3d0be0 100644 --- a/helpers/posting/markdown.js +++ b/helpers/posting/markdown.js @@ -9,7 +9,7 @@ const greentextRegex = /^>((?!>\d+|>>/\w+(/\d*)?|>># , strikeRegex = /~~(.+?)~~/gm , italicRegex = /\*\*(.+?)\*\*/gm , spoilerRegex = /\|\|([\s\S]+?)\|\|/gm - , detectedRegex = /(\(\(\(.+?\)\)\))/gm + , detectedRegex = /\(\(\((.+?)\)\)\)/gm , linkRegex = /\[(?