Replies: 2 comments
-
|
Use I think you'll then see why the filter above is too simple. You can use Lua's pattern matching and substituting functions to do this more reliably. (Note especially that you can pass a table in as a parameter to |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
You may use here the functions string.match and/or string.gsub. More generally,
if you wish to write Lua filters, it is advisable to learn the basics of Lua
(see https://lua.org/docs.html). Personally, I would recommend the book
Programming in Lua. It takes some time (not so much actually), but it is very
rewarding.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Following the instructions here, I created a Lua filter for Pandoc to automatically expand my abbreviations. My Pandoc version is 3.8.2.1.
In the MWE below, the expansion happens with the abbreviation AI in the heading and the abbreviation ML in the sentence preceded and followed by a space. The abbreviation does, however, not get expanded when the sentence ends with “AI” followed by a punctuation mark.
The expectation would be that the output generated shows “This text is about Artificial Intelligence.” Instead, it remains “This text is about AI.”
While I understand that this probably happens because
AI.is a different string toAIby itself, I’m not familiar with Lua and this is a very useful function that I would really like to use, as I have a very long list of abbreviations that I use frequently. I’ve looked into patterns in Lua to get it to ignore potential following punctuation characters, but unfortunately couldn’t figure out how to modify the code/function so it works.Any help, and, if you can spare the time, an explanation so I understand what’s happening would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions