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

From blackwiki
Jump to navigation Jump to search
blackwiki>Erutuon
(forgot IPA link for symbols)
blackwiki>Erutuon
(several palatalized consonants aren't supported by Template:IPA link)
Line 16: Line 16:
 
 
 
if cell_content:find("<big>") then
 
if cell_content:find("<big>") then
return whole_match:gsub("<big>([^<]+)</big>", "<big>{{IPA link|%1}}</big>")
+
return whole_match:gsub("<big>([^<]+)</big>",
 +
function(symbol)
 +
local template
 +
if symbol:find("ʲ") then
 +
template = "IPA"
 +
else
 +
template = "IPA link"
 +
end
 +
return "<big>{{" .. template .. "|" .. symbol .. "}}</big>"
 +
end)
 
end
 
end
 
 

Revision as of 02:45, 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>",
					function(symbol)
						local template
						if symbol:find("ʲ") then
							template = "IPA"
						else
							template = "IPA link"
						end
						return "<big>{{" .. template .. "|" .. symbol .. "}}</big>"
					end)
			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