I know this title is pretty bad but I couldnt come up with something better.
Basically what I want is to be able to write normal text, but that it displays in PDF in a custom alphabet once compiled. This is different than just using a custom font because for example, if I write "la" it should corresponds to one character, and "lo" to another different character.
The point is I want to be able to write it without using ten billion macros myself, for example writing \customLA \customLO instead of la lo would be extremely tedious if I want to write lines and lines.
Is there a simple and automatic way to do it with LaTeX? Or should i write my own parsing program in C++ to modifiy the LaTeX file to replace characters combinations with macros?
Best Answer
This is a simple replacement tool at a Lua level. Everything written in
\parseme
is a target for replacements, but the TeX commands are not expanded and we can hide a portion of text from replacement procedure. The replacements are stored in a simple Lua table, the first column contains the searched terms and the second column contains their replacements. Testing goes from top to bottom. For instanceA
is replaced quite soon and never again. On the other hand,X
is going to beY
, thenY
goes toZ
and that goes toA
. The name of commands will be replaced, e.g.\colorme
would become\cojuicerme
. I used the\clrme
command to illustrate a fast workaround, if needed.If you need even more advanced tool for string manipulations than the
string
library can offer, I can recommend youLPeg
library, that's a tool which is already installed in LuaTeX. Some examples are mentioned in Programming in LuaTeX article.If you run my example you will see
1 2 3 4 5 6
three times in the terminal. It means there were 6 replacement tests called three times by the\parseme
command during typesetting.