From 34825868805ba5b6c482c93d0bfce31e273c6689 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 3 Apr 2018 12:00:20 +0100 Subject: [PATCH] Allow variable injection with punctuation --- second-pass.lua | 10 +++++++++- test/main.md | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/second-pass.lua b/second-pass.lua index b1b305f..402c641 100644 --- a/second-pass.lua +++ b/second-pass.lua @@ -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 diff --git a/test/main.md b/test/main.md index 730f4a3..1776034 100644 --- a/test/main.md +++ b/test/main.md @@ -1,3 +1,5 @@ # Hello world \lipsum[3-56] + +Foo is equal to \$foo\$.