Skip to content

Commit

Permalink
NEW: Support IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Apr 9, 2024
1 parent 8853c4a commit 2fbe473
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utterance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import createWords from '../words/index.js'
export default function convertUtterance(u, options) {

const header = createHeader(u.metadata, options)
const { id } = u
const literal = createLiteral(u.literal, options)
const phonetic = createPhonetic(u.phonetic, options)
const source = createSource(u.speaker, u.source)
Expand All @@ -21,7 +22,8 @@ export default function convertUtterance(u, options) {
const words = createWords(u.words, options)

const { classes, tag } = options
const classString = classes.join(` `)
const classesString = classes.join(` `)
const idString = id ? `id='${ id }'` : ``

const lines = [
header,
Expand All @@ -36,6 +38,6 @@ export default function convertUtterance(u, options) {
].filter(Boolean)
.join(``)

return `<${ tag } class='${ classString }'>${ lines }</${ tag }>`
return `<${ tag } class='${ classesString }' ${ idString }>${ lines }</${ tag }>`

}
20 changes: 20 additions & 0 deletions test/utterance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ describe(`utterance`, function() {

})

describe(`id`, function() {

it(`renders`, async function() {

const scription = `
\\id 17
\\txn ninakupenda
\\m ni-na-ku-pend-a
\\gl 1SG.SUBJ-PRES-1SG.OBJ-love-IND
\\tln I love you
`

const { dom } = await parse(scription)
const wrapper = findElement(dom, el => getAttribute(el, `id`) === `17`)

expect(wrapper).to.exist

})

})

describe(`literal translation`, function() {

Expand Down

0 comments on commit 2fbe473

Please sign in to comment.