sfm-js/README.md

55 lines
753 B
Markdown
Raw Normal View History

2021-03-26 14:20:12 +00:00
# mfm.js
2020-01-31 19:29:30 +00:00
## Description
2021-03-20 15:36:54 +00:00
A MFM parser implementation with PEG.js
2020-01-31 19:29:30 +00:00
## Installation
```
2021-03-19 12:16:21 +00:00
npm i rosee
2020-01-31 19:29:30 +00:00
```
2020-02-16 14:27:25 +00:00
## Usage
2021-03-17 06:24:33 +00:00
TypeScript:
2020-02-16 14:27:25 +00:00
```ts
2021-03-19 12:16:21 +00:00
import * as mfm from 'rosee';
2020-02-16 14:27:25 +00:00
2021-03-20 15:36:54 +00:00
const input =
`<center>
Hello [tada everynyan! 🎉]
I'm @ai, An bot of misskey!
https://github.com/syuilo/ai
</center>`;
2020-02-24 13:27:01 +00:00
// parse a MFM text
2021-03-20 15:36:54 +00:00
const result = mfm.parse(input);
2020-02-24 13:27:01 +00:00
// parse a MFM plain text
const plainResult = mfm.parsePlain('I like the hot soup :soup:');
2020-02-16 14:27:25 +00:00
```
## Usage (Repository)
### 1. Clone
```
2021-03-26 14:20:12 +00:00
git clone https://github.com/misskey-dev/mfm.js.git
2020-02-16 14:27:25 +00:00
```
2021-03-17 06:24:33 +00:00
### 2. Install packages
2020-01-31 19:29:30 +00:00
```
2021-03-26 14:20:12 +00:00
cd mfm.js
2021-03-17 06:24:33 +00:00
npm i
2020-01-31 19:29:30 +00:00
```
2021-03-17 06:24:33 +00:00
### 3. Build
2020-01-31 19:29:30 +00:00
```
2021-03-17 06:24:33 +00:00
npm run build
2020-01-31 19:29:30 +00:00
```
2021-03-17 06:24:33 +00:00
### Use the interactive CLI parser
2020-01-31 19:29:30 +00:00
```
2020-02-20 03:31:56 +00:00
npm run parse
2020-01-31 19:29:30 +00:00
```
2020-02-16 14:27:25 +00:00
## License
2021-03-17 06:24:33 +00:00
This software is released under the [MIT License](LICENSE).