Styling: Remove line-break at end of blockquote

since the DOM element breaks the line already
This commit is contained in:
JC Brand 2020-11-25 16:11:36 +01:00
parent d2074afe9a
commit fb316ff010
3 changed files with 5 additions and 5 deletions

View File

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

View File

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

View File

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