From 42432994cd151df1c8b7562b40580e851d66ecbf Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 20 Sep 2024 13:22:11 -0700 Subject: [PATCH] PDF now can include images --- notebookgen.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/notebookgen.js b/notebookgen.js index e61b385..d2464ae 100644 --- a/notebookgen.js +++ b/notebookgen.js @@ -7,6 +7,7 @@ const os = require('os') const section = ['\\section{', '\\subsection{', '\\subsubsection{'] const extensions = { + '.png': 'png', '.cc': 'C++', '.cpp': 'C++', '.hpp': 'C++', @@ -30,7 +31,9 @@ function walk (_path, depth) { ans += '\n' + section[depth] + file + '}\n' + walk(f, depth + 1) } else if (path.extname(f) in extensions) { ans += '\n' + section[depth] + file.split('.')[0] + '}\n' - if (path.extname(f) !== '.tex') { + if (path.extname(f) === '.png') { + ans += '\\centering{\\includegraphics[width=8.0cm]{' + normalizeUnixStyle(path.resolve(f)) + '}}' + } else if (path.extname(f) !== '.tex') { ans += `\\begin{lstlisting}[language=${extensions[path.extname(f)]}]\n` + fs.readFileSync(f) + '\\end{lstlisting}\n' } else { ans += fs.readFileSync(f)