Skip to content

Commit

Permalink
chore: add top-level attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed May 15, 2024
1 parent 2fa354d commit d6055d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/myst-frontmatter/src/exports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Export = {
zip?: boolean;
toc?: any[];
articles?: ExportArticle[];
top_level?: 'parts' | 'chapters' | 'sections';
/** sub_articles are only for jats xml export */
sub_articles?: string[];
/** MECA: to, from later */
Expand Down
8 changes: 8 additions & 0 deletions packages/myst-frontmatter/src/exports/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
defined,
incrementOptions,
validateBoolean,
validateChoice,
validateEnum,
validateList,
validateNumber,
Expand All @@ -28,6 +29,7 @@ const EXPORT_KEY_OBJECT = {
'name',
'renderer',
'articles',
'top_level',
'sub_articles',
],
alias: {
Expand Down Expand Up @@ -238,6 +240,12 @@ export function validateExport(input: any, opts: ValidationOptions): Export | un
validExport.articles = undefined;
}
}
if (defined(value.top_level)) {
validExport.top_level = validateChoice(value.top_level || 'sections', {
...incrementOptions('top_level', opts),
choices: ['parts', 'chapters', 'sections'],
}) as Export['top_level'];
}
if (defined(value.sub_articles)) {
if (validExport.format !== ExportFormats.xml) {
validationError("sub_articles are only supported for 'jats' export", opts);
Expand Down

0 comments on commit d6055d7

Please sign in to comment.