Skip to content

Commit

Permalink
Added the debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Apr 24, 2024
1 parent 4b61a42 commit f1fc653
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 14 additions & 2 deletions odsfile.sty
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ rowseparator=[[\\n]]
\luaexec{odssave="\luatexluaescapestring{#1}"}%
}

\define@key{includespread}{debug}{% use either true or false
\luaexec{odsdebug=\luatexluaescapestring{#1}}%
}

\define@key{includespread}{coltypes}{%
\luaexec{coltypes="\luatexluaescapestring{\unexpanded{#1}}"}%
}
Expand Down Expand Up @@ -70,6 +74,8 @@ columns = split(s,",")
\luaexec{odslastnl="\luatexluaescapestring{\unexpanded{#1}}"}%
}



% Variable initialization and helper functions
\begin{luacode*}
odsreader = require("odsfile")
Expand All @@ -80,6 +86,7 @@ columns = nil
templates = {}
row = {}
odssave = nil
odsdebug = nil
body = nil
odsfilename = ""
currenttemplate = nil
Expand Down Expand Up @@ -126,6 +133,7 @@ odslastnl = "\\OdsLastNl"
columns=nil
currenttemplate = nil
odssave = nil
odsdebug = false
rowtemplate = nil
celltpl = "-{value}"
columnbreak = "\\linebreak{}"
Expand Down Expand Up @@ -224,7 +232,9 @@ odslastnl = "\\OdsLastNl"
end
content = table.concat(content, odsnl .. " " ..rowseparator) .. odslastnl
local result = odsreader.interp(templates[currenttemplate],{content=content,coltypes=coltypes,colheading=colheading,rowsep=rowseparator})
print(result)
if odsdebug then
print(result)
end
if odssave then
odsreader.save(odssave, result)
else
Expand All @@ -238,7 +248,9 @@ odslastnl = "\\OdsLastNl"
end
content = table.concat(content,rowseparator)
local result = odsreader.interp(templates[currenttemplate],{content=content,coltypes=coltypes,colheading=colheading,rowsep=rowseparator})
print(result)
if odsdebug then
print(result)
end
if odssave then
odsreader.save(odssave, result)
else
Expand Down
9 changes: 7 additions & 2 deletions odsfile.tex
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,14 @@ \subsection{Saving the generated table to a file}

\begin{LTXexample}
There should be no table listed
\includespread[sheet=List1,columns=head,escape=false,save=save-test.tex]
\includespread[sheet=List1,columns=head,escape=false,save=save-test.tex,debug=true]
\end{LTXexample}

\subsection{Debugging}

You can print the generated table to the terminal output of \LaTeX\ using the \texttt{debug} option. Possible values are
\texttt{true} and \texttt{false}.


\section{Templates}\label{sec:tpl}

Expand Down Expand Up @@ -422,7 +427,7 @@ \section{Changes}
\begin{description}
\item [devel]
\begin{itemize}
\item added the \texttt{save} option
\item added the \texttt{save} and \texttt{debug }options
\item added support for multiple ranges in the \texttt{range} option
\item added \texttt{newline} and \texttt{lastnewline} options
\end{itemize}
Expand Down

0 comments on commit f1fc653

Please sign in to comment.