diff --git a/README.md b/README.md index 16e42fe..f6ed6df 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,13 @@ npm i mfm-parser-pegjs ## Usage ```ts -import { parse } from 'mfm-parser-pegjs'; +import * as mfm from 'mfm-parser-pegjs'; -// parse a MFM code -const result = parse('this is a ***MFM text***'); +// parse 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) @@ -39,6 +42,3 @@ npm run parse ## 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 diff --git a/package.json b/package.json index eca84f8..4c639b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mfm-parser-pegjs", - "version": "0.1.1", + "version": "0.1.3", "description": "A MFM parser made with PEG.js", "main": "./built/index.js", "scripts": { @@ -18,6 +18,7 @@ "url": "git+https://github.com/marihachi/mfm-parser-pegjs.git" }, "author": "Marihachi", + "license": "MIT", "devDependencies": { "@types/node": "^12.0.4", "@types/parsimmon": "^1.10.1", diff --git a/src/parser/index.ts b/src/parser/index.ts index b091ca2..ac87a8a 100644 --- a/src/parser/index.ts +++ b/src/parser/index.ts @@ -12,3 +12,9 @@ export function parse(input: string) { trees = coreParser.parse(input); return trees; } + +export function parsePlain(input: string) { + let trees: Tree[]; + trees = coreParser.parse(input, { startRule: 'plainParser' }); + return trees; +}