Skip to content
Snippets Groups Projects
Commit b15e4d3c authored by marihachi's avatar marihachi
Browse files

🐱

parent 771ba41f
No related branches found
No related tags found
No related merge requests found
# rosee
## Description
A MFM parser implementation with PEG.js (In developing)
A MFM parser implementation with PEG.js
## Installation
```
......@@ -12,8 +12,17 @@ TypeScript:
```ts
import * as mfm from 'rosee';
const input =
`<center>
Hello [tada everynyan! 🎉]
I'm @ai, An bot of misskey!
https://github.com/syuilo/ai
</center>`;
// parse a MFM text
const result = mfm.parse('good morning ***everynyan!***');
const result = mfm.parse(input);
// parse a MFM plain text
const plainResult = mfm.parsePlain('I like the hot soup :soup:​');
......
......@@ -47,7 +47,10 @@ export type MfmInline = MfmEmoji | MfmBold | MfmSmall | MfmItalic | MfmStrike |
export type MfmEmoji = {
type: 'emoji';
props: { emoji: string; name: undefined; } | { emoji: undefined; name: string; };
props: {
emoji?: string;
name?: string;
};
children: [];
};
......
import { MfmNode, MfmText } from './node';
export function createNode(type: string, props?: Record<string, any>, children?: MfmNode[]): MfmNode {
export function createNode(type: string, props: Record<string, any>, children?: MfmNode[]): MfmNode {
props = props ?? {};
children = children ?? [];
const node = { type, props, children } as MfmNode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment