Skip to content

Commit

Permalink
🏷 Add short_title to JATS output (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Oct 13, 2023
1 parent 912e8b5 commit aecf616
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-days-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-jats': patch
---

Add alt-title to JATS (as running-head)
5 changes: 5 additions & 0 deletions .changeset/plenty-planets-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-frontmatter': patch
---

Remove restriction on short_title length from validation.
5 changes: 1 addition & 4 deletions packages/myst-frontmatter/src/frontmatter/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,7 @@ export function validateSiteFrontmatterKeys(value: Record<string, any>, opts: Va
output.description = validateString(value.description, incrementOptions('description', opts));
}
if (defined(value.short_title)) {
output.short_title = validateString(value.short_title, {
...incrementOptions('short_title', opts),
maxLength: 40,
});
output.short_title = validateString(value.short_title, incrementOptions('short_title', opts));
}
if (defined(value.subtitle)) {
output.subtitle = validateString(value.subtitle, incrementOptions('subtitle', opts));
Expand Down
15 changes: 13 additions & 2 deletions packages/myst-to-jats/src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export function getJournalMeta(): Element | null {
export function getArticleTitle(frontmatter: ProjectFrontmatter): Element[] {
const title = frontmatter?.title;
const subtitle = frontmatter?.subtitle;
if (!title && !subtitle) return [];
const short_title = frontmatter?.short_title;
if (!title && !subtitle && !short_title) return [];
const articleTitle: Element[] = [
{
type: 'element',
Expand All @@ -78,11 +79,21 @@ export function getArticleTitle(frontmatter: ProjectFrontmatter): Element[] {
},
]
: [];
const articleShortTitle: Element[] = short_title
? [
{
type: 'element',
name: 'alt-title',
attributes: { 'alt-title-type': 'running-head' },
elements: [{ type: 'text', text: short_title }],
},
]
: [];
return [
{
type: 'element',
name: 'title-group',
elements: [...articleTitle, ...articleSubtitle],
elements: [...articleTitle, ...articleSubtitle, ...articleShortTitle],
},
];
}
Expand Down

0 comments on commit aecf616

Please sign in to comment.