refactor: Introduce list of MFM Functions (#7882)

* introduce list of MFM Functions

* add note
This commit is contained in:
marihachi 2021-11-01 23:47:13 +09:00 committed by GitHub
parent 34ea3cf226
commit 1c38c7010d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 6 deletions

View file

@ -1,9 +1,10 @@
import * as mfm from 'mfm-js';
import { fnNameList } from '@/mfm/fn-name-list';
import { Note } from '@/models/entities/note';
import { toHtml } from '../../../mfm/to-html';
export default function(note: Note) {
let html = note.text ? toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers)) : null;
let html = note.text ? toHtml(mfm.parse(note.text, { fnNameList }), JSON.parse(note.mentionedRemoteUsers)) : null;
if (html == null) html = '<p>.</p>';
return html;

View file

@ -11,6 +11,7 @@ import { IIdentifier } from '../models/identifier';
import renderHashtag from './hashtag';
import { DriveFiles, UserProfiles } from '@/models/index';
import { getUserKeypair } from '@/misc/keypair-store';
import { fnNameList } from '@/mfm/fn-name-list';
export async function renderPerson(user: ILocalUser) {
const id = `${config.url}/users/${user.id}`;
@ -66,7 +67,7 @@ export async function renderPerson(user: ILocalUser) {
url: `${config.url}/@${user.username}`,
preferredUsername: user.username,
name: user.name,
summary: profile.description ? toHtml(mfm.parse(profile.description)) : null,
summary: profile.description ? toHtml(mfm.parse(profile.description, { fnNameList })) : null,
icon: avatar ? renderImage(avatar) : null,
image: banner ? renderImage(banner) : null,
tag,