The string manipulation wiki page has an example that does not compile successfully. There must be some syntax to place before and after this code, but I cannot find any details about this in the documentation. The snippet is:
\starttext
str = "Luxury Yacht"
rep = {
[1] = { "Luxury", "Throatwobbler" },
[2] = { "Yacht", "Mangrove" },
}
print("My name is spelled “" .. str .. "”, but it's pronounced “" .. lpeg.replacer(rep):match(str) .. "”.")
\stoptext
- How can I use this feature in my document?
- Can I place all of the text from my document inside
print()to perform some changes to all of the text? E.g., to replace all occurrences of "apple" with "fruit" in the document?
I am particularly interested in using the lpeg.replacer(table) feature.
\directluain the manual. I have tried placing\directlua{}around the code, but this is an "Undefined control sequence." – Village Jan 17 '12 at 13:17\directluaprimitive is wrapped up as\ctxlua. – Joseph Wright Jan 17 '12 at 13:46