Skip to content

Commit

Permalink
Fix #4034 (#4037)
Browse files Browse the repository at this point in the history
* Fix #4034

* improve
  • Loading branch information
mei23 authored and syuilo committed Jan 29, 2019
1 parent 2ed9e26 commit b0e00da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mfm/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default (tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteU

text(token) {
const el = doc.createElement('span');
const nodes = (token.node.props.text as string).split('\n').map(x => doc.createTextNode(x));
const nodes = (token.node.props.text as string).split(/\r\n|\r|\n/).map(x => doc.createTextNode(x));

for (const x of intersperse('br', nodes)) {
el.appendChild(x === 'br' ? doc.createElement('br') : x);
Expand Down
6 changes: 6 additions & 0 deletions test/mfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,12 @@ describe('MFM', () => {
const output = '<p><span>foo<br>bar<br>baz</span></p>';
assert.equal(toHtml(analyze(input)), output);
});

it('br alt', () => {
const input = 'foo\r\nbar\rbaz';
const output = '<p><span>foo<br>bar<br>baz</span></p>';
assert.equal(toHtml(analyze(input)), output);
});
});

it('code block with quote', () => {
Expand Down

0 comments on commit b0e00da

Please sign in to comment.