Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -0,0 +1,40 @@
function csvToHtml(input) {
if (!input || typeof input !== 'string') {
throw new Error('Invalid input!');
}
function _createTableCell(cellContents, index) {
if (!cellContents || typeof cellContents !== 'string') {
throw new Error('Invalid data!');
}
const tableCell = document.createElement(
(index === 0) ? 'th' : 'td'
);
tableCell.textContent = cellContents.trim();
return tableCell;
}
const rows = input.split('\n');
const table = document.createElement('table');
rows.forEach((row, index) => {
const tableRow = document.createElement('tr');
const tableCells = row.split(',');
tableCells.forEach((cell) => {
try {
tableRow.appendChild(
_createTableCell(cell, index),
);
} catch (error) {
console.error(error);
}
});
table.appendChild(tableRow);
});
return table;
}

View file

@ -0,0 +1,14 @@
const inputData = `Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!`;
try {
document.body.append(
csvToHtml(inputData),
);
} catch (error) {
console.error(error)
}