mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-25 15:35:13 +00:00
v0.1.3
This commit is contained in:
parent
ed85121c5a
commit
753cb6deff
3 changed files with 14 additions and 7 deletions
12
README.md
12
README.md
|
@ -9,10 +9,13 @@ npm i mfm-parser-pegjs
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```ts
|
```ts
|
||||||
import { parse } from 'mfm-parser-pegjs';
|
import * as mfm from 'mfm-parser-pegjs';
|
||||||
|
|
||||||
// parse a MFM code
|
// parse a MFM text
|
||||||
const result = parse('this is a ***MFM text***');
|
const result = mfm.parse('good morning ***everyone!***');
|
||||||
|
|
||||||
|
// parse a MFM plain text
|
||||||
|
const plainResult = mfm.parsePlain('I like the hot soup :soup:');
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage (Repository)
|
## Usage (Repository)
|
||||||
|
@ -39,6 +42,3 @@ npm run parse
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This software is released under the [MIT License](LICENSE).
|
This software is released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
This software includes codes of other softwares:
|
|
||||||
- PEG.js: https://raw.githubusercontent.com/pegjs/pegjs/master/LICENSE
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mfm-parser-pegjs",
|
"name": "mfm-parser-pegjs",
|
||||||
"version": "0.1.1",
|
"version": "0.1.3",
|
||||||
"description": "A MFM parser made with PEG.js",
|
"description": "A MFM parser made with PEG.js",
|
||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
"url": "git+https://github.com/marihachi/mfm-parser-pegjs.git"
|
"url": "git+https://github.com/marihachi/mfm-parser-pegjs.git"
|
||||||
},
|
},
|
||||||
"author": "Marihachi",
|
"author": "Marihachi",
|
||||||
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^12.0.4",
|
||||||
"@types/parsimmon": "^1.10.1",
|
"@types/parsimmon": "^1.10.1",
|
||||||
|
|
|
@ -12,3 +12,9 @@ export function parse(input: string) {
|
||||||
trees = coreParser.parse(input);
|
trees = coreParser.parse(input);
|
||||||
return trees;
|
return trees;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parsePlain(input: string) {
|
||||||
|
let trees: Tree[];
|
||||||
|
trees = coreParser.parse(input, { startRule: 'plainParser' });
|
||||||
|
return trees;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue