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

From blackwiki
Jump to navigation Jump to search
blackwiki>Erutuon
(function to clean up recent revision of Help:IPA/Ukrainian)
blackwiki>Erutuon
(forgot IPA link for symbols)
Line 14: Line 14:
 
return whole_match:gsub("/[^/]+/", "{{IPA|%0}}")
 
return whole_match:gsub("/[^/]+/", "{{IPA|%0}}")
 
end
 
end
 +
 +
if cell_content:find("<big>") then
 +
return whole_match:gsub("<big>([^<]+)</big>", "<big>{{IPA link|%1}}</big>")
 +
end
 +
 
local scripts = count_scripts(cell_content)
 
local scripts = count_scripts(cell_content)
 
if scripts.Cyrl and not scripts.Latn then
 
if scripts.Cyrl and not scripts.Latn then

Revision as of 02:41, 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
			
			if cell_content:find("<big>") then
				return whole_match:gsub("<big>([^<]+)</big>", "<big>{{IPA link|%1}}</big>")
			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