mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-21 21:55:09 +00:00
🐱
This commit is contained in:
parent
771ba41ff8
commit
b15e4d3c2e
3 changed files with 16 additions and 4 deletions
13
README.md
13
README.md
|
@ -1,6 +1,6 @@
|
|||
# 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: [];
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue