diff --git a/plugins/plugin-md-power/src/node/container/codeTree.ts b/plugins/plugin-md-power/src/node/container/codeTree.ts index 0599ddcd..2248c484 100644 --- a/plugins/plugin-md-power/src/node/container/codeTree.ts +++ b/plugins/plugin-md-power/src/node/container/codeTree.ts @@ -151,7 +151,7 @@ export function codeTreePlugin(md: Markdown, app: App, options: CodeTreeOptions expanded: true, filepath: node.filepath, } - return ` + return ` ${node.children?.length ? renderFileTree(node.children, mode) : ''} ` diff --git a/plugins/plugin-md-power/src/node/container/fileTree.ts b/plugins/plugin-md-power/src/node/container/fileTree.ts index 7b31aa64..d64d3b32 100644 --- a/plugins/plugin-md-power/src/node/container/fileTree.ts +++ b/plugins/plugin-md-power/src/node/container/fileTree.ts @@ -162,7 +162,7 @@ export function fileTreePlugin(md: Markdown, options: FileTreeOptions = {}): voi filename, level, } - return ` + return ` ${renderedIcon}${renderedComment}${children.length > 0 ? renderFileTree(children, meta) : ''} ` }).join('\n') diff --git a/plugins/plugin-md-power/src/node/utils/stringifyAttrs.ts b/plugins/plugin-md-power/src/node/utils/stringifyAttrs.ts index 884b4969..283a5038 100644 --- a/plugins/plugin-md-power/src/node/utils/stringifyAttrs.ts +++ b/plugins/plugin-md-power/src/node/utils/stringifyAttrs.ts @@ -2,16 +2,17 @@ import { isBoolean, isNull, isNumber, isString, isUndefined, kebabCase } from '@ export function stringifyAttrs( attrs: T, - withUndefined = false, + withUndefinedOrNull = false, + forceStringify: (keyof T)[] = [], ): string { const result = Object.entries(attrs) .map(([key, value]) => { const k = kebabCase(key) if (isUndefined(value) || value === 'undefined') - return withUndefined ? `:${k}="undefined"` : '' + return withUndefinedOrNull ? `:${k}="undefined"` : '' if (isNull(value) || value === 'null') - return withUndefined ? `:${k}="null"` : '' + return withUndefinedOrNull ? `:${k}="null"` : '' if (value === 'true') value = true @@ -25,8 +26,12 @@ export function stringifyAttrs( return `:${k}="${value}"` // like object or array - if (isString(value) && (value[0] === '{' || value[0] === '[')) - return `:${k}="${value.replaceAll('\"', '\'')}"` + if (isString(value) && (value[0] === '{' || value[0] === '[')) { + const v = value.replaceAll('\"', '\'') + if (forceStringify.includes(key as keyof T)) + return `${k}="${v}"` + return `:${k}="${v}"` + } const hasDynamic = key[0] === ':' return `${hasDynamic ? ':' : ''}${k}="${String(value)}"`