Markus-Rost пре 4 година
родитељ
комит
ba4a5cec92
3 измењених фајлова са 7 додато и 9 уклоњено
  1. 0 5
      cmds/wiki/user.js
  2. 4 1
      functions/parse_page.js
  3. 3 3
      functions/phabricator.js

+ 0 - 5
cmds/wiki/user.js

@@ -447,11 +447,6 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 				}
 				embed.addField( gender[0], gender[1], true ).addField( registration[0], registration[1], true );
 				
-				if ( querypage.pageprops && querypage.pageprops.displaytitle ) {
-					var displaytitle = htmlToDiscord( querypage.pageprops.displaytitle );
-					if ( displaytitle.length > 250 ) displaytitle = displaytitle.substring(0, 250) + '\u2026';
-					embed.setTitle( displaytitle );
-				}
 				if ( querypage.pageprops && querypage.pageprops.description ) {
 					var description = htmlToDiscord( querypage.pageprops.description );
 					if ( description.length > 1000 ) description = description.substring(0, 1000) + '\u2026';

+ 4 - 1
functions/parse_page.js

@@ -305,10 +305,13 @@ function parse_page(lang, msg, content, embed, wiki, reaction, {title, contentmo
 					section = $('[id="' + toSection(fragment, false).replace( '#', '' ) + '"]');
 					newFragment = section.attr('id');
 					if ( section.is(':empty') ) section = section.parent();
+					if ( ['h1','h2','h3','h4','h5','h6'].includes( section.prev()[0]?.tagName ) ) {
+						section = section.prev();
+					}
 				}
 				if ( !section.length ) exactMatch = false;
 				if ( !section.length ) section = allSections.filter( (i, span) => {
-					return ( '#' + span.attribs.id.toLowerCase() === toSection(fragment).toLowerCase() );
+					return ( '#' + span.attribs.id?.toLowerCase() === toSection(fragment).toLowerCase() );
 				} );
 				if ( !section.length ) section = allSections.filter( (i, span) => {
 					return ( $(span).parent().text().trim() === fragment );

+ 3 - 3
functions/phabricator.js

@@ -114,9 +114,9 @@ function parse_text(text, site) {
 		else link = site + 'w/' + target;
 		return '[' + ( display || target ) + '](' + link + ')';
 	} );
-	text = text.replace( /@([\w-]+)\b/g, '[@$1](' + site + 'p/$1)' );
-	text = text.replace( /\b\{?(r[A-Z]+[a-f\d]+)\}?\b/g, '[$1](' + site + '$1)' );
-	text = text.replace( /\b\{?([CDFHLMPQTV]\d+(?:#\d+)?)\}?\b/g, '[$1](' + site + '$1)' );
+	text = text.replace( /(?<!\w)@([\w-]+)\b/g, '[@$1](' + site + 'p/$1)' );
+	text = text.replace( /(?<!https?:\/\/[^\s]+)\b\{?(r[A-Z]+[a-f\d]+)\}?\b/g, '[$1](' + site + '$1)' );
+	text = text.replace( /(?<!https?:\/\/[^\s]+)\b\{?([CDFHLMPQTV]\d+(?:#\d+)?)\}?\b/g, '[$1](' + site + '$1)' );
 	text = text.replace( /(?<!https?:\/\/[^\s]+)#([a-z0-9_-]+)\b/g, '[#$1](' + site + 'tag/$1)' );
 	return text;
 }