Module:Text: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
imported>Sukanthi "local yesNo = require("Module:Yesno") local Text = { serial = "2022-07-21", suite = "Text" } --[=[ Text utilities ]=] -- local globals local PatternCJK = false local PatternCombined = false local PatternLatin = false local PatternTerminated = false local QuoteLang = false local QuoteType = false local RangesLatin..."-இப்பெயரில் புதிய பக்கம் உருவாக்கப்பட்டுள்ளது |
imported>Ravidreams சி en:Module:Text இலிருந்து திருத்தம் இறக்குமதி செய்யப்பட்டன |
||
| (2 பயனர்களால் செய்யப்பட்ட 2 இடைப்பட்ட திருத்தங்கள் காட்டப்படவில்லை.) | |||
வரிசை 5:
Text utilities
]=]
local function fiatQuote( apply, alien, advance )
வரி 127 ⟶ 16:
advance = tonumber(advance) or 0
local suite
local data = mw.loadData('Module:Text/data')
local QuoteLang = data.QuoteLang
local QuoteType = data.QuoteType
local slang = alien:match( "^(%l+)-" )
suite = QuoteLang[alien] or slang and QuoteLang[slang] or QuoteLang["en"]
வரி 230 ⟶ 121:
-- Returns: true, if CJK detected
s = s and tostring(s) or ""
return mw.ustring.find( s, patternCJK ) ~= nil
end -- Text.containsCJK()
வரி 294 ⟶ 174:
-- Returns: true, if valid for latin only
s = s and tostring(s) or "" --- ensure input is always string
local PatternLatin = mw.loadData('Module:Text/data').PatternLatin
return mw.ustring.match(s, PatternLatin) ~= nil
end -- Text.isLatinRange()
வரி 309 ⟶ 189:
return false
end
return mw.ustring.find( SeekQuote, s, 1, true ) ~= nil
end -- Text.isQuote()
வரி 398 ⟶ 261:
-- or basic greek or cyrillic or symbols etc.
local cleanup, decomposed
decomposed = mw.ustring.toNFD( adjust and tostring(adjust) or "" )
cleanup = mw.ustring.gsub( decomposed, PatternCombined, "" )
வரி 420 ⟶ 276:
-- Returns: true, if sentence terminated
local r
if mw.ustring.find( analyse, PatternTerminated ) then
r = true
வரி 476 ⟶ 325:
-- Returns: string with non-latin parts enclosed in <span>
local r
local data = mw.loadData('Module:Text/data')
local PatternLatin = data.PatternLatin
local RangesLatin = data.RangesLatin
local NumLatinRanges = data.NumLatinRanges
if mw.ustring.match( adjust, PatternLatin ) then
-- latin only, horizontal dashes, quotes
வரி 490 ⟶ 342:
-- isLatin
local range
for i = 1, NumLatinRanges do
range = RangesLatin[ i ]
if a >= range[ 1 ] and a <= range[ 2 ] then
வரி 569 ⟶ 422:
local r
if about == "quote" then
r = { }
r.QuoteLang = data.QuoteLang
r.QuoteType = data.QuoteType
end
return r
end -- Text.test()
-- Non Unicode-aware version of mw.text.split and mw.text.gsplit
-- based on [[phab:diffusion/ELUA/browse/master/includes/Engines/LuaCommon/lualib/mw.text.lua]]
-- These run up to 60 times faster than the Unicode-aware versions
Text.split = function ( text, pattern, plain )
local ret = {}
for m in Text.gsplit( text, pattern, plain ) do
ret[#ret+1] = m
end
return ret
end
Text.gsplit = function ( text, pattern, plain )
local s, l = 1, string.len( text )
return function ()
if s then
local e, n = string.find( text, pattern, s, plain )
local ret
if not e then
ret = string.sub( text, s )
s = nil
elseif n < e then
-- Empty separator!
ret = string.sub( text, s, e )
if e < l then
s = e + 1
else
s = nil
end
else
ret = e > s and string.sub( text, s, e - 1 ) or ''
s = n + 1
end
return ret
end
end, nil, nil
end
-- Export
வரி 756 ⟶ 644:
end
function p.split(frame)
local text = frame.args.text or frame.args[1] or ''
local pattern = frame.args.pattern or frame.args[2] or ''
local plain = yesNo(frame.args.plain or frame.args[3])
local index = tonumber(frame.args.index) or tonumber(frame.args[4]) or 1
local a = Text.split(text, pattern, plain)
if index < 0 then index = #a + index + 1 end
return a[index]
end
வரி 761 ⟶ 659:
return Text.serial
end
| |||