Skip to content

Commit

Permalink
DOCS: Add sample HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Oct 26, 2023
1 parent 174f6e3 commit b676f06
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 7 deletions.
39 changes: 39 additions & 0 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import convert from '../index.js'
import esbuild from 'esbuild'
import { fileURLToPath } from 'node:url'
import path from 'path'

import { readdir, readFile, writeFile } from 'node:fs/promises'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const contentTag = `<!-- CONTENT -->`

// Bundle JavaScript for browsers

await esbuild.build({
bundle: true,
entryPoints: [`index.js`],
minify: true,
outfile: `scription2html.js`,
})

// Build samples

const template = await readFile(path.resolve(__dirname, `./template.html`), `utf8`)
const files = await readdir(path.resolve(__dirname, `../samples/data`))

for (const file of files) {
const scription = await readFile(path.resolve(__dirname, `../samples/data`, file), `utf8`)
const filename = path.basename(file, `.txt`)
let content = `<h1>${ filename }</h1>`
const { html } = convert(scription)
const interlinears = `<ul>${ html }</ul>`

content += `\n${ interlinears }`

const sample = template.replace(contentTag, content)

await writeFile(path.resolve(__dirname, `../samples/html`, `${ filename }.html`), sample)

}
13 changes: 13 additions & 0 deletions build/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content='width=device-width, initial-scale=1.0, shrink-to-fit=no'>
<title>scription2html Samples</title>
<meta name=author content='Daniel W. Hieber'>
<link rel=author href=https://danielhieber.info>
</head>
<body>
<!-- CONTENT -->
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"exports": "./index.js",
"scripts": {
"build": "esbuild --bundle --minify --outfile=scription2html.js index.js",
"build": "node build/index.js",
"stop-only": "stop-only --folder . --skip node_modules,.github",
"test": "mocha *.test.js"
},
Expand Down
12 changes: 6 additions & 6 deletions samples/Algonquian.txt → samples/data/Algonquian.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Menominee
\txn pemētaehkipew
\m paemet-aehkw-ape
\gl crosswise-face-sit
\gl initial-medial-final
\tln S/he sits sideways.
\s (Bloomfield 1975: 208)
\txn pemētaehkipew
\m paemet-aehkw-ape
\gl crosswise-face-sit
\gl-en initial-medial-final
\tln S/he sits sideways.
\s (Bloomfield 1975: 208)

# SW Ojibwe
ozhaashisagaa
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
214 changes: 214 additions & 0 deletions samples/html/Algonquian.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content='width=device-width, initial-scale=1.0, shrink-to-fit=no'>
<title>scription2html Samples</title>
<meta name=author content='Daniel W. Hieber'>
<link rel=author href=https://danielhieber.info>
</head>
<body>
<h1>Algonquian</h1>
<ul><div class='igl'>{
"metadata": "Menominee",
"transcription": {
"default": "pemētaehkipew"
},
"translation": "S/he sits sideways.",
"source": "(Bloomfield 1975: 208)",
"words": [
{
"transcription": {
"default": ""
},
"analysis": {
"default": "paemet-aehkw-ape"
},
"gloss": {
"gl": "crosswise-face-sit",
"en": "initial-medial-final"
},
"morphemes": [
{
"transcription": {
"default": "paemet"
},
"gloss": {
"gl": "crosswise",
"en": "initial"
}
},
{
"transcription": {
"default": "aehkw"
},
"gloss": {
"gl": "face",
"en": "medial"
}
},
{
"transcription": {
"default": "ape"
},
"gloss": {
"gl": "sit",
"en": "final"
}
}
]
}
]
}</div><div class='igl'>{
"metadata": "SW Ojibwe",
"transcription": {
"default": "ozhaashisagaa"
},
"translation": "It is a slippery floor.",
"source": "(Nichols 2015)",
"words": [
{
"transcription": {
"default": ""
},
"analysis": {
"default": "ozhaash-sag-aa"
},
"gloss": {
"gl": "slippery-floor-stat",
"en": "initial-medial-final"
},
"morphemes": [
{
"transcription": {
"default": "ozhaash"
},
"gloss": {
"gl": "slippery",
"en": "initial"
}
},
{
"transcription": {
"default": "sag"
},
"gloss": {
"gl": "floor",
"en": "medial"
}
},
{
"transcription": {
"default": "aa"
},
"gloss": {
"gl": "stat",
"en": "final"
}
}
]
}
]
}</div><div class='igl'>{
"metadata": "Delaware",
"transcription": {
"default": "kwənaskwat"
},
"translation": "It is long grass.",
"source": "(O'Meara 1990: 250)",
"words": [
{
"transcription": {
"default": ""
},
"analysis": {
"default": "kwən-askw-at"
},
"gloss": {
"gl": "long-grass-inan",
"en": "initial-medial-final"
},
"morphemes": [
{
"transcription": {
"default": "kwən"
},
"gloss": {
"gl": "long",
"en": "initial"
}
},
{
"transcription": {
"default": "askw"
},
"gloss": {
"gl": "grass",
"en": "medial"
}
},
{
"transcription": {
"default": "at"
},
"gloss": {
"gl": "inan",
"en": "final"
}
}
]
}
]
}</div><div class='igl'>{
"metadata": "Blackfoot",
"transcription": {
"default": "sisáápittakit"
},
"translation": "shred (the hide) into strips",
"source": "(Frantz & Genee 2015)",
"words": [
{
"transcription": {
"default": ""
},
"analysis": {
"default": "siso-ap-ittaki"
},
"gloss": {
"gl": "cut-stringlike-by.blade",
"en": "initial-medial-final"
},
"morphemes": [
{
"transcription": {
"default": "siso"
},
"gloss": {
"gl": "cut",
"en": "initial"
}
},
{
"transcription": {
"default": "ap"
},
"gloss": {
"gl": "stringlike",
"en": "medial"
}
},
{
"transcription": {
"default": "ittaki"
},
"gloss": {
"gl": "by.blade",
"en": "final"
}
}
]
}
]
}</div></ul>
</body>
</html>
38 changes: 38 additions & 0 deletions samples/html/Chitimacha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content='width=device-width, initial-scale=1.0, shrink-to-fit=no'>
<title>scription2html Samples</title>
<meta name=author content='Daniel W. Hieber'>
<link rel=author href=https://danielhieber.info>
</head>
<body>
<h1>Chitimacha</h1>
<ul><div class='igl'>{
"transcript": {
"default": "wetkšˊ husˊ na·nča·kamankšˊ wetkˊ hi hokmiʔiˊ."
},
"transcription": {
"default": ""
},
"translation": "He left his brothers."
}</div><div class='igl'>{
"transcript": {
"default": "kunˊ ču·gšˊ ču·gšˊ, še·nink hupˊ hi ničwiʔiˊ."
},
"transcription": {
"default": ""
},
"translation": "He went and went till he came to the edge of a pond."
}</div><div class='igl'>{
"transcript": {
"default": "wetkšˊ we še·ninkˊ hi ničwinkišˊ, weykˊ hi kišutiʔiˊ."
},
"transcription": {
"default": ""
},
"translation": "When he got to the edge of the pond, he swam it."
}</div></ul>
</body>
</html>
Loading

0 comments on commit b676f06

Please sign in to comment.