Skip to content

Commit

Permalink
📤 Allow multi-article meca export, following jats (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkoch authored Jul 14, 2024
1 parent 606085a commit 167238b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-gifts-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-cli': patch
---

Support multiple articles with meca like jats
32 changes: 31 additions & 1 deletion packages/myst-cli/src/build/utils/collectExportOptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('resolveArticlesFromProject', () => {
expect(vfile.messages.length).toBe(0);
});
it('single page format uses singe page if available', async () => {
const exp: any = { format: ExportFormats.meca };
const exp: any = { format: ExportFormats.docx };
const proj: Omit<LocalProject, 'bibliography'> = {
path: '.',
file: 'index.md',
Expand Down Expand Up @@ -163,6 +163,36 @@ describe('resolveArticlesFromProject', () => {
});
expect(vfile.messages.length).toBe(1);
});
it('meca format uses no articles on multiple pages', async () => {
const exp: any = { format: ExportFormats.meca };
const proj: Omit<LocalProject, 'bibliography'> = {
path: '.',
file: 'index.md',
index: 'index',
pages: [
{
title: 'zero',
level: 1,
},
{
file: 'one.md',
level: 1,
slug: 'one',
},
{
file: 'two.md',
level: 2,
slug: 'two',
},
],
};
const vfile = new VFile();
expect(resolveArticlesFromProject(exp, proj, vfile)).toEqual({
articles: [{ file: 'index.md', level: 1 }],
sub_articles: ['one.md', 'two.md'],
});
expect(vfile.messages?.length).toBeFalsy();
});
});

describe('resolveTemplate', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-cli/src/build/utils/collectExportOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function resolveArticlesFromProject(
if (MULTI_ARTICLE_EXPORT_FORMATS.includes(exp.format)) {
return { articles };
}
if (exp.format === ExportFormats.xml) {
if (exp.format === ExportFormats.xml || exp.format === ExportFormats.meca) {
return {
articles: [fileAsPage],
sub_articles: pages
Expand Down

0 comments on commit 167238b

Please sign in to comment.