2020-05-24 23:10:30 +02:00
|
|
|
function kanjiTable(kanjiArray) {
|
2020-05-25 22:16:04 +02:00
|
|
|
const xLength = 15;
|
2020-05-24 23:10:30 +02:00
|
|
|
const yLength = Math.ceil(kanjiArray.length/xLength);
|
|
|
|
const sideLength = Math.ceil(Math.sqrt(kanjiArray.length));
|
|
|
|
|
|
|
|
let tableString = '';
|
|
|
|
for (let y_index = 0; y_index < yLength; y_index++) {
|
|
|
|
|
|
|
|
const lineArray = new Array;
|
|
|
|
|
|
|
|
for (let x_index = 0; x_index < xLength; x_index++) {
|
2020-05-25 22:16:04 +02:00
|
|
|
const indexNumber = y_index * xLength + x_index;
|
2020-05-24 23:10:30 +02:00
|
|
|
lineArray.push(kanjiArray[indexNumber] ? kanjiArray[indexNumber] : '');
|
|
|
|
}
|
|
|
|
|
|
|
|
tableString += `${lineArray.join(' & ')} \\\\\n`
|
|
|
|
}
|
|
|
|
|
|
|
|
return `\\begin{tabular}{ ${'c '.repeat(xLength)}}
|
|
|
|
${tableString}\\end{tabular}`
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.kanjiTable = kanjiTable;
|