Difference between revisions of "Module:Sandbox/Erutuon/random"
< Module:Sandbox | Erutuon
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 = {} | ||
| − | + | local count_scripts = require("Module:Language/scripts").countScripts | |
| − | |||
| − | |||
| − | |||
| − | function p. | + | function p.show(frame) |
| − | local | + | 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 | |
| − | function | + | end) |
| − | + | ||
| − | + | return frame:extensionTag{ | |
| − | + | name = "syntaxhighlight", | |
| − | + | content = content, | |
| − | + | } | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | end | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | return | ||
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