From 6b2be99b538790ce6094522e2d97959f39e943c1 Mon Sep 17 00:00:00 2001 From: Ika Date: Wed, 25 Apr 2018 00:41:39 +0800 Subject: [PATCH] docs(plugins): add parser.preprocess (#4365) * docs(plugins): add parser.preprocess * docs: fix linting --- docs/plugins.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index 449f8de2..0b5c00a4 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -87,7 +87,8 @@ export const parsers = { astFormat: "dance-ast", hasPragma, locStart, - locEnd + locEnd, + preprocess } }; ``` @@ -104,12 +105,18 @@ The location extraction functions (`locStart` and `locEnd`) return the starting function locStart(node: object): number; ``` -The pragma detection function (`hasPragma`) should return if the text contains the pragma comment. +_(Optional)_ The pragma detection function (`hasPragma`) should return if the text contains the pragma comment. ```ts function hasPragma(text: string): boolean; ``` +_(Optional)_ The preprocess function can process the input text before passing into `parse` function. + +```ts +function preprocess(text: string, options: object): string; +``` + ### `printers` Printers convert ASTs into a Prettier intermediate representation, also known as a Doc.