local p = {}  -- Load data local data_page = "Data:Quran.tab" local data = mw.ext.data.get(data_page)  -- Surah name to number map (Bengali) local surah_map = { 	["আল-ফাতিহা"] = "1", ["আল-বাকারা"] = "2", ["আল-ইমরান"] = "3", 	["আন-নিসা"] = "4", ["আল-মায়িদা"] = "5", ["আল-আনআম"] = "6", 	["আল-আরাফ"] = "7", ["আল-আনফাল"] = "8", ["আত-তাওবা"] = "9", 	["ইউনুস"] = "10", ["হুদ"] = "11", ["ইউসুফ"] = "12", 	["আর-রাদ"] = "13", ["ইব্রাহিম"] = "14", ["আল-হিজর"] = "15", 	["আন-নাহল"] = "16", ["বনী ইসরাইল"] = "17", ["আল-কাহফ"] = "18", 	["মরইয়াম"] = "19", ["ত্বা-হা"] = "20", ["আল-আম্বিয়া"] = "21", 	["আল-হাজ্জ"] = "22", ["আল-মুমিনূন"] = "23", ["আন-নূর"] = "24", 	["আল-ফুরকান"] = "25", ["আশ-শুয়ারা"] = "26", ["আন-নামল"] = "27", 	["আল-কাসাস"] = "28", ["আল-আনকাবুত"] = "29", ["আর-রূম"] = "30", 	["লোকমান"] = "31", ["আস-সাজদা"] = "32", ["আল-আহযাব"] = "33", 	["সাবা"] = "34", ["ফাতির"] = "35", ["ইয়া-সিন"] = "36", 	["আস-সাফফাত"] = "37", ["সাদ"] = "38", ["আয-যুমার"] = "39", 	["গাফির"] = "40", ["ফুসসিলাত"] = "41", ["আশ-শুরা"] = "42", 	["আয-যুখরুফ"] = "43", ["আদ-দোখান"] = "44", ["আল-জাসিয়া"] = "45", 	["আল-আহকাফ"] = "46", ["মুহাম্মদ"] = "47", ["আল-ফাতহ"] = "48", 	["আল-হুজরাত"] = "49", ["কাফ"] = "50", ["আয-যারিয়াত"] = "51", 	["আত-তূর"] = "52", ["আন-নাজম"] = "53", ["আল-কামার"] = "54", 	["আর-রাহমান"] = "55", ["আল-ওয়াকিয়া"] = "56", ["আল-হাদিদ"] = "57", 	["আল-মুজাদিলা"] = "58", ["আল-হাশর"] = "59", ["আল-মুমতাহিনা"] = "60", 	["আস-সাফ"] = "61", ["আল-জুমুয়া"] = "62", ["আল-মুনাফিকুন"] = "63", 	["আত-তাগাবুন"] = "64", ["আত-তালাক"] = "65", ["আত-তাহরিম"] = "66", 	["আল-মুলক"] = "67", ["আল-কলম"] = "68", ["আল-হাক্কাহ"] = "69", 	["আল-মারিজ"] = "70", ["নুহ"] = "71", ["আল-জিন"] = "72", 	["আল-মুযাম্মিল"] = "73", ["আল-মুদ্দাসসির"] = "74", ["আল-কিয়ামাহ"] = "75", 	["আল-ইনসান"] = "76", ["আল-মুরসালাত"] = "77", ["আন-নাবা"] = "78", 	["আন-নাজিয়াত"] = "79", ["আবাসা"] = "80", ["আত-তাকভীর"] = "81", 	["আল-ইনফিতার"] = "82", ["আত-তাতফিফ"] = "83", ["আল-ইনশিকাক"] = "84", 	["আল-বরূজ"] = "85", ["আত-তারিক"] = "86", ["আল-আ'লা"] = "87", 	["আল-গাশিয়া"] = "88", ["আল-ফজর"] = "89", ["আল-বালাদ"] = "90", 	["আশ-শামস"] = "91", ["আল-লাইল"] = "92", ["আদ-দুহা"] = "93", 	["আল-ইনশিরাহ"] = "94", ["আত-তিন"] = "95", ["আল-আলাক"] = "96", 	["আল-কদর"] = "97", ["আল-বাইয়্যিনা"] = "98", ["আয-যিলজাল"] = "99", 	["আল-আদিয়াত"] = "100", ["আল-কারিয়া"] = "101", ["আত-তাকাসুর"] = "102", 	["আল-আসর"] = "103", ["আল-হুমাযা"] = "104", ["আল-ফিল"] = "105", 	["কুরাইশ"] = "106", ["আল-মাউন"] = "107", ["আল-কাওসার"] = "108", 	["আল-কাফিরুন"] = "109", ["আন-নাসর"] = "110", ["আল-মাসাদ"] = "111", 	["আল-ইখলাস"] = "112", ["আল-ফালাক"] = "113", ["আন-নাস"] = "114" }  -- Utilities local function getColumnIndexes(source_col, output_col) 	local src_idx, out_idx 	for i, field in ipairs(data.schema.fields) do 		if field.name == source_col then src_idx = i end 		if field.name == output_col then out_idx = i end 	end 	return src_idx, out_idx end  local function fetchAyah(key) 	local src_col = "sura_ayah" 	local out_col = "text" 	local src_idx, out_idx = getColumnIndexes(src_col, out_col) 	if not (src_idx and out_idx) then return nil end  	for _, row in ipairs(data.data) do 		if row[src_idx] == key then 			return row[out_idx] 		end 	end end  -- Normalize input local function normalizeInput(input) 	local cleaned = mw.ustring.gsub(input, "[%s%-–—‐]+", "") 	local name, ayah_part = cleaned:match("^([^:]+):?(.*)$") 	local surah_num = surah_map[name] 	if not surah_num then return nil end 	if ayah_part == "" then return surah_num end 	return surah_num .. ":" .. ayah_part end  -- List all Surahs local function listSurahs() 	local result = {} 	for name, num in pairs(surah_map) do 		table.insert(result, num .. ". " .. name) 	end 	table.sort(result) 	return "📖 সমর্থিত সূরা তালিকা:\n" .. table.concat(result, "") end  -- Handle ayah local function handleSingle(key) 	local text = fetchAyah(key) 	return text and ("" .. text .. " (" .. key .. ")") or "আয়াত পাওয়া যায়নি: " .. key end  local function handleRange(sura, from_, to_) 	local result = {} 	for i = from_, to_ do 		local key = sura .. ":" .. i 		table.insert(result, handleSingle(key )) end return table.concat(result, "") end  -- Main entry point function p.main(frame) local raw = mw.text.trim(frame.args[1] or "") local format = frame.args["format"] or "html" if raw == "" then return "কোনো ইনপুট দেওয়া হয়নি। /help বা /list ব্যবহার করুন।" end if raw == "/list" then 	return listSurahs() elseif raw == "/help" then 	return "ব্যবহার নির্দেশিকা:\n1. `সূরা:আয়াত` উদাহরণ: `১:১`\n2. `সূরা:আয়াত-আয়াত` উদাহরণ: `১:১-৫`" end  local input = normalizeInput(raw) if not input then 	return "সঠিক সূরা বা আয়াত ফরম্যাট নয়। /help দেখুন।" end  local sura, range = input:match("^(%d+):?(%d+%-%d*)$") if not sura then return "ইনপুট সঠিক নয়।" end  if range and range:match("%d+%-%d+") then 	local start_ayah, end_ayah = range:match("(%d+)%-(%d+)") 	return handleRange(sura, tonumber(start_ayah), tonumber(end_ayah)) else 	return handleSingle(input) end