From cf18f2027f8df741b499093a0974c5d88d1bbb8e Mon Sep 17 00:00:00 2001 From: Jim Madge Date: Wed, 26 Feb 2025 13:34:01 +0000 Subject: [PATCH] Don't construct CodeBlockOptions when unecessary Co-authored-by: Angus Hollands --- packages/myst-directives/src/include.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/myst-directives/src/include.ts b/packages/myst-directives/src/include.ts index ead40074a..b703a0073 100644 --- a/packages/myst-directives/src/include.ts +++ b/packages/myst-directives/src/include.ts @@ -74,12 +74,14 @@ export const includeDirective: DirectiveSpec = { const file = data.arg as string; const lang = (data.options?.lang as string) ?? extToLanguage(file.split('.').pop()); - const opts = getCodeBlockOptions( - data, - vfile, - // Set the filename in the literal include by default - file.split(/\/|\\/).pop(), - ); + const opts = literal + ? getCodeBlockOptions( + data, + vfile, + // Set the filename in the literal include by default + file.split(/\/|\\/).pop(), + ) + : {}; const filter: Include['filter'] = {}; ensureOnlyOneOf(data, vfile, ['start-at', 'start-line', 'start-after', 'lines']); ensureOnlyOneOf(data, vfile, ['end-at', 'end-line', 'end-before', 'lines']);