summaryrefslogtreecommitdiff
path: root/src/mfm
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-08-19 00:55:07 +0900
committerGitHub <noreply@github.com>2018-08-19 00:55:07 +0900
commit0e45d0d47fca2f9cf2caf87a25442d3090bea2fb (patch)
tree4591218074ce73b4f5d3be7582d76a170dc1b672 /src/mfm
parentNew translations ja.yml (Japanese (Kansai-ben)) (diff)
parentMerge pull request #2330 from syuilo/patch (diff)
downloadmisskey-0e45d0d47fca2f9cf2caf87a25442d3090bea2fb.tar.gz
misskey-0e45d0d47fca2f9cf2caf87a25442d3090bea2fb.tar.bz2
misskey-0e45d0d47fca2f9cf2caf87a25442d3090bea2fb.zip
Merge branch 'master' into l10n_master
Diffstat (limited to 'src/mfm')
-rw-r--r--src/mfm/html-to-mfm.ts3
-rw-r--r--src/mfm/html.ts13
2 files changed, 10 insertions, 6 deletions
diff --git a/src/mfm/html-to-mfm.ts b/src/mfm/html-to-mfm.ts
index daa228ec51..084578fc18 100644
--- a/src/mfm/html-to-mfm.ts
+++ b/src/mfm/html-to-mfm.ts
@@ -49,6 +49,9 @@ export default function(html: string): string {
text += txt;
break;
}
+ // メンション以外
+ } else {
+ text += `[${txt}](${node.attrs.find((x: any) => x.name == 'href').value})`;
}
if (node.childNodes) {
diff --git a/src/mfm/html.ts b/src/mfm/html.ts
index c11bd55cf4..c798ee410a 100644
--- a/src/mfm/html.ts
+++ b/src/mfm/html.ts
@@ -5,6 +5,10 @@ import config from '../config';
import { INote } from '../models/note';
import { TextElement } from './parse';
+function intersperse<T>(sep: T, xs: T[]): T[] {
+ return [].concat(...xs.map(x => [sep, x])).slice(1);
+}
+
const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: INote['mentionedRemoteUsers']) => void } = {
bold({ document }, { bold }) {
const b = document.createElement('b');
@@ -80,12 +84,9 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
},
text({ document }, { content }) {
- for (const text of content.split('\n')) {
- const node = document.createTextNode(text);
- document.body.appendChild(node);
-
- const br = document.createElement('br');
- document.body.appendChild(br);
+ const nodes = (content as string).split('\n').map(x => document.createTextNode(x));
+ for (const x of intersperse(document.createElement('br'), nodes)) {
+ document.body.appendChild(x);
}
},