mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-28 23:08:12 +09:00
Fix #2720
This commit is contained in:
parent
fdb809d28e
commit
900739eb71
@ -82,9 +82,13 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
|
|||||||
|
|
||||||
text({ document }, { content }) {
|
text({ document }, { content }) {
|
||||||
const nodes = (content as string).split('\n').map(x => document.createTextNode(x));
|
const nodes = (content as string).split('\n').map(x => document.createTextNode(x));
|
||||||
for (const x of intersperse(document.createElement('br'), nodes)) {
|
for (const x of intersperse('br', nodes)) {
|
||||||
|
if (x === 'br') {
|
||||||
|
document.body.appendChild(document.createElement('br'));
|
||||||
|
} else {
|
||||||
document.body.appendChild(x);
|
document.body.appendChild(x);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
url({ document }, { url }) {
|
url({ document }, { url }) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
|
|
||||||
import analyze from '../src/mfm/parse';
|
import analyze from '../src/mfm/parse';
|
||||||
|
import toHtml from '../src/mfm/html';
|
||||||
import syntaxhighlighter from '../src/mfm/parse/core/syntax-highlighter';
|
import syntaxhighlighter from '../src/mfm/parse/core/syntax-highlighter';
|
||||||
|
|
||||||
describe('Text', () => {
|
describe('Text', () => {
|
||||||
@ -170,4 +171,12 @@ describe('Text', () => {
|
|||||||
assert.equal(html, '<span class="symbol">/</span>');
|
assert.equal(html, '<span class="symbol">/</span>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('toHtml', () => {
|
||||||
|
it('br', () => {
|
||||||
|
const input = 'foo\nbar\nbaz';
|
||||||
|
const output = '<p>foo<br>bar<br>baz</p>';
|
||||||
|
assert.equal(toHtml(analyze(input)), output);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user