Skip to content

Commit

Permalink
FIX: Adjust code to handle new HTML structure for literal translations
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Mar 16, 2024
1 parent 2bbe916 commit 77b61ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/utterance/literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function createLiteral(data, { analysisLang }) {

for (const lang in data) {
const lit = data[lang]
html += `<p class=lit'><i lang=en>lit.</i> <span class=tln lang='${ lang }>${ addEmphasis(lit) }</span></p>`
html += `<p class=lit><i lang=en>lit.</i> <span class=tln lang='${ lang }'>${ addEmphasis(lit) }</span></p>`
}

return html
Expand Down
13 changes: 7 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import parse from './utilities/convertAndParse.js'
import parseClassString from './utilities/parseClassString.js'
import { Swahili } from '../samples/data/data.js'

describe(`scription2html`, function() {
describe(`dlx2html`, function() {

it(`wraps utterances in <div class=igl> by default`, async function() {

Expand Down Expand Up @@ -66,13 +66,14 @@ describe(`scription2html`, function() {
`

const analysisLang = `sp`
const { dom } = await parse(scription, { analysisLang })
const { dom, html } = await parse(scription, { analysisLang })

const lit = findElementByClass(dom, `lit`)
const tln = findElementByClass(dom, `tln`)
const meta = findElementByClass(dom, `ex-header`)
const lit = findElementByClass(dom, `lit`)
const tln = findElementByClass(dom, `tln`)
const meta = findElementByClass(dom, `ex-header`)
const literalTranslation = findElementByClass(lit, `tln`)

expect(getAttribute(lit, `lang`)).to.equal(analysisLang)
expect(getAttribute(literalTranslation, `lang`)).to.equal(analysisLang)
expect(getAttribute(tln, `lang`)).to.equal(analysisLang)
expect(getAttribute(meta, `lang`)).to.equal(analysisLang)

Expand Down
10 changes: 6 additions & 4 deletions test/utterance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ describe(`utterance`, function() {
expect(literal).to.have.length(2)

const [eng, spa] = literal
const engLiteral = findElementByClass(eng, `tln`)
const spaLiteral = findElementByClass(spa, `tln`)

expect(getAttribute(eng, `lang`)).to.equal(`en`)
expect(getAttribute(spa, `lang`)).to.equal(`sp`)
expect(getTextContent(eng)).to.equal(`they ate each other's mouths`)
expect(getTextContent(spa)).to.equal(`se comen sus bocas`)
expect(getAttribute(engLiteral, `lang`)).to.equal(`en`)
expect(getAttribute(spaLiteral, `lang`)).to.equal(`sp`)
expect(getTextContent(engLiteral)).to.equal(`they ate each other's mouths`)
expect(getTextContent(spaLiteral)).to.equal(`se comen sus bocas`)

})

Expand Down

0 comments on commit 77b61ff

Please sign in to comment.