React to a Command or a Comment to start the Lua Code

i asked a question a few weeks ago for some Lua Code, that splits my table cell into two cells, if i type a new line. Here is the code:

\begin{luacode*}
function doline(line)
local splitpoint = string.find(line, "=")
local title = line:sub(1, splitpoint-1)
local description = string.gsub(line:sub(splitpoint + 1), "\\par", "\n")
tex.print(title)
for token in string.gmatch(description, "[^\n]+") do
tex.print("&\\multicolumn{4}{p{11cm}}{" .. token .. "}\\\\[2pt]")
end
tex.print("\\hline")
end
\end{luacode*}
\newcommand{\tabularline}[1]{%
\directlua{
doline("\luatexluaescapestring{\detokenize{#1}}")
}}


My problem now is, that there is an empty line, if there is an itemize inside the cell. it looks weird because there are empty lines, that shouldn't be there. The idea was to react to a string like a \newcell or %---newcell but i'm not so good with Lua so i'm looking for some help. Hope, you have any idea.

• This is the question i aked before: tex.stackexchange.com/questions/482739/… – Narhog May 22 at 8:31
• This doesn't look very efficient and like an XY problem. What are you actually trying to do? – Henri Menke May 22 at 8:40
• The Problem is, if there is an massive amount of text in table cell, latex doesn't make a page break and your text disappears at the bottom of your page. The Table is created by a macro, so the idea was to write a code, which writes the Text into a new cell so there is a page break and the text doesn't disappear. but instead of typing a new line in the code i want to do it with a command now, if it is possible – Narhog May 22 at 8:46
• If you are willing to switch to ConTeXt for that document you can use the tabulate environment which can break cells across pages. – Henri Menke May 22 at 8:49
• surely if you want to allow page breaking over a table cell you want to break at lines in the output not based on newlines on the source? – David Carlisle May 22 at 13:07