Module:Documentation: Difference between revisions
From WikiOasis Meta
More actions
m 1 revision imported from wikipedia:Module:Documentation: Importing from English Wikipedia to sync templates |
mediawiki>Uzume cherry pick Module wikitext support from w:en:Module:Documentation |
||
| Line 82: | Line 82: | ||
ret[#ret + 1] = select(i, ...) | ret[#ret + 1] = select(i, ...) | ||
end | end | ||
return '<small>(' .. table.concat(ret, ' | ') .. ')</small>' | return '<small style="font-style: normal;">(' .. table.concat(ret, ' | ') .. ')</small>' | ||
end | end | ||
| Line 137: | Line 137: | ||
local root = mw.html.create() | local root = mw.html.create() | ||
root | root | ||
:wikitext(p._getModuleWikitext(args, env)) | |||
:wikitext(p.protectionTemplate(env)) | :wikitext(p.protectionTemplate(env)) | ||
:wikitext(p.sandboxNotice(args, env)) | :wikitext(p.sandboxNotice(args, env)) | ||
| Line 326: | Line 327: | ||
-- Auxiliary templates | -- Auxiliary templates | ||
---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ||
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') | |||
function p._getModuleWikitext(args, env) | |||
local currentTitle = mw.title.getCurrentTitle() | |||
if currentTitle.contentModel ~= 'Scribunto' then return end | |||
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care | |||
local moduleWikitext = package.loaded["Module:Module wikitext"] | |||
if moduleWikitext then | |||
return moduleWikitext.main() | |||
end | |||
end | |||
function p.sandboxNotice(args, env) | function p.sandboxNotice(args, env) | ||
| Line 397: | Line 410: | ||
omargs.text = text | omargs.text = text | ||
omargs.class = message('sandbox-class') | omargs.class = message('sandbox-class') | ||
local ret = '<div style="clear: both;"></div>' | |||
ret = ret .. messageBox.main('ombox', omargs) | |||
return ret | |||
end | end | ||
| Line 523: | Line 538: | ||
local function escapeBrackets(s) | local function escapeBrackets(s) | ||
-- Escapes square brackets with HTML entities. | -- Escapes square brackets with HTML entities. | ||
s = s:gsub('%[', '[') -- Replace square brackets with HTML entities. | |||
s = s:gsub('%]', ']') | |||
return s | return s | ||
end | end | ||