local p = local yn = require("Module:Yesno")local pv = require("Module:If preview")local pvWarning = pv._warning--Formats the word count, etc. while showing/hiding the count--
function p._main(str, limit) local strout = "" limit = limit or math.huge local count = 0 local phrases = mw.text.split(str, "%s") local separators = for match in mw.ustring.gmatch(str, "%s") do table.insert(separators, match) end for k,v in pairs(phrases) do if (count < limit) then strout = strout .. v .. (separators[k] ~= nil and separators[k] or "") end if v ~= "" then count = count + 1 end end return end
function p.main(frame) local args = require("Module:Arguments").getArgs(frame) local str = args[1] or local limit = tonumber(args['limit']) or tonumber(args[2]) or math.huge local result = p._main(str, limit) mw.logObject(result) local out = if (yn(args['showcount'] or false) and not mw.isSubsting) or frame:preprocess('')
math.huge then out = out .. 'Word count: ' .. result['count'] .. '
' elseif 0 <= result['count'] and result['count'] < limit / 2 then out = out .. 'Word count:
return p