From d91df5d8db105ba29cd464f485c43a07569fab1f Mon Sep 17 00:00:00 2001 From: Ron S Date: Sun, 25 Jul 2021 23:56:09 -0400 Subject: [PATCH] style: Clean up TranslatorConfig type --- src/translator.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/translator.ts b/src/translator.ts index 238bd48..460abce 100755 --- a/src/translator.ts +++ b/src/translator.ts @@ -23,42 +23,50 @@ export type TranslatorContext = Partial & { base?: TranslatorConfig } -export type TranslatorConfig = { +export interface TranslatorConfig { /** * Preceeds content, follows surroundingNewLines */ - prefix?: string, + prefix?: string + /** * Follows content, preceeds surroundingNewLines */ - postfix?: string, + postfix?: string + /** * Set fixed output content */ - content?: string, + content?: string + /** * Post-process content after inner nodes have been rendered. * Returning undefined will cause the content to not be updated */ postprocess?: (ctx: TranslatorContext & { content: string }) => string | PostProcessResult + /** * If false, no child elements will be scanned * @default true */ - recurse?: boolean, + recurse?: boolean + /** * Adds newline before and after (true, false, or number of newlines to add per side) * @default false */ surroundingNewlines?: boolean | number + /** * Ignore node entirely */ ignore?: boolean + /** * Do not escape content */ noEscape?: boolean + /** * If first character matches end of the last written data, add a space * @example @@ -67,6 +75,7 @@ export type TranslatorConfig = { * // becomes: **abc** **def** */ spaceIfRepeatingChar?: boolean + /** * Ensure translator is always visited, even if element is empty * Note: For speed, trees are optimized beforehand to only visit elements which have child nodes or text content.