From 4690b1de6f09beb04fa3b3911fff07c78afdc3eb Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Thu, 26 Dec 2024 20:55:51 +0900 Subject: [PATCH] Simplify and document md converter --- bin/api-docs/gen-components-docs/markdown/index.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/api-docs/gen-components-docs/markdown/index.mjs b/bin/api-docs/gen-components-docs/markdown/index.mjs index e9afa87a3a6c5..b66aedaa144e7 100644 --- a/bin/api-docs/gen-components-docs/markdown/index.mjs +++ b/bin/api-docs/gen-components-docs/markdown/index.mjs @@ -8,8 +8,14 @@ import json2md from 'json2md'; */ import { generateMarkdownPropsJson } from './props.mjs'; +/** + * Converter for strings that are already formatted as Markdown. + * + * @param {string} [input] + * @return {string} The trimmed input if it is contentful, otherwise an empty string. + */ json2md.converters.md = ( input ) => { - return input?.trim() ? input : ''; + return input?.trim() || ''; }; export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {