From 45347ca298cf272a4c2a6a0bd1708f4ca498bb7f Mon Sep 17 00:00:00 2001 From: Tatakinov Date: Sat, 7 Jan 2023 14:35:11 +0900 Subject: [PATCH] =?UTF-8?q?kotori=E3=81=AE=E6=9B=B4=E6=96=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ghost/master/corelib/path/init.lua | 5 +++++ ghost/master/shiori/init.lua | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ghost/master/corelib/path/init.lua b/ghost/master/corelib/path/init.lua index 7d24755..84d4a5c 100644 --- a/ghost/master/corelib/path/init.lua +++ b/ghost/master/corelib/path/init.lua @@ -8,6 +8,11 @@ function M.join(...) return table.concat(t, SEP) end +function M.basename(path) + local match = string.match(path, [[.+[/\](.-)$]]) + return match or path +end + function M.normalize(path) -- TODO stub return path diff --git a/ghost/master/shiori/init.lua b/ghost/master/shiori/init.lua index eb20b70..7c9ad20 100644 --- a/ghost/master/shiori/init.lua +++ b/ghost/master/shiori/init.lua @@ -47,7 +47,8 @@ function M:load(path) --トーク読み込み Path.dirWalk(path .. "talk", function(file_path) - if string.sub(file_path, 1, 1) == "_" or string.sub(file_path, -4, -1) ~= ".lua" then + local file_name = Path.basename(file_path) + if string.sub(file_name, 1, 1) == "_" or string.sub(file_name, -4, -1) ~= ".lua" then return end local t, err = (function() @@ -267,8 +268,10 @@ function M:autoReplace(x) end function M:autoReplaceVars(str) - local str = string.gsub(str, "%${([^}]+)}", function(s) - --print("replace: " .. s) + local str = str:gsub("(\\?)%${([^}]+)}", function(escape, s) + if escape == "\\" then + return string.format("${%s}", s) + end return tostring(self.var(s)) end) return str