Module:Sandbox/Aseleste/Indexer: Difference between revisions

Content deleted Content added
Reverted to revision 1001388836 by Aseleste (talk): Remove: debug code
fix: broken replacement - attempt 9 (this should no longer be broken now, but there are other problems)
Line 38:
end
return result
return mw.text.nowiki(mw.dumpObject(args))
end
 
Line 126:
as_key_content_function = function(text)
local function func(content)
returnlocal result = text:gsub("__M_CONTENT__", escape_replacement(content)) -- need this variable to only return 1 result
return result
end
return func
Line 135 ⟶ 136:
as_value_content_function = function(text)
local function func(category)
returnlocal result = text:gsub("__M_CATEGORY__", escape_replacement(category)) -- need this variable to only return 1 result
return result
end
return func
Line 145 ⟶ 147:
local function func(left, right)
-- some improvements could be made here
returnlocal result = text:gsub("__M_LEFT__", escape_replacement(left)):gsub("__M_RIGHT__", escape_replacement(right)) -- need this variable to only return 1 result
return result
end
return func
Line 151 ⟶ 154:
 
-- escapes replacement, replace '%' with '%%'
-- ah, multiple return results cost us headache, apparently multiple return results expand into multiple arguments
escape_replacement = function(text)
returnlocal result = text:gsub("%%", "%%%%") -- need this variable to only return 1 result
return result
end
 
unstrip_and_strip_nowiki_tags = function(text)
returnlocal result = mw.text.unstripNoWiki(text):gsub("<nowiki>", ""):gsub("</nowiki>", "") -- need this variable to only return 1 result
return result
end