diff --git a/src/renderer/plugins/markdown-macro.ts b/src/renderer/plugins/markdown-macro.ts index 54c4b5d1..44c172c6 100644 --- a/src/renderer/plugins/markdown-macro.ts +++ b/src/renderer/plugins/markdown-macro.ts @@ -2,7 +2,6 @@ import { escapeRegExp, merge, omit } from 'lodash-es' import frontMatter from 'front-matter' import type { Plugin } from '@fe/context' import type { BuildInSettings, Doc } from '@fe/types' -import { MARKDOWN_FILE_EXT } from '@share/misc' import type { MenuItem } from '@fe/services/status-bar' import { render } from '@fe/services/view' import { t } from '@fe/services/i18n' @@ -10,6 +9,7 @@ import { readFile } from '@fe/support/api' import { getLogger, md5 } from '@fe/utils' import { basename, dirname, resolve } from '@fe/utils/path' import { getPurchased } from '@fe/others/premium' +import { isPlain } from '@fe/services/document' import ctx from '@fe/context' type Result = { __macroResult: true, vars?: Record, value: string } @@ -208,8 +208,8 @@ async function include ( return { __macroResult: true, value: 'Error: $include maximum call stack size exceeded [3]' } } - if (!path.endsWith(MARKDOWN_FILE_EXT)) { - return { __macroResult: true, value: 'Error: $include markdown file only' } + if (!isPlain({ type: 'file', path })) { + return { __macroResult: true, value: 'Error: $include path is not a plain file' } } try { diff --git a/src/renderer/services/document.ts b/src/renderer/services/document.ts index 2aab1829..61ce831b 100644 --- a/src/renderer/services/document.ts +++ b/src/renderer/services/document.ts @@ -166,7 +166,7 @@ export function isEncrypted (doc?: Pick | null): boolean { * @param doc * @returns */ -export function isPlain (doc?: PathItemWithType) { +export function isPlain (doc?: Omit) { if (!doc) return false return doc.type === 'file' &&