local data = {}
local U = mw.ustring.char
local anusvAra = U(0x902)
local visarga = U(0x903)
local virAma = U(0x94D)
local avagraha = "ऽ"
local consonants = "कखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसह"
local consonant = ""
local acute = U(0x301) -- combining acute
data = {
-- Vowels and modifiers. Do the diphthongs and diaereses first.
{"ai", "ऐ"},
{"au", "औ"},
{"ä", "अ"},
{"ö", "ओ"},
{"ï", "इ"},
{"ü", "उ"},
{"a", "अ"},
{"ā", "आ"},
{"i", "इ"},
{"ī", "ई"},
{"u", "उ"},
{"ū", "ऊ"},
{"e", "ए"},
{"o", "ओ"},
{"ṝ", "ॠ"},
{"ṛ", "ऋ"},
{"r̥", "ऋ"},
{"ḹ", "ॡ"},
{"l̥̄", "ॡ"},
{"ḷ", "ळ"},
{"(अ)()", "%1%2"}, -- a-i, a-u for अइ, अउ; must follow rules for "ai", "au"
-- Two-letter consonants must go before h.
{"kh", "ख"},
{"gh", "घ"},
{"ch", "छ"},
{"jh", "झ"},
{"ṭh", "ठ"},
{"ḍh", "ढ"},
{"th", "थ"},
{"dh", "ध"},
{"ph", "फ"},
{"bh", "भ"},
{"h", "ह"},
-- Other stops.
{"k", "क"},
{"g", "ग"},
{"c", "च"},
{"j", "ज"},
{"ṭ", "ट"},
{"ḍ", "ड"},
{"t", "त"},
{"d", "द"},
{"p", "प"},
{"b", "ब"},
-- Nasals.
{"ṅ", "ङ"},
{"ñ", "ञ"},
{"ṇ", "ण"},
{"n", "न"},
{"n", "न"},
{"m", "म"},
-- Remaining consonants.
{"y", "य"},
{"r", "र"},
{"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(0x947),
= U(0x94B),
= U(0x93E),
= U(0x940),
= U(0x942),
= U(0x948),
= U(0x94C),
}
-- Convert independent vowels to diacritics after consonants. Must go after all consonant conversions.
for independentForm, diacriticalForm in pairs(vowels) do
table.insert(data, {"(" .. consonant .. ")" .. independentForm, "%1" .. diacriticalForm})
end
-- This must go last, after independent vowels are converted to diacritics, or "aï", "aü" won't work.
table.insert(data, {"(" .. consonant .. ")अ", "%1"})
-- ] to ]
data = {
= {
= "ā",
= "ī",
= "ū",
= "ñ",
= "ṭ",
= "ḍ",
= "ṇ",
= "ṅ",
= "ś",
= "ṣ",
= "ṃ",
= "ḷ",
= "ḥ",
= "ḹ",
= acute,
},
= {
= "ṝ",
},
= {
= "ṛ",
},
}
return data