diff --git a/src/words/index.js b/src/words/index.js
index 2cd94fc..4c7471d 100644
--- a/src/words/index.js
+++ b/src/words/index.js
@@ -1,3 +1,4 @@
+import createLiteral from './literal.js'
import createTranscription from './transcription.js'
export default function createWords(words, options) {
@@ -8,10 +9,12 @@ export default function createWords(words, options) {
for (const word of words) {
+ const literal = createLiteral(word.literal, options)
const transcription = createTranscription(word.transcription, options)
html += `\n
${ transcription }
+ ${ literal }
`
}
diff --git a/src/words/literal.js b/src/words/literal.js
new file mode 100644
index 0000000..bdc8901
--- /dev/null
+++ b/src/words/literal.js
@@ -0,0 +1,19 @@
+export default function createLiteral(data, { analysisLang }) {
+
+ if (!data) return ``
+
+ if (typeof data === `string`) {
+ const lang = analysisLang ? `lang='${ analysisLang }'` : ``
+ return `${ data }`
+ }
+
+ let html = ``
+
+ for (const lang in data) {
+ const tln = data[lang]
+ html += `${ tln }`
+ }
+
+ return html
+
+}
diff --git a/test/words.test.js b/test/words.test.js
index 0c7d6ce..8ccf86b 100644
--- a/test/words.test.js
+++ b/test/words.test.js
@@ -3,6 +3,11 @@ import findElementByClass from './utilities/findElementByClass.js'
import { getTextContent } from '../node_modules/@web/parse5-utils/src/index.js'
import parse from './utilities/convertAndParse.js'
+import {
+ findElement,
+ getTagName,
+} from '@web/parse5-utils'
+
describe(`words`, function() {
it(`renders one HTML word per linguistic word`, async function() {
@@ -46,7 +51,7 @@ describe(`words`, function() {
\\tln one day a man
`
- const { dom, html } = await parse(scription)
+ const { dom } = await parse(scription)
const wordsContainer = findElementByClass(dom, `words`)
const [firstWord, secondWord] = wordsContainer.childNodes.filter(node => node.tagName === `li`)
@@ -73,4 +78,40 @@ describe(`words`, function() {
expect(getTextContent(b)).to.equal(`waxdungu`)
})
+
+ it(`word literal translation (single language)`, async function() {
+
+ const scription = `
+ \\w waxdungu qasi
+ \\wlt one.day a.man
+ `
+
+ const { dom } = await parse(scription)
+ const wordsContainer = findElementByClass(dom, `words`)
+ const [firstWord, secondWord] = wordsContainer.childNodes.filter(node => node.tagName === `li`)
+
+ expect(getTextContent(firstWord)).to.include(`one.day`)
+ expect(getTextContent(secondWord)).to.include(`a.man`)
+
+ })
+
+ it(`word literal translation (single language)`, async function() {
+
+ const scription = `
+ \\w waxdungu qasi
+ \\wlt-en one.day a.man
+ \\wlt-sp un.día un.hombre
+ `
+
+ const { dom } = await parse(scription)
+ const wordsContainer = findElementByClass(dom, `words`)
+ const [firstWord, secondWord] = wordsContainer.childNodes.filter(node => node.tagName === `li`)
+
+ expect(getTextContent(firstWord)).to.include(`one.day`)
+ expect(getTextContent(firstWord)).to.include(`un.día`)
+ expect(getTextContent(secondWord)).to.include(`a.man`)
+ expect(getTextContent(secondWord)).to.include(`un.hombre`)
+
+ })
+
})