Browse Source

Improved markdown

master
Igor Zhukov 9 years ago
parent
commit
e9f790b8ea
  1. 16
      app/js/lib/ng_utils.js

16
app/js/lib/ng_utils.js

@ -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)`([^\n]+?)`/;
var siteHashtags = { var siteHashtags = {
Telegram: '#/im?q=%23{1}', Telegram: '#/im?q=%23{1}',
@ -1325,21 +1325,21 @@ 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[2]) { // pre if (match[3]) { // pre
newText.push(match[1] + match[2]); newText.push(match[1] + match[3]);
entities.push({ entities.push({
_: 'messageEntityPre', _: 'messageEntityPre',
language: '', language: '',
offset: matchIndex + match[1].length, offset: matchIndex + match[1].length,
length: match[2].length length: match[3].length
}); });
rawOffset -= 6; rawOffset -= match[2].length + match[4].length;
} else { // code } else { // code
newText.push(match[3] + match[4]); newText.push(match[5] + match[6]);
entities.push({ entities.push({
_: 'messageEntityCode', _: 'messageEntityCode',
offset: matchIndex + match[3].length, offset: matchIndex + match[5].length,
length: match[4].length length: match[6].length
}); });
rawOffset -= 2; rawOffset -= 2;
} }

Loading…
Cancel
Save