summaryrefslogtreecommitdiff
path: root/macros/luatex/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-09-08 03:02:30 +0000
committerNorbert Preining <norbert@preining.info>2023-09-08 03:02:30 +0000
commit608e422a8e775ac4d1c23c80b4170776701680d5 (patch)
treed1e69057c0dc339fb0f890882f5fef9fe3b3a66f /macros/luatex/latex
parent96f1d7a9e9fe6e682cbd19d1bf2b7797891160b6 (diff)
CTAN sync 202309080302
Diffstat (limited to 'macros/luatex/latex')
-rw-r--r--macros/luatex/latex/odsfile/odsfile.lua38
-rw-r--r--macros/luatex/latex/odsfile/odsfile.pdfbin94940 -> 97289 bytes
-rw-r--r--macros/luatex/latex/odsfile/odsfile.sty10
-rw-r--r--macros/luatex/latex/odsfile/odsfile.tex33
-rw-r--r--macros/luatex/latex/odsfile/pokus.odsbin11019 -> 12024 bytes
5 files changed, 60 insertions, 21 deletions
diff --git a/macros/luatex/latex/odsfile/odsfile.lua b/macros/luatex/latex/odsfile/odsfile.lua
index e7112a939d..8fdf30abee 100644
--- a/macros/luatex/latex/odsfile/odsfile.lua
+++ b/macros/luatex/latex/odsfile/odsfile.lua
@@ -42,7 +42,8 @@ function getTable(x,table_name)
for i = 1, #val do
local r = val[i]
- local rowRep = r["_attr"]["table:number-rows-repeated"] or 1
+ local rattr = r["_attr"] or {}
+ local rowRep = rattr["table:number-rows-repeated"] or 1
row = {}
row["_attr"] = r["_attr"]
@@ -214,19 +215,23 @@ function interp(s, tab)
end
function escape(s)
- return string.gsub(s, "([%\\]?)([#%%%$&_%{%}%\\|])", function(a,b)
- if a=="" then
- if b == "\\" then
- return "\\textbackslash"
- elseif b == "|" then
- return "\\textbar"
- else
- return "\\"..b
+ if latexescape=="true" then
+ return string.gsub(s, "([%\\]?)([#%%%$&_%{%}%\\|])", function(a,b)
+ if a=="" then
+ if b == "\\" then
+ return "\\textbackslash{}"
+ elseif b == "|" then
+ return "\\textbar{}"
+ else
+ return "\\"..b
+ end
+ elseif a=="\\" and b=="\\" then
+ return "\\textbackslash\\textbackslash{}"
end
- elseif a=="\\" and b=="\\" then
- return "\\textbackslash\\textbackslash"
- end
- end)
+ end)
+ else
+ return s
+ end
end
get_link = function(val)
@@ -268,6 +273,7 @@ function newRow()
cells = {},
-- Generic function for inserting cell
addCell = function(self,val, attr,pos)
+ local attr = attr or {}
if pos then
table.insert(self.cells,pos,{["text:p"] = val, ["_attr"] = attr})
self.pos = pos
@@ -298,7 +304,7 @@ function newRow()
return #sheet["table:table-row"]+1
end,
insert = function(self, sheet, pos)
- local t = {}
+ local t = {_attr = {}}
local pos = pos or self:findLastRow(sheet)
print("pos je: ",pos)
if sheet["table:table-column"]["_attr"] and sheet["table:table-column"]["_attr"]["table:number-columns-repeated"] then
@@ -307,9 +313,9 @@ function newRow()
table_columns = #sheet["table:table-column"]
end
for i=1, table_columns do
- table.insert(t,self.cells[i] or {})
+ table.insert(t,self.cells[i] or {_attr={}})
end
- t = {["table:table-cell"]=t}
+ t = {["table:table-cell"]=t, _attr = {}}
table.insert(sheet["table:table-row"],pos,t)
end
}
diff --git a/macros/luatex/latex/odsfile/odsfile.pdf b/macros/luatex/latex/odsfile/odsfile.pdf
index 7ea30cb63f..20e61a2d0f 100644
--- a/macros/luatex/latex/odsfile/odsfile.pdf
+++ b/macros/luatex/latex/odsfile/odsfile.pdf
Binary files differ
diff --git a/macros/luatex/latex/odsfile/odsfile.sty b/macros/luatex/latex/odsfile/odsfile.sty
index 0e4085ded0..59b8cfa760 100644
--- a/macros/luatex/latex/odsfile/odsfile.sty
+++ b/macros/luatex/latex/odsfile/odsfile.sty
@@ -1,6 +1,6 @@
% Package odsfile. Author Michal Hoftich <michal.h21@gmail.com>
% This package is subject of LPPL license, version 1.3c
-\ProvidesPackage{odsfile}[2022/12/13 v0.7 odsfile package to select cells from ODS sheets and
+\ProvidesPackage{odsfile}[2023/09/07 v0.8 odsfile package to select cells from ODS sheets and
typeset them as LaTeX tables]
\RequirePackage{luacode,xkeyval,xparse}
@@ -13,6 +13,7 @@
\define@key{includespread}{rowtemplate}{\luaexec{rowtemplate="\luatexluaescapestring{\detokenize{#1}}"}}%
\define@key{includespread}{celltemplate}{\luaexec{celltpl="\luatexluaescapestring{\detokenize{#1}}"}}%
\define@key{includespread}{multicoltemplate}{\luaexec{multicoltpl="\luatexluaescapestring{\unexpanded{#1}}"}}%
+\define@key{includespread}{escape}{\luaexec{latexescape="\luatexluaescapestring{\unexpanded{#1}}"}}%
\newcommand\OdsNl{\\}
\newcommand\OdsLastNl{\\}
@@ -72,6 +73,7 @@ currenttemplate = nil
rowtemplate = nil
celltpl = "-{value}"
multicoltpl = "\\multicolumn{-{count}}{l}{-{value}}"
+latexescape = "true"
\end{luacode*}
\newcommand\loadodsfile[2][]{%
@@ -112,6 +114,7 @@ multicoltpl = "\\multicolumn{-{count}}{l}{-{value}}"
celltpl = "-{value}"
columnbreak = "\\linebreak{}"
coltypes = nil
+ latexescape = "true"
}%
\setkeys{includespread}{#1}%
\luaexec{%
@@ -142,7 +145,8 @@ multicoltpl = "\\multicolumn{-{count}}{l}{-{value}}"
else
value = odsreader.interp(celltpl, {value = value})
end
- table.insert(t,value)
+ % table.insert(t,value)
+ t[i] = value
headings[i] = br
i = i + x
end
@@ -251,6 +255,8 @@ if pos == "" then pos = nil end; row = odsreader.newRow()%
\luaexec{%
body = body or odsreader.getTable(odsfile)
row:insert(body,pos)%
+% we must save the updated table to the original table
+odsfile.root["office:document-content"]["office:body"]["office:spreadsheet"]["table:table"] = body%
}%
}
diff --git a/macros/luatex/latex/odsfile/odsfile.tex b/macros/luatex/latex/odsfile/odsfile.tex
index 9aefc2a890..e3b5fcda78 100644
--- a/macros/luatex/latex/odsfile/odsfile.tex
+++ b/macros/luatex/latex/odsfile/odsfile.tex
@@ -8,7 +8,7 @@
\author{Michal Hoftich (\url{michal.h21@gmail.com})}
\title{The \textsf{odsfile} package:\\
accessing of the \textsf{opendocument spreadsheet} from \LaTeX{}
-documents\thanks{Version 0.7, last revisited 2022-12-13.}
+documents\thanks{Version 0.8, last revisited 2023-09-07.}
}
\usepackage[english]{babel}
\lstloadlanguages{[LaTeX]Tex}
@@ -36,7 +36,7 @@ This is \LuaLaTeX{} package and \textsf{lua} library for working with
Their contents can be read as \LaTeX{} tables, can be pass to macros,
you can also add new data to existing spreadsheets.
-\ods format consist of number of |xml| files packed in the |zip| file.
+The \ods format consist of number of |xml| files packed in the |zip| file.
This package uses \LuaTeX's zip library, LuaXML library\footnote{Pure |lua| library
for working with |xml| files, it is available form CTAN or \url{https://github.com/michal-h21/LuaXML}} and lua scripting to read |xml| content from this archive,
which means that it is not possible to use this package with pdf\LaTeX{} or \XeLaTeX.
@@ -205,6 +205,26 @@ command
\end{description}
+\subsection{Character escaping}
+
+To prevent compilation errors, \textsf{odsfile} escapes characters that have special meaning in \LaTeX,
+for example backslashes or dollar characters. In some cases, you may want to
+execute the \TeX\ code that is saved in the spreadsheet. In that case, use the \texttt{escape} option:
+
+\begin{description}
+
+\item[escape] Set the value to false to ignore special characters in the cell data.
+\end{description}
+
+The following example prints the left cell in the last row in table in bold, because the original
+spreadsheet contains the \verb|\textbf{bold}| command.
+
+\begin{LTXexample}
+\begin{tabular}{lll}
+\includespread[sheet=List1,columns=head,escape=false]
+\end{tabular}
+\end{LTXexample}
+
\section{Templates}\label{sec:tpl}
@@ -272,7 +292,7 @@ Position specifies cell, where data should be added, if you leave it blank, it w
You can explicitly load \ods file with \marginpar{\cmd{\loadodsfile}}\cmd{\loadodsfile}\oarg{key val list}\marg{filename}. This can be useful, if you only want to write some data to the file, otherwise it is better to use \cmd{\includespread}.
-For saving spreadsheets modified with |AddRow|, you can use \cmd{\savespreadsheet}\marginpar{\cmd{\savespreadsheet}}. This command uses call to external |zip| utility, so you should have installed it and you have to call lua\LaTeX with |lualatex --shell-escape filename|. Lua\LaTeX also must have write permissions for accessing the \ods file. This command creates file |content.xml| in the current directory, so if externall call fails, you can run
+For saving spreadsheets modified with |AddRow|, you can use \cmd{\savespreadsheet}\marginpar{\cmd{\savespreadsheet}}. This command uses call to external |zip| utility, so you should have installed it and you have to call Lua\LaTeX\ with |lualatex --shell-escape filename|. Lua\LaTeX\ also must have write permissions for accessing the \ods file. This command creates file |content.xml| in the current directory, so if externall call fails, you can run
\begin{verbatim}
zip -r filename.ods content.xml
\end{verbatim}
@@ -381,6 +401,13 @@ CC & 5 & 7
\section{Changes}
\begin{description}
+ \item[v0.8]
+ \begin{itemize}
+ \item added the escape option for enabling or disabling of the character escaping
+ \item fixed handling of merged cells in ranges
+ \item fixed escaping of backslashes
+ \item fixed row insertion
+ \end{itemize}
\item[v0.7]
\begin{itemize}
\item Fixed character escaping. Unescaped ``\%,\#,\$, \_ and \&'' characters will be escaped to prevent compilation errors.
diff --git a/macros/luatex/latex/odsfile/pokus.ods b/macros/luatex/latex/odsfile/pokus.ods
index 52bdbf4cc3..c54ad84a69 100644
--- a/macros/luatex/latex/odsfile/pokus.ods
+++ b/macros/luatex/latex/odsfile/pokus.ods
Binary files differ