1
Fork 0

Allow variable injection with punctuation

This commit is contained in:
Jake Howard 2018-04-03 12:00:20 +01:00
parent a6ed61b4eb
commit 3482586880
2 changed files with 11 additions and 1 deletions

View file

@ -1,5 +1,7 @@
local vars = {} local vars = {}
local additionalChars = {".", ",", "!", ":", ";"}
function fileExists(name) function fileExists(name)
local f=io.open(name,"r") local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end if f~=nil then io.close(f) return true else return false end
@ -13,7 +15,13 @@ end
local function getVars(meta) local function getVars(meta)
for k, v in pairs(meta) do for k, v in pairs(meta) do
if v.t == 'MetaInlines' then 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 end
end end

View file

@ -1,3 +1,5 @@
# Hello world # Hello world
\lipsum[3-56] \lipsum[3-56]
Foo is equal to \$foo\$.