local data = {}
local U = require("Module:string/char")
local anusvAra = U(0x902)
local visarga = U(0x903)
local virAma = U(0x94D)
local avagraha = "ऽ"
local consonants = "कखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसह"
local consonant = ""
local Lconsonants = "kgṅcjñṭḍṇtdnpbmyrlvśṣs" -- excludes h and ḷ
local Lcons1 = ""
local Lcons2 = ""
local Lvowels = "āeĕēiïīoŏōuŭuṛṝl̥̄l̥ḹ" -- excludes a
local Lvowel1 = ""
local Lvowel2 = ""
local accents = U(0x301, 0x306, 0x308) -- combining acute, breve and diaeresis
local accent = ""
local acute = U(0x301) -- combining acute
data = {
-- Resolve ḷ where possible
{"("..Lcons1..")(ḷ)", "%1l̥"}, -- It's a vowel next to a consonant
{"(ḷ)("..Lcons2..")", "l̥%2"},
{"("..Lvowel1..accent.."?)(ḷ)", "%1L"}, -- It's a consonant next to a vowel.
{"(ḷ)(h?"..Lvowel2..")", "L%2"},
-- Vowels and modifiers. Do the diphthongs and diaereses first.
{"ai", "ऐ"},
{"au", "औ"},
{".", { = "अ", = "ओ", = "इ", = "उ",
= "अ", = "आ", = "इ", = "ई",
= "उ", = "ऊ", = "ए", = "ओ",
= "ॠ", = "ऋ", = "ॡ", = "ऌ", }},
{"r̥", "ऋ"},
{"l̥", "ऌ"},
{"l̥̄", "ॡ"},
{"(अ)()", "%1%2"}, -- a-i, a-u for अइ, अउ; must follow rules for "ai", "au"
-- Two-letter consonants must go before h.
{".h", { = "ख", = "घ", = "छ", = "झ",
= "ठ", = "ढ", = "थ", = "ध",
= "फ", = "भ", }},
-- Other letters
{".", {h = "ह",
-- Other stops.
k = "क", g = "ग", c = "च", j = "ज",
= "ट", = "ड", t = "त", d = "द",
p = "प", b = "ब",
-- Nasals.
= "ङ", = "ञ", = "ण", = "न",
n = "न", m = "म",
-- Remaining consonants.
y = "य", r = "र", l = "ल", L = "ळ",
v = "व", = "श", = "ष", s = "स",
= "य़", = anusvAra, = visarga,
= avagraha,
}},
-- This rule must be applied twice because a consonant may only be in one capture per operation,
-- so "CCC" will only recognize the first two consonants. Must follow all consonant conversions.
{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
{"(" .. consonant .. ")(" .. consonant .. ")", "%1" .. virAma .. "%2"},
{"(" .. consonant .. ")$", "%1" .. virAma},
{acute, ""},
}
local vowels = {
= U(0x93F),
= U(0x941),
= U(0x943),
= U(0x962),
= U(0x947),
= U(0x94B),
= U(0x93E),
= U(0x940),
= U(0x942),
= U(0x944),
= U(0x963),
= U(0x948),
= U(0x94C),
}
-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions.
local independentForms = {}
for independentForm in pairs(vowels) do
-- assert(mw.ustring.len(independentForm) == 1)
table.insert(independentForms, independentForm)
end
table.insert(data, {"%f()", vowels})
-- This must go last, after independent vowels are converted to diacritics, or "aï", "aü" won't work.
table.insert(data, {"(" .. consonant .. ")अ", "%1"})
-- ] to ]
data = {
= {
= "ā",
= "e",
= "ī",
= "ū",
= "o",
= "ñ",
= "ṭ",
= "ḍ",
= "ṇ",
= "ṅ",
= "ś",
= "ṣ",
= "ṃ",
= "ḥ",
= "ḹ",
= acute,
},
= {
= "l̥", -- was "ḷ",
= "ṝ",
},
= {
= "ṛ",
},
}
return data