mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Add support for !avatar syntax in echo.js.
This commit is contained in:
		@@ -470,6 +470,7 @@ var inline = {
 | 
			
		||||
  emoji: noop,
 | 
			
		||||
  unicodeemoji: noop,
 | 
			
		||||
  usermention: noop,
 | 
			
		||||
  avatar: noop,
 | 
			
		||||
  realm_filters: [],
 | 
			
		||||
  text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
 | 
			
		||||
};
 | 
			
		||||
@@ -528,6 +529,7 @@ inline.zulip = merge({}, inline.breaks, {
 | 
			
		||||
  emoji: /^:([A-Za-z0-9_\-\+]+?):/,
 | 
			
		||||
  unicodeemoji: /^(\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff])/,
 | 
			
		||||
  usermention: /^(@\*\*([^\*]+)?\*\*)/m,
 | 
			
		||||
  avatar: /^!avatar\(([^)]+)\)/,
 | 
			
		||||
  realm_filters: [],
 | 
			
		||||
  text: replace(inline.breaks.text)
 | 
			
		||||
    ('|', '|(\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff])|')
 | 
			
		||||
@@ -752,6 +754,13 @@ InlineLexer.prototype.output = function(src) {
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // user avatar
 | 
			
		||||
    if (cap = this.rules.avatar.exec(src)) {
 | 
			
		||||
      src = src.substring(cap[0].length);
 | 
			
		||||
      out += this.userAvatar(cap[1]);
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // text
 | 
			
		||||
    if (cap = this.rules.text.exec(src)) {
 | 
			
		||||
      src = src.substring(cap[0].length);
 | 
			
		||||
@@ -796,6 +805,13 @@ InlineLexer.prototype.unicodeEmoji = function (name) {
 | 
			
		||||
  return this.options.unicodeEmojiHandler(name);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
InlineLexer.prototype.userAvatar = function (email) {
 | 
			
		||||
  if (typeof this.options.avatarHandler !== 'function')
 | 
			
		||||
    return '!avatar(' + email + ')';
 | 
			
		||||
  return this.options.avatarHandler(email);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
InlineLexer.prototype.realm_filter = function (filter, matches, orig) {
 | 
			
		||||
  if (typeof this.options.realmFilterHandler !== 'function')
 | 
			
		||||
    return;
 | 
			
		||||
@@ -1369,6 +1385,7 @@ marked.defaults = {
 | 
			
		||||
  gfm: true,
 | 
			
		||||
  emoji: false,
 | 
			
		||||
  unicodeemoji: false,
 | 
			
		||||
  avatar: false,
 | 
			
		||||
  tables: true,
 | 
			
		||||
  breaks: false,
 | 
			
		||||
  pedantic: false,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user