Module:script utilities: Verskil tussen weergawes
Content deleted Content added
Nuwe bladsy geskep met 'local export = {} local m_data = mw.loadData("Module:script utilities/data") --[=[ Other modules used: Module:scripts Module:languages Module:parameters...' |
No edit summary |
||
Lyn 1:
local export = {}
local m_data = mw.loadData("Module:script utilities/data")▼
--[=[
[[Module:script utilities/data]]
[[Module:scripts]]
[[Module:languages]]
Lyn 12:
function export.is_Latin_script(sc)
-- Latn, Latf, Latinx, nv-Latn, pjt-Latn
return
end
Line 41 ⟶ 42:
end
-- Ustring turns on the codepoint-aware string matching. The basic string function
local function trackChar(text, character, tracking)▼
-- should be used for simple sequences of characters, Ustring function for
if character and mw.ustring.find(text, character) then▼
-- sets – [].
local find = ustring and mw.ustring.find or string.find
require("Module:debug").track("script/" .. tracking)
end
Line 51 ⟶ 56:
if lang and text then
local langCode = lang:getCode()
-- [[Special:WhatLinksHere/Template:tracking/script/ang/acute]]
if
local decomposed = mw.ustring.toNFD(text)
local acute = U(0x301)
end▼
--[=[
Line 66 ⟶ 72:
ϑ, ϰ, ϱ, ϕ should generally be replaced with θ, κ, ρ, φ.
]=]
end▼
--[=[
[[Special:WhatLinksHere/Template:tracking/script/Ancient Greek/spacing-coronis]]
[[Special:WhatLinksHere/Template:tracking/script/Ancient Greek/spacing-smooth-breathing]]
[[Special:WhatLinksHere/Template:tracking/script/Ancient Greek/wrong-apostrophe]]
When spacing coronis and spacing smooth breathing are used as apostrophes,
they should be replaced with right single quotation marks (’).
]=]
if
end
-- [[Special:WhatLinksHere/Template:tracking/script/Russian/grave-accent]]
local decomposed = mw.ustring.toNFD(text)
local grave = U(0x300)▼
end▼
-- [[Special:WhatLinksHere/Template:tracking/script/Tibetan/trailing-punctuation]]
end▼
--[=[
Line 105 ⟶ 107:
[[Special:WhatLinksHere/Template:tracking/script/Thai/wrong-rue-lue]]
]=]
end▼
--[=[
Line 115 ⟶ 116:
[[Special:WhatLinksHere/Template:tracking/script/Lao/broken-am]]
]=]
end
end
Line 136 ⟶ 137:
replaced with line breaks. ]]
local escaped = {}
local escape_format = "$%d"
local
return text:gsub(
pattern,
escaped[i] = link_target▼
function(item)
i = i + 1
return (prefix or "") .. escape_format:format(i)
▲ end)
end
text = escape(text, "<[^>]+>")
text =
▲ )
-- Unescape whatever was escaped.
text =
"$(%d)",
function(a)
Line 199 ⟶ 197:
end
local data =
if sc:getDirection() == "rtl" then▼
local post = ""
if
post = "‎"
end
Line 218 ⟶ 212:
end
function export.tag_translit(translit, lang, kind, attributes, is_manual)
if type(lang) == "table" then
lang = lang.getCode and lang:getCode()
Line 224 ⟶ 218:
end
local data =
local opening_tag = {}
Line 230 ⟶ 224:
table.insert(opening_tag, data.tag)
if lang == "ja" then
table.insert(opening_tag, 'class="' .. (data.classes and data.classes .. " " or "") .. (is_manual and "manual-tr " or "") .. 'tr"')
else
table.insert(opening_tag, 'lang="' .. lang .. '-Latn"')
table.insert(opening_tag, 'class="' .. (data.classes and data.classes .. " " or "") .. (is_manual and "manual-tr " or "") .. 'tr Latn"')
end
Line 243 ⟶ 237:
return "<" .. table.concat(opening_tag, " ") .. ">" .. translit .. "</" .. data.tag .. ">"
function export.tag_transcription(transcription, lang, kind, attributes)
if type(lang) == "table" then
lang = lang.getCode and lang:getCode()
or error("Third argument to tag_translit should be a language code or language object.")
local opening_tag = {}
table.insert(opening_tag, data.tag)
table.insert(opening_tag, 'class="' .. (data.classes and data.classes .. " " or "") .. 'ts"')
else
table.insert(opening_tag, 'lang="' .. lang .. '-Latn"')
table.insert(opening_tag, 'class="' .. (data.classes and data.classes .. " " or "") .. 'ts Latn"')
if data.dir then
table.insert(opening_tag, 'dir="' .. data.dir .. '"')
table.insert(opening_tag, attributes)
return "<" .. table.concat(opening_tag, " ") .. ">" .. transcription .. "</" .. data.tag .. ">"
end
|