Module:Introspection utils: Difference between revisions
add function to check whether an invocation exists; add function to produce a normalized module name from an invocation |
mNo edit summary |
||
| Line 16: | Line 16: | ||
-- --------------- CODE EXTRACTION AND PREPROCESSING FUNCTIONS ----------------- | -- --------------- CODE EXTRACTION AND PREPROCESSING FUNCTIONS ----------------- | ||
-- ----------------------------------------------------------------------------- | -- ----------------------------------------------------------------------------- | ||
-- Helper function: preprocess lua code | -- Helper function: preprocess lua code | ||
| Line 112: | Line 99: | ||
return normalized | return normalized | ||
end | |||
function p.get_and_preprocess_content(namespace, pagename) | |||
local title = mw.title.new(string.format("%s:%s", namespace, pagename)) | |||
local content = title:getContent() | |||
if string.lower(namespace) == "module" then | |||
return p.preprocess_code(content) | |||
elseif string.lower(namespace) == "template" then | |||
return p.preprocess_wikitext(content) | |||
else | |||
return "" | |||
end | |||
end | end | ||