模組:FakeH
外观
local p = {}
local mError = require('Module:Error').error
local csslist = {
[1] = "font-size: 1.8em; margin-top: 1em; margin-bottom: 0.25em; display: block; line-height: 1.3; border-bottom-color: rgb(162, 169, 177); border-bottom-style: solid; border-bottom-width: 1px; font-family: 'Linux Libertine','Georgia','Times',serif",
[2] = "font-size: 1.5em; margin-top: 1em; line-height: 1.3; display: block; border-bottom-color: rgb(162, 169, 177); border-bottom-style: solid; border-bottom-width: 1px; font-family: 'Linux Libertine','Georgia','Times',serif",
[3] = "font-size: 1.2em; font-weight: bold; display: block; margin-top: 0.3em; padding-top: 0.5em;",
[4] = "font-size: 100%; font-weight: bold; display: block; margin-top: 0.3em; padding-top: 0.5em;",
[5] = "font-size: 100%; font-weight: bold; display: block; margin-top: 0.3em; padding-top: 0.5em;",
[6] = "font-size: 100%; font-weight: bold; display: block; margin-top: 0.3em; padding-top: 0.5em;"
}
local function getFakeH (level, text)
return tostring(mw.html.create('span'):cssText(csslist[level]):wikitext(text):done())
end
function p._main (configs, text)
local frame = mw.getCurrentFrame()
local level = configs.level
if not tonumber(level) or not csslist[tonumber(level)] then
return mError({[1] = '無法解釋章節等級' .. tostring(frame:extensionTag('syntaxhighlight', '<h' .. level .. '></h .. level .. >', {lang = 'html', inline = ''}))})
end
return getFakeH (level, text)
end
function p.main (frame)
local text = ''
local getArgs = require('Module:Arguments').getArgs
local configs = getArgs(frame, {
frameOnly = true
})
local args = getArgs(frame, {
removeBlanks = false,
valueFunc = (function (key, value)
if key == 1 then
return value
end
return nil
end),
frameOnly = true
})
if not args[1] then
text = '標題'
else
text = args[1]
end
return p._main (configs, text)
end
return p