卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁文本”︁的源代码
←
模块:文本
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} function p.main(frame) local args = {} local text = "" -- 收集所有参数 for i = 1, 9 do if frame.args[i] and frame.args[i] ~= "" then args[i] = frame.args[i] end end -- 最后一个非空参数是文本内容 local textIndex = 0 for i = 1, 9 do if args[i] then textIndex = i end end if textIndex == 0 then return "错误:未提供文本内容" end text = args[textIndex] -- CSS样式 local styles = {} local classes = {} -- 处理样式参数 for i = 1, textIndex - 1 do if args[i] then local style = args[i] local styleLower = string.lower(style) -- 检查背景颜色设置(优先处理) if string.match(style, "^背景颜色=(.+)$") then local bgColor = string.match(style, "^背景颜色=(.+)$") local bgColorLower = string.lower(bgColor) -- 如果是十六进制颜色 if string.match(bgColor, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$") or string.match(bgColor, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$") then table.insert(styles, "background-color: " .. bgColor) -- 如果是颜色名称 elseif bgColorLower == "红" or bgColorLower == "red" then table.insert(styles, "background-color: #FF0000") elseif bgColorLower == "蓝" or bgColorLower == "blue" then table.insert(styles, "background-color: #0000FF") elseif bgColorLower == "绿" or bgColorLower == "green" then table.insert(styles, "background-color: #008000") elseif bgColorLower == "黄" or bgColorLower == "yellow" then table.insert(styles, "background-color: #FFD700") elseif bgColorLower == "紫" or bgColorLower == "purple" then table.insert(styles, "background-color: #800080") elseif bgColorLower == "橙" or bgColorLower == "orange" then table.insert(styles, "background-color: #FFA500") elseif bgColorLower == "黑" or bgColorLower == "black" then table.insert(styles, "background-color: #000000") elseif bgColorLower == "白" or bgColorLower == "white" then table.insert(styles, "background-color: #FFFFFF") elseif bgColorLower == "灰" or bgColorLower == "gray" or bgColorLower == "grey" then table.insert(styles, "background-color: #808080") elseif bgColorLower == "粉" or bgColorLower == "pink" then table.insert(styles, "background-color: #FFC0CB") elseif bgColorLower == "青" or bgColorLower == "cyan" then table.insert(styles, "background-color: #00FFFF") else -- 如果不是预设颜色,直接使用原始值 table.insert(styles, "background-color: " .. bgColor) end -- 添加圆角和内边距 table.insert(styles, "padding: 2px 6px") table.insert(styles, "border-radius: 4px") -- 检查是否为十六进制颜色代码 elseif string.match(style, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$") or string.match(style, "^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$") then table.insert(styles, "color: " .. style) -- 检查是否为像素大小 elseif string.match(style, "^%d+px$") then table.insert(styles, "font-size: " .. style) -- 预设颜色 elseif styleLower == "红" or styleLower == "red" then table.insert(styles, "color: #FF0000") elseif styleLower == "蓝" or styleLower == "blue" then table.insert(styles, "color: #0000FF") elseif styleLower == "绿" or styleLower == "green" then table.insert(styles, "color: #008000") elseif styleLower == "黄" or styleLower == "yellow" then table.insert(styles, "color: #FFD700") elseif styleLower == "紫" or styleLower == "purple" then table.insert(styles, "color: #800080") elseif styleLower == "橙" or styleLower == "orange" then table.insert(styles, "color: #FFA500") elseif styleLower == "黑" or styleLower == "black" then table.insert(styles, "color: #000000") elseif styleLower == "白" or styleLower == "white" then table.insert(styles, "color: #FFFFFF") elseif styleLower == "灰" or styleLower == "gray" or styleLower == "grey" then table.insert(styles, "color: #808080") elseif styleLower == "粉" or styleLower == "pink" then table.insert(styles, "color: #FFC0CB") elseif styleLower == "青" or styleLower == "cyan" then table.insert(styles, "color: #00FFFF") -- 文本装饰 elseif styleLower == "下划线" then table.insert(styles, "text-decoration: underline") elseif styleLower == "加粗" or styleLower == "粗体" then table.insert(styles, "font-weight: bold") elseif styleLower == "划掉" or styleLower == "删除线" then table.insert(styles, "text-decoration: line-through") -- 预设字体大小 elseif styleLower == "大" then table.insert(styles, "font-size: 1.2em") elseif styleLower == "小" then table.insert(styles, "font-size: 0.8em") elseif styleLower == "特大" then table.insert(styles, "font-size: 1.5em") elseif styleLower == "特小" then table.insert(styles, "font-size: 0.6em") end end end -- 生成HTML local styleStr = "" if #styles > 0 then styleStr = ' style="' .. table.concat(styles, "; ") .. '"' end return '<span' .. styleStr .. '>' .. mw.text.encode(text) .. '</span>' end return p
该页面使用的模板:
模块:文本/doc
(
查看源代码
)
返回
模块:文本
。