Skip to content

Commit

Permalink
NEW: Support emphasis in literal translation
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Dec 18, 2023
1 parent b6d0e6f commit 1b9011c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/lines/literal.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import addEmphasis from '../utilities/addEmphasis.js'

export default function createLiteral(data) {

if (typeof data === `string`) {
return `<p class=lit lang=en>${ data }</p>`
return `<p class=lit lang=en>${ addEmphasis(data) }</p>`
}

let html = ``

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

return html
Expand Down
55 changes: 38 additions & 17 deletions test/lines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,49 @@ describe(`lines`, function() {
})


it(`literal translation`, function() {
describe(`literal translation`, function() {

const scription = `
\\txn xaa qapx guxna
\\m xaq qapx guxt-na
\\gl mouth recip eat-nf.pl
\\tln they kissed each other
\\lit-en they ate each other's mouths
\\lit-sp se comen sus bocas
`
it(`renders`, function() {

const { dom } = parse(scription)
const literal = findElementsByClass(dom, `lit`)
const scription = `
\\txn xaa qapx guxna
\\m xaq qapx guxt-na
\\gl mouth recip eat-nf.pl
\\tln they kissed each other
\\lit-en they ate each other's mouths
\\lit-sp se comen sus bocas
`

const { dom } = parse(scription)
const literal = findElementsByClass(dom, `lit`)

expect(literal).to.have.length(2)

expect(literal).to.have.length(2)
const [eng, spa] = literal

const [eng, spa] = literal
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(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`)
})

it(`renders with emphasis`, function() {

const scription = `# Causative-Reversive
\\trs Satia’tawi*’t*á*hsi*!
\\m s-at-ia’t-a-wi-*’t*-a-*hsi*
\\gl 2sg.agt-mid-body-jr-cover-*caus*-jr-*rev*
\\lit *un-cause* your body to be covered, uncover your body
\\tln Take your coat off!`

const { dom } = parse(scription)
const literal = findElementByClass(dom, `lit`)
const b = findElement(literal, el => getTagName(el) === `b`)

expect(getTextContent(b)).to.equal(`un-cause`)

})

})

Expand Down

0 comments on commit 1b9011c

Please sign in to comment.