From b3a8925fdb7d55d9a7c4326d497c3c3a7ec9bab1 Mon Sep 17 00:00:00 2001 From: marihachi <marihachi0620@gmail.com> Date: Sat, 2 Oct 2021 10:27:05 +0900 Subject: [PATCH] update doc --- docs/api.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index bad44a5..75ae293 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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]" ``` -- GitLab