diff options
author | Karl Berry <karl@freefriends.org> | 2023-09-07 20:15:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-09-07 20:15:22 +0000 |
commit | 591fa942532c9208ae10e82bea8f929861005501 (patch) | |
tree | f1040d8478a679a69581fabb4e5ea41d3aaf6ce5 /Master/texmf-dist/tex | |
parent | bb9f4360575ae459a789b6602d209e55f7be6e84 (diff) |
odsfile (7sep23)
git-svn-id: svn://tug.org/texlive/trunk@68201 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/odsfile/odsfile.lua | 38 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty | 10 |
2 files changed, 30 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/lualatex/odsfile/odsfile.lua b/Master/texmf-dist/tex/lualatex/odsfile/odsfile.lua index e7112a939df..8fdf30abee6 100644 --- a/Master/texmf-dist/tex/lualatex/odsfile/odsfile.lua +++ b/Master/texmf-dist/tex/lualatex/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/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty b/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty index 0e4085ded03..59b8cfa7606 100644 --- a/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty +++ b/Master/texmf-dist/tex/lualatex/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% }% } |