Allow variable injection with punctuation
This commit is contained in:
parent
a6ed61b4eb
commit
3482586880
2 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
local vars = {}
|
||||
|
||||
local additionalChars = {".", ",", "!", ":", ";"}
|
||||
|
||||
function fileExists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
|
@ -13,7 +15,13 @@ end
|
|||
local function getVars(meta)
|
||||
for k, v in pairs(meta) do
|
||||
if v.t == 'MetaInlines' then
|
||||
vars["$" .. k .. "$"] = v
|
||||
local var_key = "$" .. k .. "$"
|
||||
local var_value = table.unpack(v)["c"]
|
||||
vars[var_key] = var_value
|
||||
for _, char in pairs(additionalChars) do
|
||||
vars[var_key .. char] = var_value .. char
|
||||
vars[char .. var_key] = char .. var_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Hello world
|
||||
|
||||
\lipsum[3-56]
|
||||
|
||||
Foo is equal to \$foo\$.
|
||||
|
|
Reference in a new issue