TransWikia.com

To Remove Enter marks (n) in Lua

TeX - LaTeX Asked on May 10, 2021

enter image description hereI have using LuaLaTeX Version : 1.12.0 and i have converting XML to LaTeX using Lua Script.

I have need to remove enter marks in Lua Scripts. How to achieve this.

documentclass{article}
begin{document}
title{Classical and Quantum Gravity}
author{Author Here}
maketitle
end{document}

I have tried many ways in Lua. My Lua Code is:

TeXIn=string.gsub(TeXIn,[[n]],[[]])
TeXIn=string.gsub(TeXIn,[[stringn]],[[]])
TeXIn=string.gsub(TeXIn,[[nstring]],[[]])
TeXIn=string.gsub(TeXIn,[[stringnstring]],[[]])
TeXIn=string.gsub(TeXIn,[[par]],[[]])
io.write(TeXIn) -- for display the text in terminal/command prompt
tex.sprint(TeXIn) -- for print the text and view in PDF

tex.tprint is not working.

How to solve this problem?

One Answer

It appears that you want to print the entire document in a semi-verbatim style as one long line wrapped string

so if z1z.tex is

documentclass{article}
begin{document}
title{Classical and Quantum Gravity}
author{Author Here}
maketitle
end{document}

and z1z.lua is

local f = assert(io.open("z1z.tex", "rb"))
local TeXIn = f:read("*all")
f:close()


tex.sprint(TeXIn)

then these can be combined with the luatex document


documentclass{article}

begin{document}

defzz#1{{%
catcode10=10 % control-j is space
catcode`=12 % verbatimish output
catcode`{=12 % verbatimish output
catcode`}=12 % verbatimish output
ttfamily    % monospace
directlua{dofile('#1')}
}}

zz{z1z.lua}

end{document}

which produces the result

enter image description here

The Lua here is doing nothing other than inputting the file, but perhaps in your real use case, it may play a role.

Correct answer by David Carlisle on May 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP