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

update doc

parent efeefc63
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,27 @@
例:
```ts
const nodes = mfm.parse('hello [tada world]');
const nodes = mfm.parse('hello $[tada world]');
console.log(JSON.stringify(nodes));
// => "[{"type":"text","props":{"text":"hello "}},{"type":"fn","props":{"name":"tada","args":{}},"children":[{"type":"text","props":{"text":"world"}}]}]"
```
### 利用可能なMFM関数のリストを設定する
MFM関数の名前をホワイトリストに登録して、登録されたMFM関数以外を通常のテキストノードとして解釈するように設定できます。
デフォルトではすべてのMFM関数名を受け入れるように設定されています。
```ts
const nodes = mfm.parse('hello $[tada world]', { fnNameList: ['tada', 'spin'] });
console.log(JSON.stringify(nodes));
// => "[{"type":"text","props":{"text":"hello "}},{"type":"fn","props":{"name":"tada","args":{}},"children":[{"type":"text","props":{"text":"world"}}]}]"
```
```ts
const nodes = mfm.parse('hello $[pope world]', { fnNameList: ['tada', 'spin'] });
console.log(JSON.stringify(nodes));
// => "[{"type":"text","props":{"text":"hello $[pope world]"}}]"
```
## parsePlain API
入力文字列からノードツリーを生成します。
絵文字コードとUnicode絵文字を利用可能です。
......@@ -25,7 +41,7 @@ console.log(JSON.stringify(nodes));
例:
```ts
const nodes = mfm.parse('hello [tada world]');
const nodes = mfm.parse('hello $[tada world]');
const output = mfm.toString(nodes);
console.log(output); // => "hello [tada world]"
```
......
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