An MFM parser implementation with TypeScript.
This is the Cheripia fork of misskey-dev/mfm.js.
The package name is mfm-js, but installing mfm-js from npm does not install this fork.
Install this fork from GitHub, replacing <commit-sha> with the full commit SHA to pin:
npm install 'mfm-js@git+https://github.com/cheripia-dev/mfm.js.git#<commit-sha>'Please see docs for the detail.
TypeScript:
import * as mfm from 'mfm-js';
const inputText =
`<center>
Hello $[tada everynyan! 🎉]
I'm @ai, A bot of cherrypick!
https://github.com/syuilo/ai
</center>`;
// Generate an MFM tree from the full MFM text.
const mfmTree = mfm.parse(inputText);
// Generate an MFM tree from the simple MFM text.
const simpleMfmTree = mfm.parseSimple('I like the hot soup :soup:');
// Reverse to an MFM text from the MFM tree.
const text = mfm.toString(mfmTree);git clone https://github.com/cheripia-dev/mfm.js.git
cd mfm.js
# This repository uses pnpm as its package manager.
pnpm i
pnpm run build
full parser:
pnpm run parse
simple parser:
pnpm run parse-simple
This software is released under the MIT License.