Skip to content

Commit b8cb595

Browse files
committed
feat: add syllabi genre, ref #115
1 parent 5d04f4b commit b8cb595

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

collection-export/syllabus.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ import {
1313
} from './xml-helpers.js'
1414
import {convertPartNumbers, moveAndRenameElement, removeEmptyElements} from './strict-mods.js'
1515

16+
export function addGenre(doc) {
17+
const genre = createElement(doc, 'genre')
18+
genre.setAttribute('type', 'aat')
19+
genre.textContent = 'syllabi'
20+
const mods = safeSelectFirst("//mods", doc)
21+
mods.appendChild(genre)
22+
23+
return doc
24+
}
25+
1626
/**
1727
* local/courseInfo/courseNumer & course -> mods/titleInfo/title
1828
* local/courseInfo/semester -> mods/part/partNumber
@@ -100,6 +110,9 @@ export function convertSyllabusXMLtoMODS(xmlString) {
100110
// mods/part/number to part/text @type=attachment-uuid
101111
convertPartNumbers(doc)
102112

113+
// Add syllabi genre
114+
addGenre(doc)
115+
103116
// Remove empty elements last, after all transformations are complete
104117
removeEmptyElements(doc)
105118

collection-export/syllabus.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import {convertSyllabusXMLtoMODS} from './syllabus.js'
66
// helper function to wrap XML in a root </xml> element
77
const x = (xml) => `<xml>${xml}</xml>`
88

9+
describe('addGenre', () => {
10+
it('should add genre element with type=syllabus', async () => {
11+
const inputXML = x(`<mods></mods>`)
12+
const result = convertSyllabusXMLtoMODS(inputXML)
13+
const genre = xpath.select1('//mods/genre[@type="aat"]', result)
14+
assert.ok(genre)
15+
assert.strictEqual(genre.textContent, 'syllabi')
16+
})
17+
})
18+
919
describe('fixSyllabusTitle', () => {
1020
it('should not retain the original title', async () => {
1121
const title = 'Fall 2026 | FASHN-360 | Media History'

0 commit comments

Comments
 (0)