Difference between revisions of "Module:Sandbox/Erutuon/random"

From blackwiki
Jump to navigation Jump to search
blackwiki>Erutuon
(there)
blackwiki>Erutuon
(function to clean up recent revision of Help:IPA/Ukrainian)
Line 3: Line 3:
 
local p = {}
 
local p = {}
  
function p.test(frame)
+
local count_scripts = require("Module:Language/scripts").countScripts
local word = frame.args[1] == "print" and "Printing is allowed"
 
return word
 
end
 
  
function p.currentFrame(frame)
+
function p.show(frame)
local currentFrame = mw.getCurrentFrame(frame)
+
local content = mw.title.new("Help:IPA/Ukrainian"):getContent()
local frameTable = {}
+
for k, v in pairs(currentFrame) do
+
content = content:gsub("(\n| *([^\n]+))",
frameTable[k] = v
+
function(whole_match, cell_content)
end
+
whole_match = "\n| " .. cell_content
return frameTable and table.concat(frameTable, ", ") or "nil"
+
if cell_content:sub(1, 1) == "/" then -- IPA
end
+
return whole_match:gsub("/[^/]+/", "{{IPA|%0}}")
 
+
end
function p.namespace(frame)
+
local scripts = count_scripts(cell_content)
return frame:getParent():getTitle() .. " " .. mw.title.getCurrentTitle().nsText
+
if scripts.Cyrl and not scripts.Latn then
end
+
return whole_match:gsub("[^%s|,]+", "{{lang|uk|%0}}")
 
+
end
function p.parameterContent(frame)
+
end)
local parameter = frame.args[1]
+
return parameter == "" and "Parameter is empty." or parameter == nil and "Parameter is nil." or "Parameter contains <code>" .. parameter .. "</code>."
+
return frame:extensionTag{
end
+
name = "syntaxhighlight",
 
+
content = content,
function p.gmatch(frame)
+
}
local parameter = frame.args[1]
 
local array = {}
 
local n = 0
 
for number in string.gmatch(parameter, "%d+") do
 
n = n + 1
 
array[n] = number or "blah"
 
end
 
return n .. " " .. array[n] .. " " .. table.concat(array, ", ")
 
end
 
 
 
function p.args(frame)
 
local currentargs = mw.getCurrentFrame().args
 
local args = mw.getCurrentFrame():getParent().args[1] and mw.getCurrentFrame():getParent().args
 
local out = (args) and args[1]..args[2]..args[3]..": parentargs" or (currentargs[1] and currentargs[2] and currentargs[3]) and currentargs[1]..currentargs[2]..currentargs[3]..": args"
 
return out .. (args == nil and ". no parentargs" or "")
 
 
end
 
end
  
 
return p
 
return p

Revision as of 02:35, 27 November 2017

Test

  • Lua error at line 10: attempt to index local 'content' (a nil value).



require("Module:No globals")

local p = {}

local count_scripts = require("Module:Language/scripts").countScripts

function p.show(frame)
	local content = mw.title.new("Help:IPA/Ukrainian"):getContent()
	
	content = content:gsub("(\n| *([^\n]+))",
		function(whole_match, cell_content)
			whole_match = "\n| " .. cell_content
			if cell_content:sub(1, 1) == "/" then -- IPA
				return whole_match:gsub("/[^/]+/", "{{IPA|%0}}")
			end
			local scripts = count_scripts(cell_content)
			if scripts.Cyrl and not scripts.Latn then
				return whole_match:gsub("[^%s|,]+", "{{lang|uk|%0}}")
			end
		end)
	
	return frame:extensionTag{
		name = "syntaxhighlight",
		content = content,
	}
end

return p