|
|
@ -1146,7 +1146,7 @@ angular.module('izhukov.utils', []) |
|
|
|
var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i; |
|
|
|
var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i; |
|
|
|
var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i; |
|
|
|
var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i; |
|
|
|
|
|
|
|
|
|
|
|
var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)|(^|\s)`([^\n]+?)`/; |
|
|
|
var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)([\s\.,:?!;]|$)|(^|\s)`([^\n]+?)`([\s\.,:?!;]|$)/; |
|
|
|
|
|
|
|
|
|
|
|
var siteHashtags = { |
|
|
|
var siteHashtags = { |
|
|
|
Telegram: '#/im?q=%23{1}', |
|
|
|
Telegram: '#/im?q=%23{1}', |
|
|
@ -1325,21 +1325,25 @@ angular.module('izhukov.utils', []) |
|
|
|
matchIndex = rawOffset + match.index; |
|
|
|
matchIndex = rawOffset + match.index; |
|
|
|
newText.push(raw.substr(0, match.index)); |
|
|
|
newText.push(raw.substr(0, match.index)); |
|
|
|
|
|
|
|
|
|
|
|
if (match[3]) { // pre
|
|
|
|
var text = (match[3] || match[7]).replace(/^\s+|\s+$/g, ''); |
|
|
|
newText.push(match[1] + match[3]); |
|
|
|
if (text.match(/^`*$/)) { |
|
|
|
|
|
|
|
newText.push(match[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (match[3]) { // pre
|
|
|
|
|
|
|
|
newText.push(match[1] + text + match[5]); |
|
|
|
entities.push({ |
|
|
|
entities.push({ |
|
|
|
_: 'messageEntityPre', |
|
|
|
_: 'messageEntityPre', |
|
|
|
language: '', |
|
|
|
language: '', |
|
|
|
offset: matchIndex + match[1].length, |
|
|
|
offset: matchIndex + match[1].length, |
|
|
|
length: match[3].length |
|
|
|
length: text.length |
|
|
|
}); |
|
|
|
}); |
|
|
|
rawOffset -= match[2].length + match[4].length; |
|
|
|
rawOffset -= match[2].length + match[4].length; |
|
|
|
} else { // code
|
|
|
|
} else { // code
|
|
|
|
newText.push(match[5] + match[6]); |
|
|
|
newText.push(match[6] + text + match[8]); |
|
|
|
entities.push({ |
|
|
|
entities.push({ |
|
|
|
_: 'messageEntityCode', |
|
|
|
_: 'messageEntityCode', |
|
|
|
offset: matchIndex + match[5].length, |
|
|
|
offset: matchIndex + match[6].length, |
|
|
|
length: match[6].length |
|
|
|
length: text.length |
|
|
|
}); |
|
|
|
}); |
|
|
|
rawOffset -= 2; |
|
|
|
rawOffset -= 2; |
|
|
|
} |
|
|
|
} |
|
|
@ -1347,7 +1351,13 @@ angular.module('izhukov.utils', []) |
|
|
|
rawOffset += match.index + match[0].length; |
|
|
|
rawOffset += match.index + match[0].length; |
|
|
|
} |
|
|
|
} |
|
|
|
newText.push(raw); |
|
|
|
newText.push(raw); |
|
|
|
return newText.join(''); |
|
|
|
newText = newText.join(''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!newText.replace(/\s+/g, '').length) { |
|
|
|
|
|
|
|
newText = text; |
|
|
|
|
|
|
|
entities.splice(0, entities.length); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return newText; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function mergeEntities (currentEntities, newEntities, fromApi) { |
|
|
|
function mergeEntities (currentEntities, newEntities, fromApi) { |
|
|
|