Skip to content

Commit

Permalink
NEW: metadata (#27)
Browse files Browse the repository at this point in the history
closes #27
  • Loading branch information
dwhieb committed Oct 26, 2023
1 parent b676f06 commit ea073e2
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 705 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ If the input is a string containing only whitespace, an empty string is returned

## HTML Structure

This section describes the structure of the HTML output by this library, and the classes added to the HTML elements.
This section describes the structure of the HTML output by this library, and the classes added to the HTML elements. You can see sample HTML output by the program in the `samples/` folder.

Each utterance/example in the original Scription text is wrapped in a `<div class=igl>` element by default. You can customize both the tag that is used for the wrapper and the classes applied to it with the `tag` and `classes` options. For example, to wrap each utterance in `<li class=interlinear>`, you would provide the following options:

Expand Down
9 changes: 6 additions & 3 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import convert from '../index.js'
import convert from '../src/index.js'
import esbuild from 'esbuild'
import { fileURLToPath } from 'node:url'
import path from 'path'
Expand All @@ -13,7 +13,7 @@ const contentTag = `<!-- CONTENT -->`

await esbuild.build({
bundle: true,
entryPoints: [`index.js`],
entryPoints: [path.resolve(__dirname, `../src/index.js`)],
minify: true,
outfile: `scription2html.js`,
})
Expand All @@ -24,10 +24,13 @@ const template = await readFile(path.resolve(__dirname, `./template.html`), `utf
const files = await readdir(path.resolve(__dirname, `../samples/data`))

for (const file of files) {

if (!file.endsWith(`.txt`)) continue

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 { html } = convert(scription, { tag: `li` })
const interlinears = `<ul>${ html }</ul>`

content += `\n${ interlinears }`
Expand Down
43 changes: 0 additions & 43 deletions index.js

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
"url": "https://danielhieber.info"
},
"type": "module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/digitallinguistics/scription2html.git"
},
"exports": "./index.js",
"exports": "./src/index.js",
"scripts": {
"build": "node build/index.js",
"stop-only": "stop-only --folder . --skip node_modules,.github",
"test": "mocha *.test.js"
"stop-only": "stop-only --folder src",
"test": "mocha src/**/*.test.js"
},
"devDependencies": {
"@digitallinguistics/eslint-config": "^0.3.0",
Expand Down
14 changes: 5 additions & 9 deletions samples/data/Chitimacha.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
---
abbreviation: A1
title: How the Indian came (first telling)
title: Example Story
---
\trs wetkšˊ husˊ na·nča·kamankšˊ wetkˊ hi hokmiʔiˊ.
\tln He left his brothers.

kunˊ ču·gšˊ ču·gšˊ, še·nink hupˊ hi ničwiʔiˊ.
He went and went till he came to the edge of a pond.

wetkšˊ we še·ninkˊ hi ničwinkišˊ, weykˊ hi kišutiʔiˊ.
When he got to the edge of the pond, he swam it.
waxdungu qasi
waxt-qungu qasi
day-one man
one day a man
4 changes: 4 additions & 0 deletions samples/data/Swahili.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ninaenda
ni-na-end-a
1SG-PRES-go-IND
I am going
20 changes: 20 additions & 0 deletions samples/data/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { readFile } from 'node:fs/promises'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const Algonquian = await readFile(path.resolve(__dirname, `./Algonquian.txt`), `utf8`)
const Chitimacha = await readFile(path.resolve(__dirname, `./Chitimacha.txt`), `utf8`)
const Nuuchahnulth = await readFile(path.resolve(__dirname, `./Nuuchahnulth.txt`), `utf8`)
const OldLatin = await readFile(path.resolve(__dirname, `./OldLatin.txt`), `utf8`)
const Swahili = await readFile(path.resolve(__dirname, `./Swahili.txt`), `utf8`)

export {
Algonquian,
Chitimacha,
Nuuchahnulth,
OldLatin,
Swahili,
}
210 changes: 9 additions & 201 deletions samples/html/Algonquian.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,206 +9,14 @@
</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>
<ul><li class='igl'>
<p class=ex-header>Menominee</p>
</li><li class='igl'>
<p class=ex-header>SW Ojibwe</p>
</li><li class='igl'>
<p class=ex-header>Delaware</p>
</li><li class='igl'>
<p class=ex-header>Blackfoot</p>
</li></ul>
</body>
</html>
Loading

0 comments on commit ea073e2

Please sign in to comment.