markup-tools
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mtools=e():t.mtools=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";const n={};n.links=r(1),n.images=r(2),n.text=r(3);const i={};i.links=r(4),i.images=r(5);const o={};o.mentions=r(6),o.hashtags=r(7),o.links=r(8),o.images=r(9),o.template=r(10),t.exports={format:n,parse:i,build:o}},function(t,e,r){"use strict";t.exports=function(t,e){var r=e||"";try{return t.replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,r)}catch(t){return""}}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n;if(e){if(e="."==e[0]?e.substr(1):e,-1==["jpeg","jpg","png","gif","svg","bmp","tif","tiff"].indexOf(e))return"";n=new RegExp("([a-z-_0-9/:.]*.("+e+"))","gi")}else n=/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi;var i=r||"";try{return t.replace(n,i)}catch(t){return""}}},function(t,e,r){"use strict";t.exports=function(t,e){var r=e?Math.min(Number(e),160):null,n=t.replace(/<[^>]+>/g,"").replace(/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi,"").replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,"").replace(/\r?\n|\r/g," ");if(r){var i=n.trim();return i.length>e?i.substring(0,e)+"... ":i}return n}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,i,o="raw"==r||"href"==r?r:"raw",u=e||0;return"raw"==o?(n=/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,(i=t.match(n))?i[u]:""):"href"==o?(n=n=/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/gi,(i=t.match(n))&&(i=i.map(function(t){var e=t.split('"');return e[e.length-2]})),i?i[u]:""):void 0}},function(t,e,r){"use strict";t.exports=function(t,e,r,n){var i,o,u="raw"==n||"src"==n?n:"raw";r&&(r="."==r[0]?r.substring(1):r);var f=e||0;if("raw"==u){if(r){if(-1==["jpeg","jpg","png","gif","svg","bmp","tif","tiff"].indexOf(r))return"";i=new RegExp("([a-z-_0-9/:.]*.("+r+"))","gi")}else i=/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi;return(o=t.match(i))?o[f]:""}if("src"==u)return i=/<\s*img(?:[^>]*)src\s*=\s*([\"\']([^\"\']+))/gi,(o=t.match(i))&&(o=o.map(function(t){var e=t.split('"');return e[e.length-1]})),r&&(o=o.filter(t=>~t.indexOf("."+r))),o?o[f]:""}},function(t,e,r){"use strict";t.exports=function(t,e){return t.replace(/(^|[^a-zA-Z0-9_!#$%&*@@\/]|(^|[^a-zA-Z0-9_+~.-\/#]))[@@]([a-z][-\.a-z\d]+[a-z\d])/gi,(t,r,n,i)=>{const o=i.toLowerCase(),u=o,f=e?e.replace(/\/$/,""):"/@",s=(r||"")+(n||"");return u?s+'<a target="_blank" href="'+f+("/@"==f?"":"/")+o+'">@'+i+"</a>":s+"@"+i})}},function(t,e,r){"use strict";t.exports=function(t,e){return t.replace(/(^|\s)(#[-a-z\d]+)/gi,t=>{if(/#[\d]+$/.test(t))return t;const r=/^\s/.test(t)?t[0]:"",n=t.trim().substring(1).toLowerCase();return r+'<a target="_blank" href="'+(e?e.replace(/\/$/,""):"/trending")+"/"+n+' ">'+t+" </a>"})}},function(t,e,r){"use strict";t.exports=function(t,e){return(t||"").replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,function(t,r,n){var i=n.split("<")[0];i.match("^https?://")||(i="http://"+i);const o={};if(o.video=!!e,o.width=o.video&&e.width||640,o.height=o.video&&e.height||360,o.frameborder=o.video&&e.frameborder||0,o.attributes=o.video&&e.attributes||"allowfullscreen> ",!o.video)return r+'<a href="'+i+'">'+n+"</a>";var u=i.match(/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);if(!u||11!=u[2].length)return r+'<a href="'+i+'">'+n+"</a>";var f=u[2];return f?'<iframe width="'+o.width+'" height="'+o.height+'" src="https://www.youtube.com/embed/'+f+'" frameborder="'+o.frameborder+'" '+o.attributes+"</iframe>":void 0})}},function(t,e,r){"use strict";t.exports=function(t){return t.replace(/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif|bmp|svg|tif|tiff)(?!["\)]))/gi,t=>'<img src="'+t+'" /><br/>')}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n=r||"";return(t||"").replace(/{{(.*?)}}/gi,function(t,r,i){return e[r]||n})}}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mtools=e():t.mtools=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n={};n.links=r(1),n.images=r(2),n.text=r(3);var i={};i.links=r(4),i.images=r(5);var u={};u.mentions=r(6),u.hashtags=r(7),u.links=r(8),u.images=r(9),u.template=r(10),t.exports={format:n,parse:i,build:u}},function(t,e,r){"use strict";t.exports=function(t,e){var r=e||"";try{return t.replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,r)}catch(t){return""}}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n;if(e){if(e="."==e[0]?e.substr(1):e,-1==["jpeg","jpg","png","gif","svg","bmp","tif","tiff"].indexOf(e))return"";n=new RegExp("([a-z-_0-9/:.]*.("+e+"))","gi")}else n=/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi;var i=r||"";try{return t.replace(n,i)}catch(t){return""}}},function(t,e,r){"use strict";t.exports=function(t,e){var r=e?Math.min(Number(e),160):null,n=t.replace(/<[^>]+>/g,"").replace(/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi,"").replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,"").replace(/\r?\n|\r/g," ");if(r){var i=n.trim();return i.length>e?i.substring(0,e)+"... ":i}return n}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n,i,u="raw"==r||"href"==r?r:"raw",f=e||0;return"raw"==u?(n=/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,(i=t.match(n))?i[f]:""):"href"==u?(n=n=/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/gi,(i=t.match(n))&&(i=i.map(function(t){var e=t.split('"');return e[e.length-2]})),i?i[f]:""):void 0}},function(t,e,r){"use strict";t.exports=function(t,e,r,n){var i,u,f="raw"==n||"src"==n?n:"raw";r&&(r="."==r[0]?r.substring(1):r);var o=e||0;if("raw"==f){if(r){if(-1==["jpeg","jpg","png","gif","svg","bmp","tif","tiff"].indexOf(r))return"";i=new RegExp("([a-z-_0-9/:.]*.("+r+"))","gi")}else i=/([a-z\-_0-9\/\:\.]*\.(jpe?g|bmp|svg|png|gif|tif|tiff))/gi;return(u=t.match(i))?u[o]:""}if("src"==f)return i=/<\s*img(?:[^>]*)src\s*=\s*([\"\']([^\"\']+))/gi,(u=t.match(i))&&(u=u.map(function(t){var e=t.split('"');return e[e.length-1]})),r&&(u=u.filter(t=>~t.indexOf("."+r))),u?u[o]:""}},function(t,e,r){"use strict";t.exports=function(t,e){return t.replace(/(^|[^a-zA-Z0-9_!#$%&*@@\/]|(^|[^a-zA-Z0-9_+~.-\/#]))[@@]([a-z][-\.a-z\d]+[a-z\d])/gi,(t,r,n,i)=>{var u=i.toLowerCase(),f=u,o=e?e.replace(/\/$/,""):"/@",a=(r||"")+(n||"");return f?a+'<a target="_blank" href="'+o+("/@"==o?"":"/")+u+'">@'+i+"</a>":a+"@"+i})}},function(t,e,r){"use strict";t.exports=function(t,e){return t.replace(/(^|\s)(#[-a-z\d]+)/gi,t=>{if(/#[\d]+$/.test(t))return t;var r=/^\s/.test(t)?t[0]:"",n=t.trim().substring(1).toLowerCase();return r+'<a target="_blank" href="'+(e?e.replace(/\/$/,""):"/trending")+"/"+n+' ">'+t+" </a>"})}},function(t,e,r){"use strict";t.exports=function(t,e){return(t||"").replace(/([^\S]|^)(((https?\:\/\/)|(www\.))(\S+))/gi,function(t,r,n){var i=n.split("<")[0];i.match("^https?://")||(i="http://"+i);var u={};if(u.video=!!e,u.width=u.video&&e.width||640,u.height=u.video&&e.height||360,u.frameborder=u.video&&e.frameborder||0,u.attributes=u.video&&e.attributes||"allowfullscreen> ",!u.video)return r+'<a href="'+i+'">'+n+"</a>";var f=i.match(/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);if(!f||11!=f[2].length)return r+'<a href="'+i+'">'+n+"</a>";var o=f[2];return o?'<iframe width="'+u.width+'" height="'+u.height+'" src="https://www.youtube.com/embed/'+o+'" frameborder="'+u.frameborder+'" '+u.attributes+"</iframe>":void 0})}},function(t,e,r){"use strict";t.exports=function(t){return t.replace(/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif|bmp|svg|tif|tiff)(?!["\)]))/gi,t=>'<img src="'+t+'" /><br/>')}},function(t,e,r){"use strict";t.exports=function(t,e,r){var n=r||"";return(t||"").replace(/{{(.*?)}}/gi,function(t,r,i){return e[r]||n})}}])}); |
@@ -6,6 +6,6 @@ 'use strict'; | ||
if (/#[\d]+$/.test(tag)) return tag; // Don't allow numbers to be tags | ||
const space = /^\s/.test(tag) ? tag[0] : ''; | ||
const tag2 = tag.trim().substring(1); | ||
const tagLower = tag2.toLowerCase(); | ||
const filler = scheme ? scheme.replace(/\/$/, '') : '/trending'; | ||
var space = /^\s/.test(tag) ? tag[0] : ''; | ||
var tag2 = tag.trim().substring(1); | ||
var tagLower = tag2.toLowerCase(); | ||
var filler = scheme ? scheme.replace(/\/$/, '') : '/trending'; | ||
return ( | ||
@@ -12,0 +12,0 @@ space + |
@@ -12,3 +12,3 @@ 'use strict'; | ||
const config = {}; | ||
var config = {}; | ||
config.video = video ? true : false; | ||
@@ -15,0 +15,0 @@ config.width = config.video ? (video.width || 640) : 640; |
@@ -8,9 +8,8 @@ 'use strict'; | ||
(match, preceeding1, preceeding2, user) => { | ||
const userLower = user.toLowerCase(); | ||
//const valid = validate_account_name(userLower) == null; | ||
const valid = userLower; | ||
const filler1 = scheme ? scheme.replace(/\/$/, '') : '/@'; | ||
const filler2 = filler1 == '/@' ? '' : '/'; | ||
var userLower = user.toLowerCase(); | ||
var valid = userLower; | ||
var filler1 = scheme ? scheme.replace(/\/$/, '') : '/@'; | ||
var filler2 = filler1 == '/@' ? '' : '/'; | ||
const preceedings = (preceeding1 || '') + (preceeding2 || ''); // include the preceeding matches if they exist | ||
var preceedings = (preceeding1 || '') + (preceeding2 || ''); // include the preceeding matches if they exist | ||
@@ -17,0 +16,0 @@ return valid |
'use strict'; | ||
//formatters | ||
const format = {}; | ||
var format = {}; | ||
format.links = require('./formatters/links.js'); | ||
@@ -10,3 +10,3 @@ format.images = require('./formatters/images.js'); | ||
//parsers | ||
const parse = {}; | ||
var parse = {}; | ||
parse.links = require('./parsers/links.js'); | ||
@@ -16,3 +16,3 @@ parse.images = require('./parsers/images.js'); | ||
//builders | ||
const build = {}; | ||
var build = {}; | ||
build.mentions = require('./builders/mentions.js'); | ||
@@ -19,0 +19,0 @@ build.hashtags = require('./builders/hashtags.js'); |
{ | ||
"name": "markup-tools", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "Utility to format markup", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
25781
251