Mòdul:Jmarchn/Proves
Aparença
![Icona de documentació de mòdul](http://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Test_Template_Info-Icon.svg/50px-Test_Template_Info-Icon.svg.png)
A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]
Proves d'Usuari:Jmarchn a {{Usuari:Jmarchn/proves}}
local p = {}
local CFCM = require "Module:ComplForColorModules"
local SD = require "Module:SimpleDebug"
function p.Alguna(frame)
h = 3
local function Fes (h)
return h
end
return Fes (4)
end
function trim1(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function p.CountChars(s)
local n = 0
s = trim1 (s)
s = string.lower(s)
ToDo = true
while (ToDo) do
local Pos = string.find (s, '--ref')
if Pos then
local ss = string.sub (s,1, Pos-8)
s = ss..string.sub (s, Pos+23)
n = n + 0.6
else
ToDo = false
end
end
if string.find (s, '--nowiki') or string.find (s, '{{') then
return -1
end
local slen = string.len(s)
local IsIntrawiki = false
local IsWeb = false
local IsWebTitle = false
local IsBold = false
local IsSubSupSmall = false
local IsBig = false
local IsCode = false
local niw = 0
local i = 1
local Char = ''
while (i <= slen) do
Char = string.sub (s,i,i)
if Char == '[' then
if (i < slen) and (string.sub (s,i+1,i+1) == '[') then
IsIntrawiki = true
i = i + 2
else
IsWeb = true
i = i + 1
end
elseif Char == ']' then
if (i < slen) and (string.sub (s,i+1,i+1) == ']') then
IsIntrawiki = false
n = n + niw
niw = 0
i = i + 2
elseif IsWebTitle then
IsWebTitle = false
n = n + niw
niw = 0
i = i + 1
end
elseif Char == "'" then
if ((i+1) < slen) and (string.sub (s,i+1,i+2) == "''") then --IsBold
i = i + 3
elseif (i < slen) and (string.sub (s,i+1,i+1) == "'") then --Cursive
i = i + 2
else
n = n + 0.5
i = i + 1
end
elseif Char == "<" then
function WhenIsSubSupSmall (N)
IsSubSupSmall = true
i = i + N
niw = 0
end
function WhenNoIsSubSupSmall (N)
IsSubSupSmall = false
i = i + N
n = n + (niw * 0.83)
end
local S5 = string.sub (s,i,i+4)
local S6 = string.sub (s,i,i+5)
local S7 = string.sub (s,i,i+6)
local S8 = string.sub (s,i,i+7)
if (S5 == '<sup>') or (S5 == '<sub>') then
WhenIsSubSupSmall (5)
elseif (S7 == '<small>') then
WhenIsSubSupSmall (7)
elseif (S5 == '<big>') then
IsBig = true
i = i + 5
niw = 0
elseif (S6 == '</sup>') or (S6 == '</sub>') then
WhenNoIsSubSupSmall (6)
elseif (S8 == '</small>') then
WhenNoIsSubSupSmall (8)
elseif (S6 == '</big>') then
IsBig = false
i = i + 6
n = n + (niw * 1.19)
elseif (S6 == '<code>') then
IsCode = true
i = i + 6
niw = 1 --not is an error
elseif (S7 == '</code>') then
IsCode = false
i = i + 7
n = n + (niw * 1.07)
else
i = i + 1
end
else
if IsIntrawiki then
if Char == '|' then
niw = 0
else
niw = niw + 1
end
elseif IsWeb then
if Char == ' ' then
IsWeb = false
IsWebTitle = true
end
elseif string.find (",.;:!",Char) then
n = n + 0.5
elseif IsSubSupSmall or IsBig or IsCode then
niw = niw + 1
else
n = n + 1
end
i = i + 1
end
end
return n
end --CountChars
function countSubstring(s1, s2)
return select(2, s1:gsub(s2, ""))
end
function LinPerCol(NLines, NCols)
local Nums = {}
local LinesPerCol = math.floor(NLines/NCols)
local Rest = NLines%NCols
for i = 1, NCols do
table.insert (Nums, LinesPerCol)
end
if Rest ~= 0 then
for i = 1, Rest do
Nums[i] = Nums[i] + 1
end
end
return Nums
end
function tableClear (T)
for i = 1, #T do
T[i] = nil
end
end
return p