2
0
Эх сурвалжийг харах

Styling: Remove line-break at end of blockquote

since the DOM element breaks the line already
JC Brand 4 жил өмнө
parent
commit
fb316ff010

+ 3 - 3
spec/styling.js

@@ -256,7 +256,7 @@ describe("An incoming chat Message", function () {
         msg_el = Array.from(view.el.querySelectorAll('converse-chat-message-body')).pop();
         expect(msg_el.innerText).toBe(msg_text);
         await u.waitUntil(() => msg_el.innerHTML.replace(/<!---->/g, '') ===
-            '<blockquote> This is quoted text\nThis is also quoted</blockquote>\nThis is not quoted');
+            '<blockquote> This is quoted text\nThis is also quoted</blockquote>This is not quoted');
 
         msg_text = `> This is *quoted* text\n>This is \`also _quoted_\`\nThis is not quoted`;
         msg = mock.createChatMessage(_converse, contact_jid, msg_text)
@@ -266,7 +266,7 @@ describe("An incoming chat Message", function () {
         expect(msg_el.innerText).toBe(msg_text);
         await u.waitUntil(() => msg_el.innerHTML.replace(/<!---->/g, '') ===
             '<blockquote> This is <span class="styling-directive">*</span><b>quoted</b><span class="styling-directive">*</span> text\n'+
-            'This is <span class="styling-directive">`</span><code>also _quoted_</code><span class="styling-directive">`</span></blockquote>\n'+
+            'This is <span class="styling-directive">`</span><code>also _quoted_</code><span class="styling-directive">`</span></blockquote>'+
             'This is not quoted');
 
         msg_text = `> > This is doubly quoted text`;
@@ -298,7 +298,7 @@ describe("An incoming chat Message", function () {
         msg_el = Array.from(view.el.querySelectorAll('converse-chat-message-body')).pop();
         expect(msg_el.innerText).toBe(msg_text);
         await u.waitUntil(() => msg_el.innerHTML.replace(/<!---->/g, '') ===
-            '<blockquote> ```\n (println "Hello, world!")</blockquote>\n\n'+
+            '<blockquote> ```\n (println "Hello, world!")</blockquote>\n'+
             'The entire blockquote is a preformatted text block, but this line is plaintext!');
         done();
     }));

+ 1 - 1
src/shared/message/styling.js

@@ -141,7 +141,7 @@ export const isQuoteDirective = (d) => ['>', '&gt;'].includes(d);
 export function getDirectiveTemplate (d, text, model, offset) {
     const template = styling_templates[styling_map[d].name];
     if (isQuoteDirective(d)) {
-        return template(text.replace(/\n>/g, '\n'), model, offset);
+        return template(text.replace(/\n>/g, '\n').replace(/\n$/, ''), model, offset);
     } else {
         return template(text, model, offset);
     }

+ 1 - 1
src/shared/message/text.js

@@ -140,7 +140,7 @@ export class MessageText extends String {
                 const { d, length } = getDirectiveAndLength(this, i);
                 if (d && length) {
                     const begin = d === '```' ? i+d.length+1 : i+d.length;
-                    const end = i+length;
+                    const end = isQuoteDirective(d) ? i+length+1 : i+length;
                     const slice_end = isQuoteDirective(d) ? end : end-d.length;
                     references.push({
                         'begin': i,