Skip to content

Commit

Permalink
Don't construct CodeBlockOptions when unecessary
Browse files Browse the repository at this point in the history
Co-authored-by: Angus Hollands <goosey15@gmail.com>
  • Loading branch information
JimMadge and agoose77 committed Feb 26, 2025
1 parent f3f2c44 commit cf18f20
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/myst-directives/src/include.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down

0 comments on commit cf18f20

Please # to comment.