I have never tried to include Lua code in a document before so please be gentle. I am after a pattern matching expression that will eventually take (stuff1)->(stuff2) and replace it with !(stuff1)||(stuff2) but baby steps first...
At the bottom of this page: Programming In Lua is a mention of a pattern for matching balanced strings. After modifying some code I found on site I decided to try the following:
\documentclass{article}
\def\swap#1{%
\directlua{%
local s, _ = string.gsub("#1","%b()%b()","%2%1")
tex.sprint(s)}
}
\begin{document}
\swap{(a)(b)}
\end{document}
Which does not work at all. Can anyone explain what I've done wrong?
