Module:Sandbox/Func/化学方程式
跳到导航
跳到搜索
local p = {} function trim(s) return (string.gsub(s,"^%s*(.-)%s*$","%1")); end -- 参考 模块:长标题 local function len(a) local rlt = 0; a=string.gsub(trim(a),"<.->","") a=string.gsub(trim(a),"\127'\"`UNIQ%-%-templatestyles%-%x+%-QINU`\"'\127","") for i = 1, mw.ustring.len(a) do local char = mw.ustring.sub(a, i, i); local charnum = mw.ustring.byte(char); if (charnum > 33 and charnum < 126) or char == '{' or char == '}' or char == ' ' then rlt = rlt + 0.5; elseif char == '\n' or char == '\t' then -- do nothing else rlt = rlt + 1; end end return rlt; end p['len'] = function(frame) local str = frame.args[1] return len(str) end return p