Browse Source

Multiple small bug fixes

Markus-Rost 4 years ago
parent
commit
92619652ad
4 changed files with 13 additions and 3 deletions
  1. 1 1
      RcGcDb
  2. 1 1
      cmds/eval.js
  3. 1 1
      functions/parse_page.js
  4. 10 0
      util/functions.js

+ 1 - 1
RcGcDb

@@ -1 +1 @@
-Subproject commit 427289a9bcf3e2bcb29d6bbcfdb053eb84b4c7ba
+Subproject commit 6db23b5ed61ae567b8263dc17cc1f390d0599df2

+ 1 - 1
cmds/eval.js

@@ -125,7 +125,7 @@ function checkWiki(wiki) {
 					return;
 				}
 				var posts = dsbody._embedded?.['doc:posts'];
-				result.postid = ( posts[0]?.id || 0 );
+				result.postid = ( posts[0]?.id || '0' );
 				if ( posts?.length ) {
 					let text = '';
 					let len = ( posts[0].creationDate.epochSecond - posts[posts.length - 1].creationDate.epochSecond ) / 60;

+ 1 - 1
functions/parse_page.js

@@ -60,7 +60,7 @@ const keepMainPageTag = [
  * @param {String} [fragment] - The section title to embed.
  */
 function parse_page(msg, {title, contentmodel}, embed, wiki, thumbnail, fragment = '') {
-	if ( !msg || ( embed.description && embed.thumbnail?.url !== thumbnail && !embed.brokenInfobox && !fragment ) ) {
+	if ( !msg?.showEmbed?.() || ( embed.description && embed.thumbnail?.url !== thumbnail && !embed.brokenInfobox && !fragment ) ) {
 		return;
 	}
 	var change = false;

+ 10 - 0
util/functions.js

@@ -175,6 +175,10 @@ function htmlToPlain(html) {
 				text += '• ';
 			}
 			if ( tagname === 'dl' ) listlevel++;
+			if ( tagname === 'dt' ) {
+				if ( !text.endsWith( '\n' ) ) text += '\n';
+				if ( listlevel > -1 ) text += '\u200b '.repeat(4 * listlevel);
+			}
 			if ( tagname === 'dd' ) {
 				if ( !text.endsWith( '\n' ) ) text += '\n';
 				if ( listlevel > -1 ) text += '\u200b '.repeat(4 * (listlevel + 1));
@@ -253,6 +257,11 @@ function htmlToDiscord(html, serverpath = '', ...escapeArgs) {
 				text += '• ';
 			}
 			if ( tagname === 'dl' ) listlevel++;
+			if ( tagname === 'dt' ) {
+				if ( !text.endsWith( '\n' ) ) text += '\n';
+				if ( listlevel > -1 ) text += '\u200b '.repeat(4 * listlevel);
+				text += '**';
+			}
 			if ( tagname === 'dd' ) {
 				if ( !text.endsWith( '\n' ) ) text += '\n';
 				if ( listlevel > -1 ) text += '\u200b '.repeat(4 * (listlevel + 1));
@@ -290,6 +299,7 @@ function htmlToDiscord(html, serverpath = '', ...escapeArgs) {
 			if ( tagname === 'sup' ) reference = false;
 			if ( tagname === 'ul' ) listlevel--;
 			if ( tagname === 'dl' ) listlevel--;
+			if ( tagname === 'dt' ) text += '**';
 			if ( tagname === 'h1' ) text += '__***';
 			if ( tagname === 'h2' ) text += '__**';
 			if ( tagname === 'h3' ) text += '**';