Fix some bugs
This commit is contained in:
parent
1c7ffaebc3
commit
e0334cfbab
|
@ -18,7 +18,7 @@ async function main(grade) {
|
||||||
const kanjiArray = jishoResults.map(result => result.query);
|
const kanjiArray = jishoResults.map(result => result.query);
|
||||||
|
|
||||||
log('Generating tex pages');
|
log('Generating tex pages');
|
||||||
const texData = getKanjiTexData(jishoResults);
|
const texData = getKanjiTexData(jishoResults, grade);
|
||||||
|
|
||||||
log('Generating chapter table page');
|
log('Generating chapter table page');
|
||||||
const chapterTable = chapterTabular(kanjiArray, 16);
|
const chapterTable = chapterTabular(kanjiArray, 16);
|
||||||
|
|
|
@ -3,7 +3,10 @@ function makeNumberRow(rowLength) {
|
||||||
numberRow = numberRow.map((number) => (number + 1).toString()); // Correct numbers and convert to string
|
numberRow = numberRow.map((number) => (number + 1).toString()); // Correct numbers and convert to string
|
||||||
numberRow = numberRow.map((number) => `{\\large ${number}}`); // Encapsulate numbers in TeX code
|
numberRow = numberRow.map((number) => `{\\large ${number}}`); // Encapsulate numbers in TeX code
|
||||||
numberRow = [' ', ...numberRow];
|
numberRow = [' ', ...numberRow];
|
||||||
return `${numberRow.join(' & ')} \\\\\n\\hline\n\\endhead\n`;
|
return `
|
||||||
|
${numberRow.join(' & ')} \\\\
|
||||||
|
\\hline
|
||||||
|
\\endhead\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function kanjiRow(index, rowLength, kanjiArray) {
|
function kanjiRow(index, rowLength, kanjiArray) {
|
||||||
|
@ -25,7 +28,7 @@ function makeRows(rowLength, columnLength, kanjiArray) {
|
||||||
line.push(`{\\large ${index}}`);
|
line.push(`{\\large ${index}}`);
|
||||||
|
|
||||||
// Concatenate the number with the rest of the row
|
// Concatenate the number with the rest of the row
|
||||||
line = [line, kanjiRow(index, rowLength, kanjiArray)];
|
line = [...line, ...kanjiRow(index, rowLength, kanjiArray)];
|
||||||
|
|
||||||
// Convert the line array into a tex row and add it to result.
|
// Convert the line array into a tex row and add it to result.
|
||||||
result += `${line.join(' & ')} \\\\\n`;
|
result += `${line.join(' & ')} \\\\\n`;
|
||||||
|
|
|
@ -5,7 +5,7 @@ const stylingBrackets = {
|
||||||
const yomiConnector = '、 ';
|
const yomiConnector = '、 ';
|
||||||
const yomiDash = '—';
|
const yomiDash = '—';
|
||||||
|
|
||||||
const styleText = (string) => stylingBrackets.start + string + stylingBrackets.end;
|
const styleText = (string) => `\\emphasize{${string}}`;
|
||||||
|
|
||||||
function styleCharactersBeforeDot(string) {
|
function styleCharactersBeforeDot(string) {
|
||||||
const words = string.split('.');
|
const words = string.split('.');
|
||||||
|
@ -80,19 +80,22 @@ const makeFirstLetterUppercase = (string) => string.charAt(0).toUpperCase() + st
|
||||||
/**
|
/**
|
||||||
* Generate TeX strings from Jisho data
|
* Generate TeX strings from Jisho data
|
||||||
* @param {object[]} jishoResults Array of results fetched from Jisho
|
* @param {object[]} jishoResults Array of results fetched from Jisho
|
||||||
|
* @param {string} grade
|
||||||
* @returns {object} An object containg TeX strings
|
* @returns {object} An object containg TeX strings
|
||||||
*/
|
*/
|
||||||
function getKanjiTexData(jishoResults) {
|
function getKanjiTexData(jishoResults, grade) {
|
||||||
return jishoResults.map(jishoResult => {
|
return jishoResults.map(jishoResult => {
|
||||||
|
|
||||||
const meaning = convertMeaning(jishoResult);
|
const meaning = convertMeaning(jishoResult);
|
||||||
const kunyomi = convertKunyomi(jishoResult);
|
const kunyomi = convertKunyomi(jishoResult);
|
||||||
const onyomi = convertOnyomi(jishoResult);
|
const onyomi = convertOnyomi(jishoResult);
|
||||||
|
|
||||||
jishoResult.taughtIn = jishoResult.taughtIn ? makeFirstLetterUppercase(jishoResult.taughtIn) : '';
|
grade = grade.slice(0,5) + ' ' + grade.slice(5);
|
||||||
|
grade = makeFirstLetterUppercase(grade);
|
||||||
|
if (grade === 'Grade 7') grade = 'Junior high'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kanjiPageHeader: `\\kanjiPageHeader{${jishoResult.query}}{${jishoResult.taughtIn}}{${jishoResult.jlptLevel}}{${jishoResult.strokeCount}}{${jishoResult.radical.symbol}}`,
|
kanjiPageHeader: `\\kanjiPageHeader{${jishoResult.query}}{${grade}}{${jishoResult.jlptLevel}}{${jishoResult.strokeCount}}{${jishoResult.radical.symbol}}`,
|
||||||
kanjiMeaning: meaning ? `\\kanjiMeaning{${meaning}}` : '',
|
kanjiMeaning: meaning ? `\\kanjiMeaning{${meaning}}` : '',
|
||||||
kunyomi: kunyomi ? `\\kunyomi{${kunyomi}}` : '',
|
kunyomi: kunyomi ? `\\kunyomi{${kunyomi}}` : '',
|
||||||
onyomi: onyomi ? `\\onyomi{${onyomi}}` : '',
|
onyomi: onyomi ? `\\onyomi{${onyomi}}` : '',
|
||||||
|
|
|
@ -135,6 +135,8 @@
|
||||||
% Kunyomi and Onyomi %
|
% Kunyomi and Onyomi %
|
||||||
% ---------------------------------------------------------------------------- %
|
% ---------------------------------------------------------------------------- %
|
||||||
|
|
||||||
|
\newcommand{\emphasize}[1]{\textbf{\textcolor{kanjiColor!80!black}{#1}}}
|
||||||
|
|
||||||
\newtcolorbox{kunyomiBox}{
|
\newtcolorbox{kunyomiBox}{
|
||||||
enhanced,
|
enhanced,
|
||||||
attach boxed title to top left={yshift=-12pt,xshift=10pt},
|
attach boxed title to top left={yshift=-12pt,xshift=10pt},
|
||||||
|
|
12
main.tex
12
main.tex
|
@ -60,21 +60,21 @@
|
||||||
\input{./data/pages/grade1.tex}
|
\input{./data/pages/grade1.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Grade 2}{grade2}
|
\chapterIntroduction{Grade 2}{grade2}
|
||||||
\input{./data/pages/grade2.tex}
|
% \input{./data/pages/grade2.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Grade 3}{grade3}
|
\chapterIntroduction{Grade 3}{grade3}
|
||||||
\input{./data/pages/grade3.tex}
|
% \input{./data/pages/grade3.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Grade 4}{grade4}
|
\chapterIntroduction{Grade 4}{grade4}
|
||||||
\input{./data/pages/grade4.tex}
|
% \input{./data/pages/grade4.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Grade 5}{grade5}
|
\chapterIntroduction{Grade 5}{grade5}
|
||||||
\input{./data/pages/grade5.tex}
|
% \input{./data/pages/grade5.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Grade 6}{grade6}
|
\chapterIntroduction{Grade 6}{grade6}
|
||||||
\input{./data/pages/grade6.tex}
|
% \input{./data/pages/grade6.tex}
|
||||||
|
|
||||||
\chapterIntroduction{Junior High}{grade7}
|
\chapterIntroduction{Junior High}{grade7}
|
||||||
\input{./data/pages/grade7.tex}
|
% \input{./data/pages/grade7.tex}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
Loading…
Reference in New Issue