Module:zh-pron/sandbox

Hello, you have come here looking for the meaning of the word Module:zh-pron/sandbox. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:zh-pron/sandbox, but we will also tell you about its etymology, its characteristics and you will know how to say Module:zh-pron/sandbox in singular and plural. Everything you need to know about the word Module:zh-pron/sandbox you have here. The definition of the word Module:zh-pron/sandbox will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:zh-pron/sandbox, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.



local export = {}

local m_str_utils = require("Module:string utilities")

local codepoint = m_str_utils.codepoint
local find = m_str_utils.find
local gsub = m_str_utils.gsub
local len = m_str_utils.len
local match = m_str_utils.match
local rsplit = m_str_utils.split
local rgsplit = m_str_utils.gsplit

local hanzi = ""
local bopomofo = ""

local langname = {
	 = "Eastern Min",
	 = "Jin",
	 = "Mandarin",
	 = "Southern Pinghua",
	 = "Dungan",
	 = "Gan",
	 = "Hakka",
	 = "Xiang",
	 = "Xiang",
	 = "Xiang",
	 = "Northern Min",
	 = "Hokkien",
	 = "Leizhou Min",
	 = "Teochew",
	 = "Wu",
	 = "Wu",
	 = "Cantonese",
	 = "Sichuanese",
	 = "Taishanese",
}

local langname_abbr = {
	 = "Mandarin",
	 = "Sichuanese",
	 = "Mandarin",
	 = "Mandarin",
	 = "Dungan",
	 = "Cantonese",
	 = "Cantonese",
	 = "Cantonese",
	 = "Taishanese",
	 = "Cantonese",
	 = "Cantonese",
	 = "Cantonese",
	 = "Gan",
	 = "Hakka",
	 = "Jin",
	 = "Northern Min",
	 = "Eastern Min",
	 = "Hokkien",
	 = "Teochew",
	 = "Leizhou Min",
	 = "Southern Pinghua",
	 = "Wu",
	 = "Wu",
	 = "Xiang",
	 = "Loudi Xiang",
	 = "Hengyang Xiang",
}

local pos_aliases_cat = {
	 = "nouns",  = "nouns",
	 = "proper nouns",  = "proper nouns",  = "proper nouns",  = "proper nouns",
	 = "pronouns",  = "pronouns",
	 = "verbs",  = "verbs",
	 = "adjectives",  = "adjectives",  = "adjectives",
	 = "adverbs",  = "adverbs",
	 = "prepositions",  = "prepositions",
	 = "postpositions",  = "postpositions",
	 = "conjunctions",  = "conjunctions",  = "conjunctions",
	 = "particles",  = "particles",
	 = "prefixes",  = "prefixes",
	 = "suffixes",  = "suffixes",
	 = "infixes",
	 = "proverbs",  = "proverbs",
	 = "idioms",  = "idioms",
	 = "four-character idioms",  = "four-character idioms",  = "four-character idioms",
	 = "four-character idioms",
	 = "phrases",  = "phrases",
	 =  "interjections",  = "interjections",  = "interjections",  = "interjections",
	 = "classifiers",  = "classifiers",  = "classifiers",
	 = "numerals",  = "numerals",
	 = "abbreviations",  = "abbreviations",
	 = "determiners",  = "determiners",  = "determiners",
	 = "syllables",  = "syllables",
}

local function make_note(text)
	if find(text, ": ") then
		text = "\n*" .. gsub(gsub(text, "\n", ".\n*"), "() ", "%1\n**")
	elseif find(text, "; ") then
		text = "\n*" .. gsub(text, "; ", ";\n*")
	end
	text = gsub(text, "“(+)”", function (a) return "“" .. gsub(a, ";\n%*+", "; ") .. "”" end)
	-- fix bug about indentation levels (see https://en.wiktionary.orghttps://en.wiktionary.org/w/index.php?oldid=78848651)
	local last_level = ("\n"..text):match("\n(%**)*$")
	local append = last_level:gsub("%*","<ul>")
	return "\n<div style=\"border: 1px solid green; padding: 4px; margin: 8px; background: #F7F4ED; font-size: 85%\">'''Note''': " .. text .. ".</div>" .. append
end

local function ipa_format(text)
	local numbers = { ="¹",="²",="³",="⁴",="⁵",="⁰",="⁻",="/, /" }
	return gsub(text,"",numbers)
end

local function Consolas(text)
	return '<span style="font-family: Consolas, monospace;">' .. text .. "</span>"
end

local function format_IPA(text)
	return '<span class="IPA">' .. text .. "</span>"
end

function export.make(frame)
	local parent_args = frame:getParent().args
	local params = {
		pagename = {},
		namespace = {},
		dial = {},
		mc = {},
		oc = {},
		cat = {},
		only_cat = {type = "boolean"},
		no_foreign_script_cat = {type = "boolean"},
	}
	for abbr, _ in pairs(langname_abbr) do
		params = {}
		params = {list = true}
		params = {}
	end
	local args = require("Module:parameters").process(parent_args, params, nil, "zh-pron", "make")

	local title = mw.title.getCurrentTitle()
	local pagename = args.pagename or title.text
	local sortkey = (require("Module:Hani-sortkey").makeSortKey(pagename))
	local is_single_hanzi = find(pagename, "^" .. hanzi .. "$") ~= nil
	local namespace = args.namespace or title.nsText
	local m_rom = args
	local m_s_rom = args
	local m_x_rom = args
	local m_nj_rom = args
	local dg_rom = args
	local c_rom = args
	local c_dg_rom = args
	local c_nn_rom = args
	local c_t_rom = args
	local c_kp_rom = args
	local c_yj_rom = args
	local c_yl_rom = args
	local g_rom = args
	local h_rom = args
	local j_rom = args
	local mb_rom = args
	local md_rom = args
	local mn_rom = args
	local mn_l_rom = args
	local mn_t_rom = args
	local sp_rom = args
	local w_rom = args
	local w_j_rom = args
	local x_rom = args
	local x_l_rom = args
	local x_h_rom = args
	local m_audio = args
	local m_s_audio = args
	local m_x_audio = args
	local m_nj_audio = args
	local dg_audio = args
	local c_audio = args
	local c_dg_audio = args
	local c_nn_audio = args
	local c_t_audio = args
	local c_kp_audio = args
	local c_yj_audio = args
	local c_yl_audio = args
	local g_audio = args
	local h_audio = args
	local j_audio = args
	local mb_audio = args
	local md_audio = args
	local mn_audio = args
	local mn_l_audio = args
	local mn_t_audio = args
	local sp_audio = args
	local w_audio = args
	local w_j_audio = args
	local x_audio = args
	local x_l_audio = args
	local x_h_audio = args
	local dial = args
	local mc = args
	local oc = args
	local only_cat = args

	-- True if arguments exist for the specified variety, using a language param abbreviation.
	local function has_var(var)
		return args or #args > 0
	end

	local function add_audio(text, audios, lang, show)
		-- This function has side effects
		for _, audio in ipairs(audios) do
			if audio == "y" then audio = string.format("%s-%s.ogg", lang, mw.title.getCurrentTitle().baseText) end
			table.insert(text, "\n*" .. (show and "::" or "**") .. " [[File:")
			table.insert(text, audio)
			table.insert(text, "]]")
		end
		if #audios > 0 then
			table.insert(text, "[[Category:")
			table.insert(text, langname)
			table.insert(text, " terms with audio links|" .. sortkey .. "]]")
		end
	end
	
	local function add_audio_show(text, audios, lang)
		add_audio(text, audios, lang, "show")
	end

	local text = {} --the pronunciation table
	if not only_cat then
        --The whole table consists of 4 parts
        --"textShow" contains Part 1, 3 and 4
		local textShow = {'<div class="toccolours zhpron" style="overflow:auto; max-width:500px; font-size:100%">'}
        --"textHide" is Part 2
		local textHide = {}
		local function show(txt)
			table.insert(textShow, txt)
		end
		local function hide(txt)
			table.insert(textHide, txt)
		end
		local function hide_note(var)
			local note = args
			if note then hide(make_note(note)) end
		end

		show('<div class="vsSwitcher" data-toggle-category="pronunciations">\n<span class="vsToggleElement" style="float: right;"></span>')
        --Part 1 and 2, "Pronunciation" and "Pronunciation expressed in different romanizations"
		if m_rom or m_s_rom or m_x_rom or m_nj_rom or dg_rom then
			show("\n* ]")
		end
		if has_var("m") then
			local m_args = {}
			local m_pron = require("Module:cmn-pron")
			if m_rom then
				local str_analysis = m_pron.str_analysis
				local other_m_vars = has_var("m-s") or has_var("dg")
				show("\n" .. str_analysis(m_rom, "head", other_m_vars))

				m_args = str_analysis(m_rom, "")
				for i = 2, 5 do
					m_args = str_analysis(m_rom, tostring(i))
				end
				local m_args_params_prefixed_with_1 = {"n", "na", "nb", "nc", "nd"}
				for _, base in ipairs(m_args_params_prefixed_with_1) do
					for i = 1, 5 do
						local param = tostring(i) .. base
						m_args = str_analysis(m_rom, param)
					end
				end
				local m_args_params = {"py", "cap", "tl", "tl2", "tl3", "a", "audio", "er", "ertl", "ertl2", "ertl3",
					"era", "eraudio"}
				for _, base in ipairs(m_args_params) do
					m_args = str_analysis(m_rom, base)
					for i = 2, 5 do
						local param = tostring(i) .. base
						m_args = str_analysis(m_rom, param)
					end
				end
			end
			for i, audio in ipairs(m_audio) do
				local ind = i == 1 and "" or tostring(i)
				m_args = audio
			end
			show(m_pron.make_audio(m_args))
			hide(m_pron.make_args(m_args))
			hide_note("m")
		end
		if not has_var("m") and (has_var("m-s") or has_var("m-x") or has_var("m-nj") or has_var("dg")) then
			hide("\n* ]")
		end
		if has_var("m-s") then
			local m_s_pron = require("Module:zhx-sic-pron")
			local m_s_processed = gsub(gsub(gsub(m_s_rom, "/", " / "), "()()", "%1 %2"), "(+)", "<sup>%1</sup>")
			if m_s_rom then
				show("\n*: <small>(<i>], ]</i>)</small>: ")
				show(Consolas(m_s_processed))
			end
			add_audio_show(textShow, m_s_audio, "zhx-sic")
			hide("\n** <small>(<i>]</i>)</small>")
			hide("\n*** <small><i>]</i></small>: ")
			hide(Consolas(m_s_processed))
			local xinwenz = m_s_pron.convert(m_s_rom, "SWZ")
			if xinwenz then
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(m_s_pron.convert(m_s_rom, "SWZ")))
			end
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA(m_s_pron.convert(m_s_rom, "IPA")))
			hide_note("m-s")
		end
		if has_var("m-x") then
			local m_x_pron = require("Module:cmn-pron-Xian")
			local m_x_display, m_x_hidden, m_x_ipa = m_x_pron.py_process(m_x_rom)
			show("\n*: <small>(<i>], ]</i>)</small>: ")
			show(Consolas(m_x_display))
			add_audio_show(textShow, m_x_audio, "cmn")
			hide("\n** <small>(<i>]</i>)</small>")
			hide("\n*** <small><i>]</i></small>: ")
			hide(Consolas(m_x_hidden))
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA(m_x_ipa))
			hide_note("m-x")
		end
		if has_var("m-nj") then
			local m_nj_pron = require("Module:cmn-pron-Nanjing")
			local m_nj_display, m_nj_hidden, m_nj_num, m_nj_ipa = m_nj_pron.py_process(m_nj_rom)
			show("\n*: <small>(<i>], ]</i>)</small>: ")
			show(Consolas(m_nj_display))
			add_audio_show(textShow, m_nj_audio, "cmn")
			hide("\n** <small>(<i>]</i>)</small>")
			hide("\n*** <small><i>]</i></small>: ")
			hide(Consolas(m_nj_hidden))
			hide("\n*** <small><i>] (numbered)</i></small>: ")
			hide(Consolas(m_nj_num))
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA(m_nj_ipa))
			hide_note("m-nj")
		end
		if has_var("dg") then
			local dg_pron = require("Module:dng-pron")
			local dg_processed = dg_pron.process(dg_rom)
			if dg_rom then
				show("\n*: <small>(<i>], ] and ]</i>)</small>: ")
				show(Consolas(dg_processed))
			end
			add_audio_show(textShow, dg_audio, "dng")
			hide("\n** <small>(<i>]</i>)</small>")
			hide("\n*** <small><i>] and ]</i></small>: ")
			hide(Consolas(dg_processed))
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA(dg_pron.convert(dg_rom, "IPA")) .. "\n**: <small>(Note: Dungan pronunciation is currently experimental and may be inaccurate.)</small>")
			hide_note("dg")
		end
		if has_var("c") or has_var("c-dg") or has_var("c-nn")
		 or has_var("c-t") or has_var("c-kp")
		 or has_var("c-yj")
		 or has_var("c-yl") then
			if c_rom or c_dg_rom or c_nn_rom or c_t_rom or c_kp_rom or c_yj_rom or c_yl_rom then
				local c_count = (c_rom and 1 or 0) + (c_dg_rom and 1 or 0)
				 + (c_nn_rom and 1 or 0) + (c_t_rom and 1 or 0)
				 + (c_kp_rom and 1 or 0) + (c_yj_rom and 1 or 0)
				 + (c_yl_rom and 1 or 0)
				local c_sep = (c_count == 1) and " " or "\n*: "
				show("\n* ]")
				hide("\n* ]")
				if c_rom then
					local c_pron = require("Module:yue-pron")
					show(c_sep)
					show("<small>(<i>")
					if c_count > 1 then
						show("]–], ")
					end
					show("]</i>)</small>: ")
					show(Consolas(c_pron.show_standard(c_rom, is_single_hanzi)))
					add_audio_show(textShow, c_audio, "yue")
					hide(c_pron.hide_standard(c_rom, is_single_hanzi))
					if not args and is_single_hanzi and (c_rom:find("^") or c_rom:find(",")) then
						args = "The zero initial " .. format_IPA("/∅-/") .. " is commonly pronounced with a ''ng''-initial " .. format_IPA("/ŋ-/") .. " in some varieties of Cantonese, including Hong Kong Cantonese"
					end
					hide_note("c")
				end
				if c_dg_rom then
					local c_dg_pron = require("Module:yue-pron/Dongguan")
					local c_dg_display = c_dg_rom:gsub(","," / ")
						:gsub("%d%-?%d?","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_dg_display))
					add_audio_show(textShow, c_dg_audio, "yue")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_dg_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_dg_pron.jpp_to_ipa(c_dg_rom)))
					hide_note("c-dg")
				end
				if c_nn_rom then
					local c_nn_pron = require("Module:yue-pron/Nanning")
					local c_nn_display = c_nn_rom:gsub(","," / ")
						:gsub("%d","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_nn_display))
					add_audio_show(textShow, c_nn_audio, "yue")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_nn_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_nn_pron.jpp_to_ipa(c_nn_rom)))
					hide_note("c-nn")
				end
				if c_t_rom then
					local c_t_pron = require("Module:yue-pron/Taishanese")
					local c_t_display = c_t_rom:gsub(","," / ")
						:gsub("+","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_t_display))
					add_audio_show(textShow, c_t_audio, "zhx-tai")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_t_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_t_pron.hoisanva_to_ipa(c_t_rom)))
					hide_note("c-t")
				end
				if c_kp_rom then
					local c_kp_pron = require("Module:yue-pron/Kaiping")
					local c_kp_display = c_kp_rom:gsub(","," / ")
						:gsub("%d%-??%*?","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_kp_display))
					add_audio_show(textShow, c_kp_audio, "yue")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_kp_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_kp_pron.jpp_to_ipa(c_kp_rom)))
					hide_note("c-kp")
				end
				if c_yj_rom then
					local c_yj_pron = require("Module:yue-pron/Yangjiang")
					local c_yj_display = c_yj_rom:gsub(","," / ")
						:gsub("","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_yj_display))
					add_audio_show(textShow, c_yj_audio, "yue")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_yj_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_yj_pron.jpp_to_ipa(c_yj_rom)))
					hide_note("c-yj")
				end
				if c_yl_rom then
					local c_yl_pron = require("Module:yue-pron/Yulin")
					local c_yl_display = c_yl_rom:gsub(","," / ")
						:gsub("%*?","<sup>%0</sup>")
					show(c_sep .. "<small>(<i>], ]</i>)</small>: ")
					show(Consolas(c_yl_display))
					add_audio_show(textShow, c_yl_audio, "yue")
					hide("\n** <small>(<i>], ]</i>)</small>")
					hide("\n*** <small><i>]</i></small>: ")
					hide(Consolas(c_yl_display))
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA(c_yl_pron.jpp_to_ipa(c_yl_rom)))
					hide_note("c-yl")
				end
			end
		end
		if has_var("g") then
			local g_pron = require("Module:gan-pron")
			if g_rom then
				show("\n* ] <small>(<i>]</i>)</small>: ")
				show(Consolas(g_pron.rom(g_rom)))
			end
			add_audio_show(textShow, g_audio, "gan")
			hide("\n* ]")
			hide("\n** <small>(<i>]</i>)</small>")
			hide("\n*** <small><i>]</i></small>: ")
			hide(Consolas(g_pron.rom(g_rom)))
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA("/" .. g_pron.ipa(g_rom) .. "/"))
			hide_note("g")
		end
		if h_rom and (find(h_rom, "pfs=.") or find(h_rom, "gd=.")) or #h_audio > 0 then
			local h_pron = require("Module:hak-pron")
			if find(h_rom, "pfs=.") or find(h_rom, "gd=.") then
				show("\n* ]")
				show(h_pron.rom_display(h_rom,"yes"))
			end
			add_audio_show(textShow, h_audio, "hak")
			hide("\n* ]")
			if h_rom then hide(h_pron.rom_display(h_rom,"")) end
			hide_note("h")
		end
		if has_var("j") then
			local j_pron = require("Module:cjy-pron")
			if j_rom then
				show("\n* ] <small>(<i>]</i>)</small>: ")
				show(Consolas(j_pron.rom(j_rom)))
			end
			add_audio_show(textShow, j_audio, "cjy")
			hide("\n* ]")
			hide("\n** <small>(<i>]</i>)<sup>]</sup></small>")
			if j_rom then
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(j_pron.rom(j_rom)))
			end
			local no_sandhi = false
			local roms = rsplit(j_rom, "/")
			for i = 1, table.getn(roms) do
				if find(roms, " + ") then
					no_sandhi = true
					break
				end
			end
			hide("\n*** <small>Sinological ] (<i>old-style" .. (no_sandhi and ", no sandhi" or "") .. "</i>)</small>: ")
			hide(format_IPA("/" .. j_pron.ipa(j_rom, no_sandhi and "no_sandhi" or "") .. "/"))
			hide_note("j")
		end
		if has_var("mb") then
			local mb_pron = require("Module:mnp-pron")
			if mb_rom then
				show("\n* ] <small>(<i>]</i>)</small>: ")
				show(Consolas(mb_pron.rom(mb_rom)))
			end
			add_audio_show(textShow, mb_audio, "mnp")
			hide("\n* ]")
			hide("\n** <small>(<i>]</i>)</small>")
			if mb_rom then
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(mb_pron.rom(mb_rom)))
				hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
				hide(format_IPA(mb_pron.ipa(mb_rom)))
			end
			hide_note("mb")
		end
		if has_var("md") then
			local md_pron = require("Module:cdo-pron")
			if md_rom then
				show("\n* ] <small>(<i>]</i>)</small>: ")
				show(Consolas(md_pron.rom(md_rom)))
			end
			add_audio_show(textShow, md_audio, "cdo")
			hide("\n* ]")
			hide("\n** <small>(<i>]</i>)</small>")
			if md_rom then
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(md_pron.rom(md_rom)))
				if not (md_rom and find(md_rom, "(*)-(*)-(*)-(*)-(*)")) then
					hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
					hide(format_IPA("/" .. md_pron.ipa(md_rom) .. "/"))
				else
					hide("\n*** <small>Sinological ] <sup>(])</sup> (<i>no sandhi</i>)</small>: ")
					hide(format_IPA("/" .. md_pron.ipa(md_rom, "no_sandhi") .. "/"))
				end
			end
			hide_note("md")
		end
		if has_var("mn") or has_var("mn-l") or has_var("mn-t") then
			local mn_pron, mn_l_pron
			if has_var("mn") or has_var("mn-t") then
				mn_pron = require("Module:sandbox/nan-pron")
			end
			if has_var("mn-l") then
				mn_l_pron = require("Module:nan-pron-Leizhou")
			end
			
			if mn_rom or mn_t_rom or mn_l_rom then
				show("\n* ]")
				if mn_rom then
					show(((mn_l_rom or mn_t_rom) and "\n*:" or "") .. " <small>(<i>], ]</i>)</small>: ")
					show(Consolas(mn_pron.poj_display(mn_pron.poj_check_invalid(mn_rom))))
					add_audio_show(textShow, mn_audio, "nan-hbl")
				end
				if mn_t_rom then
					show(((mn_rom or mn_l_rom) and "\n*:" or "") .. " <small>(<i>], ]</i>)</small>: ")
					show(Consolas(mn_pron.pengim_display(mn_t_rom)))
					add_audio_show(textShow, mn_t_audio, "nan-tws")
				end
				if mn_l_rom then
					show(((mn_rom or mn_t_rom) and "\n*:" or "") .. " <small>(<i>], Leizhou Pinyin</i>)</small>: ")
					show(Consolas(mn_l_pron.rom(mn_l_rom)))
					add_audio_show(textShow, mn_l_audio, "nan-luh")
				end
			end
			hide("\n* ]")
			if has_var("mn") then
				hide(mn_pron.generate_all(mn_rom))
				hide_note("mn")
			end
			if has_var("mn-t") then
				hide("\n** <small>(<i>]</i>)</small>")
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(mn_pron.pengim_display(mn_t_rom)))
				hide("\n*** <small><i>]-like</i></small>: ")
				hide(Consolas(mn_pron.pengim_to_pojlike_conv(mn_t_rom)))
				hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
				hide(format_IPA(mn_pron.pengim_to_ipa_conv(mn_t_rom)))
				hide_note("mn-t")
			end
			if has_var("mn-l") then
				hide("\n** <small>(<i>]</i>)</small>")
				hide("\n*** <small><i>Leizhou Pinyin</i></small>: ")
				hide(Consolas(mn_l_pron.rom(mn_l_rom)))
				hide("\n*** <small>Sinological ]</small>: ")
				hide(format_IPA(mn_l_pron.ipa(mn_l_rom)))
				hide_note("mn-l")
			end
		end
		if has_var("sp") then
			local sp_pron = require("Module:csp-pron")
			local sp_processed = sp_rom:gsub(",()",", %1")
				:gsub("()", "<sup>%1</sup>")
			show("\n* ] <small>(<i>], ]</i>)</small>: ")
			show(Consolas(sp_processed))
			add_audio_show(textShow, sp_audio, "csp")
			hide("\n* ]")
			hide("\n** <small>(<i>], ]</i>)</small>")
			hide("\n*** <small><i>]</i></small>: ")
			hide(Consolas(sp_processed))
			hide("\n*** <small>Sinological ] <sup>(])</sup></small>: ")
			hide(format_IPA(sp_pron.jpp_to_ipa(sp_rom)))
			hide_note("sp")
		end
		if has_var("w") or has_var("w-j") then
			local w_show, w_hide, w_j_show, w_j_hide
			if w_rom then
				w_show, w_hide = require("Module:wuu-pron/sandbox").make(w_rom)
			end
			if w_j_rom then
				w_j_show, w_j_hide = require("Module:wuu-pron/Jinhua").make(w_j_rom)
			end
			show("\n* ] <small>(<i>]</i>)</small>")
			show(w_show)
			show(w_j_show)
			add_audio_show(textShow, w_audio, "wuu")
			hide("\n* ]")
			hide(w_hide)
			hide(w_j_hide)
			-- add_audio(textHide, w_audio, "wuu")
			hide_note("w")
			hide_note("w-j")
		end
		if has_var("x") or has_var("x-l") or has_var("x-h") then
			if has_var("x") then
				x_pron = require("Module:hsn-pron")
			end
			if has_var("x-l") then
				x_l_pron = require("Module:hsn-pron-Loudi")
			end
			if has_var("x-h") then
				x_h_pron = require("Module:hsn-pron-Hengyang")
			end
			if x_rom or x_l_rom or x_h_rom then
				show("\n* ]")
				if x_rom then
					show(((x_l_rom or x_h_rom) and "\n*:" or "") .. " <small>(<i>], ]</i>)</small>: ")
					show(Consolas(x_pron.rom(x_rom)))
					add_audio_show(textShow, x_audio, "hsn")
				end
				if x_l_rom then
					show(((x_rom or x_h_rom) and "\n*:" or "") .. " <small>(<i>], ]</i>)</small>: ")
					show(Consolas(x_l_pron.rom(x_l_rom)))
					add_audio_show(textShow, x_l_audio, "hsn-lou")
				end
				if x_h_rom then
					show(((x_rom or x_l_rom) and "\n*:" or "") .. " <small>(<i>], ]</i>)</small>: ")
					show(Consolas(x_h_pron.rom(x_h_rom)))
					add_audio_show(textShow, x_h_audio, "hsn-hya")
				end
			end
			hide("\n* ]")
			if x_rom then
				local x_diff = x_pron.stylediff(x_rom)
				hide("\n** <small>(<i>]</i>)</small>")
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(x_pron.rom(x_rom)))
				hide("\n*** <small>Sinological ] <sup>(])</sup>")
				hide(x_diff and " (<i>old-style</i>)" or "")
				hide("</small>: ")
				hide(format_IPA("/" .. x_pron.ipa(x_rom) .. "/"))
				if x_diff then
					hide("\n*** <small>Sinological ] <sup>(])</sup> (<i>new-style</i>)</small>: ")
					hide(format_IPA("/" .. x_pron.ipa(x_rom, "new") .. "/"))
				end
				hide_note("x")
			end
			if x_l_rom then
				hide("\n** <small>(<i>]</i>)</small>")
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(x_l_pron.rom(x_l_rom)))
				hide("\n*** <small>Sinological ] <sup>(])</sup>")
				hide("</small>: ")
				hide(format_IPA("/" .. x_l_pron.ipa(x_l_rom) .. "/"))
				hide_note("x-l")
			end
			if x_h_rom then
				hide("\n** <small>(<i>]</i>)</small>")
				hide("\n*** <small><i>]</i></small>: ")
				hide(Consolas(x_h_pron.rom(x_h_rom)))
				hide("\n*** <small>Sinological ] <sup>(])</sup>")
				hide("</small>: ")
				hide(format_IPA("/" .. x_h_pron.ipa(x_h_rom) .. "/"))
				hide_note("x-h")
			end
		end
        -- combine textShow and textHide into text
		text = {
            table.concat(textShow),
            '\n<div class="vsHide">\n----\n',
            table.concat(textHide),
            "</div></div>"
        }

        --Part 3 "Dialectal data"
		if dial ~= "n" and is_single_hanzi then
			local success, m_dial = pcall(mw.loadData, "Module:zh/data/dial-pron/" .. pagename)
			if success then
				local dialPron = {}
				local temporary = {}
				if dial and find(dial, "^+$") then
					for element in rgsplit(dial, ",") do
						table.insert(dialPron, m_dial)
					end
				else
					for _, element in ipairs(m_dial) do
						table.insert(dialPron, element)
					end
				end
				for _, set in ipairs(dialPron) do
					for _, object in ipairs(set) do
						table.insert(temporary, object)
					end
				end
				local rand = gsub("-" .. table.concat(temporary), "", codepoint("%1"))
				table.insert(text,
                    '\n----\n<div class="vsSwitcher" data-toggle-category="pronunciations" style="background-color:#FAFFFA">\n* ' ..
                    '<span style="color:#3366bb">Dialectal data</span>' ..
					'<span class="vsToggleElement" style="float:right; padding:0 0; font-size:90%"></span>\n' ..
                    '<div class="vsHide">'
                )

				table.insert(text, '\n{| class="wikitable" ' ..
					'id="' .. rand .. '" style="width:100%; margin:0; ' ..
					'text-align:center; border-collapse: collapse; border-style: hidden; display: table;"')

				local locStart = "\n|-\n!"
				local readingStart = table.concat({'\n!style="background:#E8ECFA; width:9em"|',
				'<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">="edit"})), ' edit]</span></div><span lang="zh" class="Hani">'})
				local locEnd = '<span class="IPA">'
				local headclr = 'style="background:#E8ECFA"|'
				local mclr = 'style="background:#FAF5F0"|'
				local jclr = 'style="background:#FAF5F0"|'
				local wclr = 'style="background:#F4F0FA"|'
				local huclr = 'style="background:#FAF9F0"|'
				local xclr = 'style="background:#F0F2FA"|'
				local gclr = 'style="background:#F0FAF3"|'
				local haclr = 'style="background:#FAF0F6"|'
				local cclr = 'style="background:#F0F5FA"|'
				local minclr = 'style="background:#F7FAF0"|'
				local clrList = {
					mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr,
					mclr, mclr, mclr, mclr, mclr, mclr, mclr, jclr, jclr, jclr,
					wclr, wclr, wclr, wclr, huclr, huclr, xclr, xclr, gclr, haclr,
					haclr, cclr, cclr, cclr, minclr, minclr, minclr, minclr, minclr
				}
				local locList = {
					table.concat({headclr, "Variety\n!", headclr, "Location"}),
					table.concat({"rowspan=17 ", mclr,  "Mandarin\n!", mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({mclr, "]\n|", mclr}),
					table.concat({"rowspan=3 ", jclr, "Jin\n!", jclr, "]\n|", jclr}),
					table.concat({jclr, "]\n|", jclr}),
					table.concat({jclr, "]\n|", jclr}),
					table.concat({"rowspan=4 ", wclr, "Wu\n!", wclr, "]\n|", wclr}),
					table.concat({wclr, "]\n|", wclr}),
					table.concat({wclr, "]\n|" , wclr}),
					table.concat({wclr, "]\n|", wclr}),
					table.concat({"rowspan=2 ", huclr, "Hui\n!", huclr, "]\n|", huclr}),
					table.concat({huclr, "]\n|", huclr}),
					table.concat({"rowspan=2 ", xclr, "Xiang\n!", xclr, "]\n|", xclr}),
					table.concat({xclr, "]\n|", xclr}),
					table.concat({gclr, "Gan\n!", gclr, "]\n|", gclr}),
					table.concat({"rowspan=2 ", haclr, "Hakka\n!", haclr, "]\n|", haclr}),
					table.concat({haclr, "]\n|", haclr}),
					table.concat({"rowspan=3 ", cclr, "Cantonese\n!", cclr, "]\n|", cclr}),
					table.concat({cclr, "]\n|", cclr}),
					table.concat({cclr, "]\n|", cclr}),
					table.concat({"rowspan=5 ", minclr, "Min\n!", minclr, "] (Hokkien)\n|", minclr}),
					table.concat({minclr, "] (Eastern Min)\n|", minclr}),
					table.concat({minclr, "] (Northern Min)\n|", minclr}),
					table.concat({minclr, "] (Teochew)\n|", minclr}),
					table.concat({minclr, "] (Hainanese)\n|", minclr})}

				local function ipa_correct(ipa, location)
					if location == 22 then return (gsub(ipa, "13", "23")) else return ipa end
				end

				local function fmtDial(text, location)
					local fmttedPron = {}
					if text == "" then return "" end
					for pronunciation in rgsplit(text, "|") do
						local ipa = match(pronunciation, "^+")
						ipa = gsub(ipa, "()()", "%1̚%2")
						local environ = match(pronunciation, "*$") or false
						table.insert(fmttedPron, "<span class=\"IPA\"><small>/" ..
							tostring(ipa_format(ipa_correct(ipa, location))) .. "/</small></span>" .. (environ
							and " <span class=\"Hani\" lang=\"zh\"><small>"..environ.."</small></span>" or nil))
					end
					return table.concat(fmttedPron, "<br>")
				end

				for locationNo = 1, 40 do
					for readingNo = 1, #dialPron do
						if readingNo == 1 then
							table.insert(text, locStart)
							table.insert(text, locList)
						end
						if locationNo == 1 then
							local situation = dialPron
							table.insert(text, readingStart)
							table.insert(text, pagename)
							table.insert(text, (pagename ~= situation and " (" ..
								gsub(situation, pagename, "<b>" .. pagename .. "</b>") .. ")" or ""))
							table.insert(text, "</span>")
						else
							table.insert(text, (readingNo == 1 and "" or "\n|" .. clrList))
							table.insert(text, locEnd)
							table.insert(text, fmtDial(dialPron, locationNo))
							table.insert(text, "</span>")
						end
					end
				end
				table.insert(text, "\n|}</div></div>")
			end
		end

        --Part 4 "Middle Chinese & Old Chinese"
		local mc_preview, oc_preview
		local m_ltc_pron, m_och_pron

		-- !!!
		-- The following function modifies the tables generated by mod:ltc-pron and mod:och-pron, shifting them
		-- from using "mw-collapsible" to using "vsSwitcher", because the former
		-- can not collapse on the mobile site and makes Chinese entries a mess.
		-- It is supposed to be a temporary solution.
		-- !!!
        local function shiftCustomtoggle2Vsswitcher(s)
            local result
            result = (s:gsub(
                '\n%* <div title="expand" class="mw%-customtoggle+">',
                '\n<div class="vsSwitcher" data-toggle-category="pronunciations">\n* '
            ):gsub(
                '<span style="float:right; border:1px solid #ccc; border%-radius:1px; padding:0 0; font%-size:90%%">▼</span>(.-)</div>\n{| class="wikitable',
                '<span class="vsToggleElement" style="float:right; padding:0 0; font-size:90%%"></span>%1\n<div class="vsHide">\n{| class="wikitable'
            ):gsub(
                '{| class="wikitable mw%-collapsible mw%-collapsed" id="+"',
                '{| class="wikitable"'
            ):gsub(
                "\n|}$",
                "\n|}</div></div>"
            ))
            return result
        end

		if mc then
			m_ltc_pron = require("Module:ltc-pron")
			mc_preview = m_ltc_pron.retrieve_pron(pagename, false, mc, true)
			if not mc_preview then
				require("Module:debug/track")("zh-pron/Middle Chinese data not found")
				mc = nil
			end
		end
		if oc then
			m_och_pron = require("Module:och-pron")
			oc_preview = m_och_pron.generate_show(pagename, oc)
			if not oc_preview then
				require("Module:debug/track")("zh-pron/Old Chinese data not found")
				oc = nil
			end
		end
		if mc or oc then
			table.insert(text, '\n----\n<div style="background-color:#f7fbff">')
			if mc then
				table.insert(text, shiftCustomtoggle2Vsswitcher(m_ltc_pron.ipa(mc, mc_preview)))
			end
			if oc then
				table.insert(text, shiftCustomtoggle2Vsswitcher(m_och_pron.ipa(oc, oc_preview)))
			end
			table.insert(text, "</div>")
		end
		table.insert(text, "</div>")
		if namespace == "" or namespace == "-" then
			if mc then
				table.insert(text, "]")
                if is_single_hanzi then
                    if mc_preview:find("k̚$") then
                        table.insert(text, "]")
                    elseif mc_preview:find("t̚$") then
                        table.insert(text, "]")
                    elseif mc_preview:find("p̚$") then
                        table.insert(text, "]")
                    end
                end
			end
			if oc then table.insert(text, "]") end
			if not args then
				table.insert(text, "]")
			end
		end
	end

	local conv_text = {} --categories
	if namespace == "" or namespace == "-" then
		local catText = args or ""
		local cat_start = "[[Category:"
		local cat_end = "]]"
		if w_rom then
			w_rom = gsub(w_rom, "%d", "")
		end
		
		local function add_cat(cat_table, name, cat)
			table.insert(cat_table, cat_start .. name .. cat .. "|" .. sortkey .. cat_end)
		end

		local cats = rsplit(catText, ",", true)
		if pos_aliases_cat] == "four-character idioms" then
			table.insert(cats, 2, "idioms")
		end
		table.insert(cats, 1, "lemmas")
		for i = 1, #cats do
			local cat = cats
			if cat == "" then break end
			cat = gsub(cat, "^ +", "")
			if find(cat, ":") then
				local cat_split = rsplit(cat, ":", true)
				local lang_name = langname_abbr]
				local category = pos_aliases_cat] or cat
				add_cat(conv_text, "Chinese ", category)
				table.insert(conv_text, cat_start .. lang_name .. " " .. category .. "|" .. sortkey .. cat_end)
			else
				cat = pos_aliases_cat or cat
				add_cat(conv_text, "Chinese ", cat)
				if m_rom or m_x_rom or m_nj_rom then add_cat(conv_text, "Mandarin ", cat) end
				if has_var("m-s") then add_cat(conv_text, "Sichuanese ", cat) end
				if has_var("dg") then add_cat(conv_text, "Dungan ", cat) end
				if c_rom or c_dg_rom or c_nn_rom or c_kp_rom or c_yj_rom
					or c_yl_rom then add_cat(conv_text, "Cantonese ", cat) end
				if c_t_rom then add_cat(conv_text, "Taishanese ", cat) end
				if has_var("g") then add_cat(conv_text, "Gan ", cat) end
				if h_rom and (find(h_rom, "pfs=.") or find(h_rom, "gd=.")) or #h_audio > 0 then
					add_cat(conv_text, "Hakka ", cat)
				end
				if has_var("j") then add_cat(conv_text, "Jin ", cat) end
				if has_var("mb") then add_cat(conv_text, "Northern Min ", cat) end
				if has_var("md") then add_cat(conv_text, "Eastern Min ", cat) end
				if has_var("mn") then add_cat(conv_text, "Hokkien ", cat) end
				if has_var("mn-t") then add_cat(conv_text, "Teochew ", cat) end
				if has_var("mn-l") then add_cat(conv_text, "Leizhou Min ", cat) end
				if has_var("sp") then add_cat(conv_text, "Southern Pinghua ", cat) end
				if has_var("w") then add_cat(conv_text, "Wu ", cat) end
				if has_var("w-j") then add_cat(conv_text, "Wu ", cat) end
				if has_var("x") then add_cat(conv_text, "Xiang ", cat) end
				if has_var("x-l") then add_cat(conv_text, "Xiang ", cat) end
				if has_var("x-h") then add_cat(conv_text, "Xiang ", cat) end
			end
		end
		table.insert(conv_text, cat_start .. "Chinese terms with IPA pronunciation|" .. sortkey .. cat_end)
		if is_single_hanzi then
			table.insert(conv_text, cat_start .. "Chinese Han characters|" .. sortkey .. cat_end)
		end
		if not find(pagename, hanzi) and not find(pagename, bopomofo) and not args.no_foreign_script_cat then
			table.insert(conv_text, cat_start .. "Chinese terms written in foreign scripts|" .. sortkey .. cat_end)
		end
	end

	local output = table.concat(text) .. table.concat(conv_text)
	if namespace ~= "" and namespace ~= "-" then
		output = gsub(output, "%]+%]%]", "")
	end
	return output
end

return export