Module:zh-forms: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
add comment to $chars_unified
appearance tweaks
(29 intermediate revisions by 12 users not shown)
Line 1: Line 1:
local export = {}
local export = {}
local m_zh = require("Module:zh")
local links = require("Module:links")
local links = require("Module:links")
local lang = require("Module:languages")
local lang = require("Module:languages")
local m_data = require("Module:zh-forms/data")
local find = mw.ustring.find
local gsub = mw.ustring.gsub
local m_scripts = require("Module:scripts")
local m_str_utils = require("Module:string utilities")
local match = mw.ustring.match

local len = mw.ustring.len
local concat = table.concat
local explode = m_str_utils.explode_utf8
local find = m_str_utils.find
local get_section = require("Module:utilities").get_section
local gsub = m_str_utils.gsub
local insert = table.insert
local len = m_str_utils.len
local match = m_str_utils.match
local new_title = mw.title.new
local sub = m_str_utils.sub
local u = m_str_utils.char

local Hani_chars = m_scripts.getByCode("Hani"):getCharacters()
local nonbreaking_hyphen = u(0x2011)


local sc = {
local sc = {
Line 13: Line 26:
["both"] = "Hani",
["both"] = "Hani",
}
}

local chars_variant_both = 'しめ溼裡うらぐん羣床ゆかまもるまもる污汚ためためにせにせ炮砲麵麪やかまし諠嘩譁鄰となりせん綫眾しゅ'
local chars_variant_one = 'たい輓遊あいだ'
-- result of comparing the utf32-cn.map and utf32-tw.map files that are at https://github.com/adobe-fonts/source-han-sans/tree/release/Resources
local chars_unified = "⺽⼊⼋⼔⼣⼥⼾⽍⽐⽕⽚⽛⽠⽡⽰⽱⽳⽶⽼⽾⽿⾆⾇⾌⾝⾠⾣⾬⾮⾵⾷⾻⾿⿁⿅⿆⿇⿈⿋⿌⿏⿓⿔㑤㑦㒈㒓㒖㒯㒼㓁㓲㕙㕯㕹㖗㖘㖨㖿㗛㗳㗻㗾㘉㘚㙂㙇㙈㙎㙳㚚㚥㚪㚬㚰㚱㚵㚹㚼㛁㛃㛄㛅㛇㛈㛓㛔㛖㛝㛡㛢㛥㛦㛵㜁㜃㜈㜊㜍㜜㜟㜢㜣㜥㜬㜭㜰㜲㜳㜺㝢㝬㞹㞾㟲㟴㟸㠏㠗㠙㠠㡵㢣㤆㤯㥤㥯㦀㦊㦑㦙㦛㦤㦾㧬㧻㨘㩞㩦㩧㪖㫵㫶㫽㬚㬫㬹㮕㮡㮴㯂㯄㯳㯴㱔㱕㲋㴬㴲㵆㵌㵝㵟㵢㵩㵪㵵㶈㶏㶥㶭㶴㶿㷆㷇㷉㷌㷍㷓㷧㷨㷫㷳㷴㷷㷼㷽㸆㸏㹃㺖㺲㻇㻐㻑㻖㻗㻢㻧㻫㻬㻰㻳㻴㻺㼀㼆㽹㿀㿍㿗㿭㿹㿺䀝䁓䁘䁟䁥䁯䂨䃈䃺䄃䄒䄲䅮䅼䅿䆲䆻䆿䇛䇭䇯䇹䈑䈣䉀䉠䉪䉶䊌䊔䊢䋻䌊䌫䍃䎑䎗䎚䎺䎼䏁䏊䏙䏟䏭䏰䏲䐁䐂䐓䐗䐤䐥䐭䑛䑺䒟䒠䒢䒰䒷䒽䓀䓃䓅䓎䓝䓞䓟䓡䓤䓩䓪䓫䓬䓲䓴䔃䔄䔉䔋䔖䔛䔝䔧䔮䔳䔶䔻䔽䔿䕃䕑䕒䕕䕘䕜䕡䕢䕪䕭䕷䕸䕺䕾䖅䖎䖓䖛䖣䖳䗚䘆䘵䙺䚀䚄䛀䛷䜓䜘䜶䝏䞦䟴䟿䠴䠷䡊䡝䡱䢛䢭䢮䣐䣭䣮䣳䣺䤆䤑䤫䤵䥑䥲䧔䧩䨏䨝䨤䨵䩮䪤䪩䫿䬐䬙䬠䬬䬷䮐䮽䯀䯊䯒䯛䰁䰠䱀䱗䱚䱭䱷䱻䱽䴇䵶䵷䶉ななうし丕丰まる丽乖じょう乜也乬乸乿亃亇些亟亡あきら亲亹仈今仞令以仮仱仳仹任份伀伋伍伙伨伬伶伾佌てい佒佘佞佢佤佬佲佴佺佽佾侂ただし侈例さむらい侑侒わび侞侫こう侴侵侹侺侻俀俁係しゅん俏保俞俟おさむ俳俺俿倃倆倇くら倏倓倕候倜倥倧倩やまと倯倰倱倷倻偀偃偈えら偊偌へん偑偕偛偞偠偡偢偤偨偫偰偶偷偺傀傁傂傅すぐる傒傖備傜傝傞傦傭傯傲傴傺傻僂僄僆僇僈僊僋僎像僐僔ぼく僙僟僠僣僪僭僯僱僳僶僸僾わし儆儋儍儒儗儚儠儢儦優儭儰儱儳儵儷げんたかし兌兝兠入內全りょう兪八こう兮冀冇冏かぶと冞冢べき决冴ひや冹冽すご凊凋しのげ凐凔凜凝凞凭凼刃分列ぶんれつ刢刱刵刹刼剁そぎぜん剏剕剙剜剡剨剩剪剭剮割剳創剷剹剺剽劀劄げき劋劐劖劗劘努いさむ勌勓かんつとむろうつの勠勢勥勱勴勵すすむ匊匎匑匒匕化きたさじ匜匧匪匴ひき匼匽匾匿卌博卨印おろし卼厎厖厜厞厦うまや厫厬いや厲厳厴及はん叛叟くさむら叭名吒吜ぎん吡吩吪含くれ吶吸われ呀呁ほけてい呎呝呢呤呧周呰呱呲呶呸咎咓咠咡咤咧咨咪咫さき咴咹咼咾哆哎哤哨哮哸哾唃唅唆唇唉唌唚唥唬唳唴唵唷唸唼唾啁啃ついばめしょう啌啖けい啡啢啣啨啾啿喁善喈喉ちょう喍喎喏喒喓喚かつ喟喢喨喩喫喭くえ喳喴喵喺喻喼喿嗁嗂嗄嗅嗆嗋嗏嗐嗒嗓嗕嗖嗗嗘嗜嗞嗟嗡嗢嗤嗬嗲嗵嗶嗷嗸嗹嗼嗾嗿嘄嘅嘆嘌嘍嘐嘑嘒嘔嘗嘛嘜嘝嘩嘬嘮嘰くちばしさぞ噀噂噃噅噆噉噊噏噒噓噗噙噚噠噡噢噤噥噪噬噯噱噳噶ばなし噾噿嚁嚂嚃嚄嚅嚆嚒嚓嚘嚝嚟嚥嚦嚧嚨嚫嚭嚯嚱嚴嚵嚶嚹嚽嚾嚿ささやき囃囈囌囓囖囟囡囧おとり囹囿圀圇けん圊園圛圞圾坂坅均坋坌坒块坭坯坱坴坺坻坼坽たれ垔垛垞垵垹埁ほこり埆埈埏埐埕埝埥埦埩埭埵埶埽埾堉堎堒堔堗堙堝堞堠堡堣堦堧堨堩堪堬堰堶塈塉塊塋塌塑塒とう塕塗づか塛塟塣塭塳塵塶塺塿墁墂墆墈墉墍墏墒墓墚墟墡墣墦墫墮墯墴墵墶墺壈壉壏壒あつ壖壙壚壜壝壟壢壣壧壩みずのえ壾壿夅変夌复夎夏夑夒夔夕がい夗夙夠夢夤夥夬央奃奄奆奈奐契奓奕奘奚奜奝奠奥おく奩奫奱女やつ奵奶奷奸她奻奼好奾奿妀妁如妃妄妅妉妊妍妎妏妐妒妓妔妖妗妘みょう妚妝妞妟妠妡妢妣妤妥妦妧さまたげ妬妭妮妯妰妱妲妳妴妵妶妷妸妹妺妻妼妽わらわ妿姀姁姃姄姅姆姇姈姉姊始姌姍姎姏あねしゅうと姒姓姖姘姙姚姛姜姝姞姠姡姣姤うばかん姨姩めいひめひめ姭姮姯姰姱姲姳姴姵姶姷姸姹姺姻姼姽姾姿すがた娀威娂娃娉娊娋娌娍娏しゃば娒娓娕娖娗娘娙娚娛娜娞娟娠娡娣娤娥娧娩娪娫娬娭娮娰娳娵娶娷娸娹娼娽娾婀婁婂婃婄婅ばば婇婈婉婊婌婍婐婑婒婓婔婕婖婗婘婙こん婛婜婝婞婟婠婡婢婣婤婥婦婧婨婩婪婫婬婭婮婰婱婷婸婹婺婻婼婽婾婿むこ媁媂媃媄媆媈媊媋媌媎媏媐媑媒媓媔媕媖媗媙こびひめ媜媝媞媟媠媡媢媤媥媦媧媩媫媬媮媯媰媱媲媳媴媵媶媷媸媹媺媻おうな媽媾媿嫀よめあによめ嫃嫄嫆嫇嫈嫉嫊嫋いや嫍嫎嫏嫑嫓嫕嫖嫗嫘嫙嫚嫛嫜嫝嫞嫟嫠嫡嫢嫣嫤嫥嫦嫨嫩嫪嫫嫬嫭嫮嫯嫰嫲嫳嫴嫵嫶嫷嫸嫹嫺嫻嫽嫾嫿嬁嬂嬃嬅嬇嬈嬉嬋嬌嬍嬎嬏嬐嬑嬓嬔嬕嬖嬗嬙嬚嬛嬝嬞嬟嬠嬡嬣嬤嬥嬦嬧嬨嬪嬫嬬嬭嬮嬯嬰嬲嬴嬸嬼嬽嬾嬿孀孁じょう孄孅孆孇孈孊孋孌孍孎孏孝孥孫孬孮孶孷孺孽宂宅やすむねあてなだめがいえんよい宸寈寑寓寖寙寞察寠寢寤寥寨審寪寬寱寲たから寴寵てら尃射はたじょうみことひろしるべ尐尜尠尨尳尷せき屄屍屎屑屔屝ぞく屢履屧屨屳屸屹屺屻屼屾岅岆岈岉岋岌岍岏岐岑岒岓岔岞岟岠岣岤岥そわ岫岬岭岮岯岰岵岶岷岺岻峂峆峈峋峌峏峐峑峒峓峔峖峗峘峙峛峟峥峨峪峬峭峮ほう峱峴峵峸峹峻かい峿崆たかし崋崌崍崎崏崐こん崕崘崚崛崝崞崠崢崣崤崥崦崧崨崯崰崲崳崴崵崷崸崹崺崼崾崿嵁嵃嵆嵈嵉嵊嵋嵎嵐嵑嵕嵖嵞嵢嵣嵥嵧嵨嵫嵬嵯嵰嵱嵲嵳嵴嵷嵹嵺嵻嵼嵽嶀嶁嶂嶅嶆嶇嶈しま嶍嶒嶓嶕嶗嶙嶜嶝嶞嶟嶠嶢嶤嶧嶩嶪嶫嶬嶮嶯嶰嶱嶴嶵嶶嶷嶸嶹みね嶼巁巂巃巆巇巉巋いわおたかし巏巑巕巖巗巘しゅう巟巡きょ巰巽帍帑帗帘帚帟帤帨帩帮たい幔幕まんまく幞幡幧幨幪幭幯幰かそけいく庀庇庈庌庐底庛庤庨庬庮庱あんかんいさお庹庽廆廈廋廌廐廒廔廕廖廗廘廛廡廣廨廩いおり廮廰廲廳のべ异弅弈弊弎弒弚弛弡弤わたるいしゆみ弭弰彃彄彉彍彐彔彗彘彛彝彞彠あや彯彲彶彸彽彾まち徎徖徘徟ふく循徭ほろ徯徵てっ徿忍忘忙忛忞忣忪かい忴念忸忿怇怌怏怒怓怜怟怣きゅう怨怩怵恀恁恃恅恆恉恋おそれじょ恝恢ほしいままはじ恬恮恷恾悁悄えつ悆悉悛悜悞悟ゆう您悰悱悲悷悸悽悾惃惄じょう惆惋惌惔惗惘惰惵惹惼惾愀愁愇いよいよ愉愌愍愎愒愖あい愝感愧愨愮愲愴愶愻愽愾愿慀慄慅慇たい慌慓慕慜慝慠慢慤慥慦とし慨慪慮慰慲慴慵けい慷慺慼慾憀憂憈憊憋憌憐憖憝憟憡憤憨憩憮憯憰憲憳憴憹憺憼憾懂懅懆懇たゆ懊懋懌懍懘懚懞懡懣懦懨懩懭懮懲懵ものぐさかか懻懽懾懿戜戠戡戢戤戥戧戫戮戲戳戺戽戾ぼうひらた扂扃扆扇扈扉扊扒たく扡扨扭扮扱扲扳批扽承こじ抐抓抭抳抵拆拎拏拐拒拔拖拟拰拴拶拸拻ゆび挈按挐挓挖挨挩振挰挷挻挼捌捎捐捑捔捘捛捥捩捶捸捺捻捼捿掃掅掋掍はい掕掖掞探せっひかえ掩掫きく掮掯掰揂そろい揄揆もめ描插揓揕揖揗揙換揝揟揠揩揪揫揬揭揯揱揲揳揶揸揹揻搇搋搎搏搓搔ゆら搘搚さがせ搡搢搥搦搧搨搫搬搭搮搰搲搳搶搽搾搿摋摎摓摙摛摝摟摠摡摦摩摮摰摱摳摴摸摹摺摽撈撍撏撐撒撖撗撘撙撚撝撤なで撬播つまみ撯撰撱撲撶撻撼撾擂擃擄みさお擎擏とりこ擔擖擙據擛擢擦きょ擨擩なずらえ擭擱擲擴擵擸擺擻擽擾擿攁攃攄攆攇攉攊攍攏攐攑攖攗攙攛攜攝攟攠攡攥攦攬攭攳敉敖きょう敜敢散けいじきすう敺斁斃斐斒斖りょう斛斟斢斥しんほどこせ旍旎ぞく旒旓旚旛旞旟旡既すんでむね旲昀昄昅こん昈昋昐昑昝映昤昵晏晗晙晨晭晴晵晷晻晼暆暍暎暐暚暛暡暨暩暪暬暮暱暵暹暽曁曄れきくもり曌曔曖曘曚曜曠曣曤曨曬曮曰曷曼替さい朁朂朅有朎朔ちん朘朙もち朠朡朢朥朦朧もうろう朳朵朼杋あんず杒杗杝条もく杧杰杲杳杻松ばん极枃枇枌枍枒枔枘枲架柂柃柅柋柍某柒染やわら柜柝柢查柧柭柰柴柸柼とちせん栔栗栘栚栠栥栨栩栮栯栳栵栾桀桇案桉桌くわ桝桭桯桵桷梁梄梆梊梋梐梒じょうふくろう梠梢梣梤梦梨梫梭梲梳梴梵棄棇棈棍棎棐棑棕棙棠棣はねず棦棨棪森棯棰棱棲棷棸棻棼棽椀椂椃椄椆ぶな椉椌椓椕椖椛椰椲椶椸さわら椻楀楂楄楆楈楉楌楑楓くさび楘楛楜楡ならゆずりはかじ楬業楲極楶楷ひさぎ楺概榆榍えのき榑榗榙榛榣榤榦榧榨榩榭榮榯榰榹榻榽榾槂槃槆槉槊槌やり槎槐槢槤槥槦槧槩槬槱かしわ槳槴槷槸槺槼槾樂樆樇樊樋樑樓ぶなしるべ樚樛樝樞樠模樤樥樧樳樶樸かばだる橀橁橄橅橆橇橉橎橏橐橒橓橕橖たちばな橠橡橢橤橩橪よこ橯橾檁檂檃檉檌檎檐檑檒檓檕檖檗檛檝檞檠檤檦檧檨檫檬檱檴檶おり檽檾檿櫂櫆櫊櫋櫌櫏櫐櫔櫘櫙櫚櫜櫟櫡櫨くぬぎ櫫櫬櫱櫳櫶櫸櫹櫺さくら欂欃けやき欇欈欉權欐欒欖欗欚欝欞次欦欵欻款歁歃歅歇歈歋歎歐歑歔歙歟歠歡此歫歭歯歴歷れきれき歹死歾歿殀殁殂殃殄殆殈殉こと殌殍殎殏殑殔殕殖殗殘殙殛殞殟殠殢殣殤殥殦殧殪殫殭殮殯殰殲殶殺殽毆毇毉毌毒毓比毖毗毘毚毞毣毦毬毯毳毹毻毼毾氀氁氂氄氉氐氓氛氝氡氨氪氮氯氰氹汃汆汍汎しお汒汝汩汭汮汲汳汵けつ汾沉沊沘沜沢沭沲沶沿泒泚泜泝泠泥泬泰泱洃きよし洖洚洝洤洧洬洯洰洱洲洳洺りゅう浚浛浧浱浵浸浻浽しょう涊涍よだれ涓涔涗涘えき涳涴涵涶涹涿淆淍淒淓淕淗淙淚淝淞あわ淥淩いん淭淯淰深淲混淹淼淽渄せいきよし渜渝みぞ渢渣うず渫渭渮渳渴渵渶渼渿湀湇湉湋湑湒湓湔湖湚湛湝湠湤湥ゆう湨湫湮湱湸溉溍溗溙溚溛溞溠溡溥溦溧溪溭溯溱溲溴溺溻溽溾滃滄滅滊滌滍滎滐滑滕滘たき滢滫滬滭滮滯滶滹滺滻滼滽たぎ滿まん漂漆漈漉漊漏漒漓漘漚ばくかんさざなみ漤漥漫漭漮漻漿潁潃潏潒潔潖潗はんせんせん潝潠潢潯潲潳潷潸潾澀澂澇澈澉澊澐澓澕澞澠澡澥澨澪澬澯澲澳澵澸澹澻澽澾濄濈濍濙濚濛濡濢濦濩濫濭濮濯濴濷濸濼濾瀀瀁瀄瀅瀇瀊瀋瀌瀍瀖瀗瀘瀙瀛瀝とろ瀟瀠瀡瀢瀧瀨たきせ瀩瀪瀯瀳瀴瀵瀷瀺瀿灀灄灆灊灌灐灑灕灖灜灞灠灡灤灥灮灯はい灵灶灷灸灹灺灼災灾灿炁炂炃炄炅炆炊炍えん炏炐炑炒炔炕炖炘炙炚炟炠炡炢炤炥炦炧炩炫炬ずみ炮炯炱炳炴炵炷炸炻炼炽炾烀烄烇烈烊烋烎烐烑烓烔烕烖烗烘烙烚烜烞烟烠烡烢烤烯烰烱烵烶烷烸烺烻烼烽烾烿焀焂焅焆焈焊焋焌焍焐焓焗焙焚焛焜焝焞焠焢焣焥焩焫焮焯焰焱焲焳焴焵然焾煀煁煃煅煆煇煉煊煋煌煎煐煑煒煓煖煗けむり煚煜煝煞煠煡煢煣すす煥煨はん煪煫煬煱煲煳煵煶煷煸煺煻煽煾熀熄熅熆熇熈熉ぐま熌熎熐熑熒熔熖熗熘熚熛熜熝熞熠熡熢熣熤熥熧熨熩熪熬熭熯熰熱熲熳熴熵熷熸熺熾熿燀燁燂もえ燄燅燇燈燉燊燋燎燏燐燑燒燔燕燖燘燙燚燛燜燝營おき燡燢燥燦ひうち燫燬しょく燮燰燱燲燴燵燶燸燹燻燼燽燿爀爁爂ばく爇爉爊爌爍爎爓爔爕爖爗爙爚爛爝爟爢爤爥爦爨爪爬爹じい牄片ばん牉牋ぱい牏牐牒牓牖牗牘牙牚牝牠牣牴牷とく牻牾犑犕犖犗犘犚犛犟犣犤犥犦犩犪犮犽狃狄狉狊狋狐狑狔狖狫狴狷狻狿猇猋猏猐猑猒猜猢猣猦猧猫猰猱猲猴猵猶猷猹猺猻猾獀獉獊獌獎ばく獒獘獚獝獡獦獬獲獴獵獶獷うそけんじ獾獿玁玂玡玢玤玦玪玭れい玼珊珛珝珡珤珥珫はん珵琀琄琇琉琊琌琛みがく琤琥琨琬琭琮琰琱琲琴琵琶びわ琷瑀瑋瑍瑎瑏瑐瑚あきら瑜瑟よう瑥瑧瑨瑩瑮瑰瑲瑳瑵瑹瑿璁璃璆璈璉璊璍璕璘璚璜璞璠璡璣璥璦璨璩璪璭璱璲璵璷璺璻璿瓀瓁瓂瓅瓈瓊瓋瓏瓐瓔瓗瓘瓛ふり瓝瓞瓟瓠瓡瓢べん瓤瓥かわら瓧瓨瓩瓪瓬瓮瓰瓱瓲瓴瓵瓶瓷瓸瓻瓽瓾瓿甀甂しきがわら甄甅甇甈甋甌いらか甎甏甐甑甒甓甔甕甖甗甚甜甝甪甯画甿畇畈畑畟畢畤番畬畯畹疄疏疑疕疝疢疪きず疷疾痈痊痏痑痚痜痝痞痟痠痥痦たん痱痲痵痷痿瘃瘈瘉瘊瘋瘑瘓瘔瘙瘛瘝瘟瘠かさ瘢瘣瘥瘦おこり瘩瘭瘯瘱瘳瘵瘺瘻瘼癀癆癑癒癓癗癘癙癚癢癥癧癩癭癮みずのと皂皆皈皉皊皣皤皪皫皴皻盆盉盋盎盔ぬすめ盝監ばん盦盧盩盭めくら盳盷盻盼眅県眡眢眥眯眳眵眹睃睄睈睊睒睕睖睙睛睡むつみ睩睭睮睽睿瞂瞃瞄瞅瞇瞈瞍瞎瞘瞙瞜瞝瞞瞟瞢まどか瞮瞰瞱瞲瞴瞵瞻瞾矂矅矇矋矌矏矐矓矔矗矙矜矝矞矣矦のり矮矱矲矺矽矾砉砏砐砑砒砥とりで砨砮砱砹硂硝硥硫硭确硹硺硻硾硿碀碃碆碉碌わん碟碡碢碣碤碥碪碳碴碶碸磃磆磇磈磉磋磍磎磐磓磔磗磘磝磟磡磨磭磯磲磷磺磻磼磿礇礌礙礛礜礞礡礤礦礪つぶて礭礯礱礳礴礵礶礹しめせ祂祓祗祟祡祤ひょうさい祲祳祾祿きん禂禃みそぎ禋禍禑禕禖禙禜禝禠禢禤禦禨禭禲禷禸禹禺离禽禿しゅう秅秋秌秎しいな秜秠秡秢しん秧秪秫秬秶秺うつり稄稅稆程やや稑稔りょう稟稠稦稨稭稯稰稷稽穄穅穈穊穋穎穔穖穟穠穥穨穩穫穬穮穲穴穵究穸穹そら穻穽穾穿窀突窂窃窄窅窆窇窈窉窊窋窌窏窐窑窒窓窔窕あなぐらまど窘窙窛窞くつ窠窢窣窨窩窪窫窬きゅうかま窰窱窲窳窴窵やつれ窷窸窹窺窻窼窽窾窿竀竁竂かまど竄竅竆竇かまど竉竊竛竜竢竣竫竭竷竺竻竽竾竿笀笄笅笆きゅう笉笊たかんな笌笍笎笏笐笑笒笓笔笘しょうふえむち笟笠笢笣笤笥笧笨笩笪笫第笭笮笯笰笱笲笳笴笵笸ささ笻筀筃筅ひつ筇筈とう筊筋筌筍筎筏かたみ筑筒こたえ筕策筘筠筡筢筤筥筦筧筨筩おさ筭筮筯筰筱筲筳筴むしろ筶筷筻箄箅箇箈箊箋箌たが箎箏箐箑ほうき箓箔箖算箘箙箚箛箜箝箠管箢箤箬箭箮箯ばこ箲箴箵箷箹箾ぶしたかむらはん篅篆へんちく篊篋篌篎篏篐篔篕篙篚篛篜かがり篟篠篡篣あつし篥篦篧篨ふるい篪篫篬篰篱篲篳篴篷篸篹篺篼篾簁簂簃簄簅簆簇簉簋簌簍簎簏簐簑簒簕簙簛簜簞簟簠簡簢簣簥簦簧簨簩かんざししょう簬簭簰簳簷簸簹簻簼簽すだれ簿籀籂籃籄籅籇籈籉籊籌せきとう籑籓籔籖籗籙籚籛籜籝籟籠籣籤籥籦籧籩籪籫ませ籭籮籯籰籲米籴籵籸籹籺类籽籾籿粀きろめーとるしいな粄粅粈粉粊粌みりめーとる粑粒粔粕粖粗ねば粞粟粡粢粣粥粦粧粨粯粱粲うるち粴粶いき粺粻粼粽せい粿糂糄糅糇糈糉糊糋糌糍糎糑糒糔糕とう糗糙糚糜糝糞糟糠そうこう糢糧糨糪糬糭糮糯糰糱糲糴糵糶糷系紁紈紉納ひも紕級まがえ紝紟むらさき紱紷紻絁絉絍絒絘絚絛絜絟絮統絳絹絿綁綃綅綉綏綔綖綗綜綞綟みどり綢綩綪綮もう綹綾緀緂緄緅緉緋緌緐緓緛緜緝緧編緪緮ぬき緰緱緳緵緺緻縃縈縉縋縌縎縏縒縔縖ばく縟縣縥縧縩縪ぬい縭縵縷縸はなだもつれ縻總しげる繄繆繇繈繌繓つくろえ繖繗繘繙繜繧繨繩まゆ繲繷繸繺繻繾繿纀纂纇纊纋まとい纑纓纔纗纚纛ともづな缷缸缹缺缽缾缿罀罁罃ひび罇罈罉罎罏罐罔罕罛罥罨罪罱罷罻罼罽羃ひぐま羉羋羌美羒羗羚羝羞羡羧羭羮羯羰羳羵羸あつもの羺羻羼羽羾羿翀翁翂翃翅翇翉翊翋翌翍翎翏翐翑習しょう翕翗翛翜翝翞翟翠翡翢翣翥翦翧翨翩翪翫翬翭翯翰翱翲かげ翴翵翷翸翹翺こぼしつばさ翽翾翿耀老耄おいぼれ耆耋耍耎耒耔こう耖耗耘耙耛耜耞耟耠耡耤耥耦耨耩耪耬耭耮耯耰耱みみ耴耵耶耷耹耻耼耽耾耿聃聄聆聇聈聊聏聐聑聒联聕せい聘聚聛聜聝聞さとし聢聣聤聦聧聬聭聯さとし聱聲そびえ聵聶しょく聸聹聽聾肁肂肄肇肈肋はだ肏肒肓肕肖ひじ肙肚肛肜きも肟股肣肥肧肩肪肫肭肮肯肱そだてさかな肵肶肷肸はい肼肽胂胃胄胅きも胇胈胍胎胏胔胕胖胗胘胙胚胛胜胝胞胠胡たね胥胦胩胬胭胯胰胱胲胳どう胵胶むね胹胺胻胼のう脀脂脃脅もろわきみゃく脉脊脌脎脒脔脖脗脘脚ずね脝脞脟脡脢脣脤脥脧脩だつ脬脭脯脰脲脷脹脺脽脾腃腄腆腇腈腊わき腌腍じん腏腑腒腓腔腕腙腚腛腞腠腡腤腥のう腧腩しゅ腭腮腯腰けん腲腳腴腶腷腸はらせん腼腿膀膂膃膄膆膇膈膉膊膋膌膍あぶら膓膕膗膘膙膚膛膜ひざ膞膟にかわ膢膣膥膦膨膩膪膬膮膰膱膲ぜん膴膵膶膷膹膺膻膼きもなますうみしり臁臂臃臄臅臆臇臈臉臊臌臍臏臑臒臕臗臘臙臚臛臝臞臟臢臬しゅう臱臲致臻臿與舉舊舋舌ねぶ舑舔舚舛しゅん舝舞舠舡舢舥舦舨舩航舫般舭舯舲舳舴舵舶舷はやぶねせん舺舼舽舾舿艀艂艄艅艇艉艋艎艏艐艑艒艓艔艕艖艗そう艙艚艛艜艞艟艡艢艣艤艥艦艨艩とも艬艭艱艹艺艻艽艾艿芀芃芄芇芊いも芍芎芏芐芑芒芓芔芘芙芚芛しば芟芠芡芢芣芤あくたあし芧芨芩芪芫芬芭芮しん芰花よし芴芶芷芸せり芺芼芾芿苀苂苃苄苊苏苐苑苒苓こけ苕苗苘苙苛苜つと苟苠苡苢苣苤わかからむし苨苪とま苬苭苮苯苰英ふき苴苶苷苹いちご苻苽苾苿茀茁しげ范茄ちがや茆茇茈茉茋茌茖茗茘茚茛茜茝茞茢茤茥茧いばら茩茪茫茬茭茯茱茲茳茴しとねちゃ茷茸茹茺茼茽荀荂荃荄荅荇荈草荊荌荍荎荏荐荑荒荓荔荖荗荢荳荵荶荸荺おぎ荼荽荾荿莃莅莆莇莈莉そう莌莍莎莏莑莒いちご莔莕くき莘莙むしろ莛莜莝莞つぼみ莠莢莣莥莦莧たばこ莩莪莫莬莰莽莾莿菀菁菂菃かん菆菇菈菉きくきん菍菎菏菑菓菔菕菖すずな菙菛さい菝菞うさぎ菠菡菢菣菤菥菧菨菩菪すみれ菬菭菮華こもひし菲菳菴菵菶菷菸菹菺菻菼菽菾菿萁萃萄萅萆萇萉萊萋萌萍萎萏萐萑萒萓萔萖萘萛萜めぐむ萡萣はぎまん萭萮萯萰かや萲萳萴萵萶萷萸萹萺萻がく落萾萿葀葂葃葄葅葆葇葈葉葊葋葌葍むぐら葐葑葒葓葔葕葖著葘葙葚葛葜葝葞葟葠葡葢董葤葥あし葧葨葩葪にんにくそうかや葮葯葰葱葲葳葴葵葶葷葸葹葺葽葾葿蒀蒂蒄蒆蒈蒍蒎蒏蒐蒑蒒蒓蒔蒖蒗蒘蒙蒚蒛ひる蒝蒞蒟蒠蒡蒢蒣蒤蒧蒨蒩蒪蒫蒬蒭蒮蒯蒰蒱蒲蒴蒶ふけ蒹蒺蒻蒼蒽蒾蒿蓀蓁蓂蓄蓅むしろ蓇蓉蓊蓋蓌蓍蓎蓏蓐蓑蓒蓓蓔蓖蓗蓚蓛蓞蓡蓢蓤蓧蓨蓩蓪蓫よもぎはちす蓯蓰蓱蓲蓳蓴蓶蓷蓸蓹蓺蓻たで蓽蓾蓿蔀蔂蔃蔄蔅蔆蔇蔈蔉蔊蔋蔌蔍蔎蔏蔐蔑蔒蔓蔔蔕蔖蔗蔘蔙蔚蔛蔜蔝蔞蔟蔠蔡蔣蔤蔥蔦蔧蔨蔩蔪蔫蔬かげ蔮蔯蔰蔱蔳蔴蔸蔻蔽蔾蕀蕁蕂蕃蕄蕅蕆蕇蕈蕉しべしべ蕌蕍そば蕑蕒蕓蕔蕕蕖ふき蕘蕙蕚蕛蕜蕝蕞蕟蕠蕡蕢蕣蕤蕥蕦蕧わらびとろけかぶら蕫蕬しょう蕮蕯蕰蕱蕳蕵蕶蕷蕸蕹蕺蕻蕼蕾薀薁薂薃うす薅薆ぜんまい薈薉あざみ薋薌薍薎薏薐はじかみ薓薔薕薖その薘薙薚薛薜薝薞薟薠薡薢薣らっきょうこも薧薨薩薪いもかおる薱薳薴薵薶薷薸薹なずな薽薾薿藀わら藂藃藄藅藆藇藈藉藊藋あい藎藏藐藑藒藕藖藗藘藙藚藜げい藞藟藠藡藢藣ふじやく藦藨はんやぶ藫藬藭藮藯藰藱藲藶藷藸藹藼藽藾藿蘀蘁しべ蘄蘅あし蘉蘊蘋蘌蘍蘏蘐蘑蘓蘔ひこばえ蘗蘘蘙蘚蘛蘜蘞蘟蘠蘡蘢蘣蘤蘥蘦蘧蘨蘩蘪蘬らん蘮蘯蘱蘲蘳蘴蘵蘶蘸蘹蘺蘻蘼蘾蘿虀虂虃虅虆虇虈虋虌虍虎しいたげ虒虓けんしょ虖虙きょとりこおそれごう虠虡虢虣虤虥虧虨虩虪しらみ虴虻蚇蚋蚌蚍蚐蚗蚙蚜蚡蚣のみ蚩蚳蚷蚸蚽蛂蛉蛌蛖蛚蛩蛪蛷蛸もぬけ蜃蜄蜈蜌蜎蜑蜒蜙蜚蜣蜧蜩蜰蜲蜹蜻蜿蝂蝆蝎蝑蝓蝔蝕蝘蝙蝚蝛蝟蝡蝤蝧しらみ蝬蝮蝱蝳蝴蝵ちょう蝸蝹蝺螁螆螇螉螋螌螏螑螓螔螖螚螛螝螢螥螩螪螫螭螮螯螰螱螲螵螶螻螿蟂蟃ぶと蟉蟋蟌蟎蟒蟓蟕蟝蟠蟡蟣蟤蟥蟦蟧蟨蟮蟳蟶かに蟼蟾蠀蠂蠃蠄はえ蠆蠍蠏蠑蠓蠕蠖蠗蠛蠟蠡蠣蠤蠥蠦蠨蠪蠬蠭蠮蠳蠵かいこ蠸衁衂衄衈衊じゅつ衚衪衯衱衲衽ふすまえり袀袂袊袕袘袚袛袞袲袵袶袽きれ裊裎裐裒裔裖裗裘裞裧裬裯裲裴裵裶裹裺裻複褉褊褋褐褒褓褕褗褘褙褞褟褡褢しとね褦褧褨褩褪褫褬褮褰褳褵褶褸褹褼褽褾襁襆襐襑襔ふすま襙襚襛襜えり襤襥襦襪襬襮襯襰襱襲襵襷襹襺襼要覅覆覑覝覢覣覤覦おや覮覷覹覽覾觀かく觓觔觕觖觗觙觚觛觜觝觟觠觡觢かい觤觥触觧觨觩觫觬觭觮觰觱觲觳觴觶觷觸觺觻觼觾觿訑訒託なまりいぶか訟訣訥訴訹訾訿詅詆詉詎詙詡詣わびかい詴詶詹詺詼誃誄認誒誕さそえ誚誜誝誤せつ誫誹調ちょうだん諈諉請諍諏諑諕諗諜諝諞諡諧諭はかいみな諲諶諷諺だく諿謀謁謂謆謊謋謍なぞ謏謑謒謔謕謖しゃうたい謣謤謥謦謧謨謪謬謯謰謱謳謵謷謻謼謽謾譀譁譃譅譎譏譐譒譔譕譖譗譝譟譢譥警譨譪譫譭譴まもる譺譽譾譿讁讂さん讅讈讋讌讒讔讘讙讛讞谻谽谾豁豂豃豅豋豌豖ぶた豟象豦豫豬豯豱豽貁貐貓貔貕貗ばく貙貛貤貧貨販貪貲貾賁賃まかないにぎわい賒賕賙賛賝賧賨賲よりゆき賻贀ぜい贆贌贍贏贙贜おこり赹赺赽趆趍趐趑趓趔趙趜趢おもむき趥趦趪趮趯趴趹趻趿跅跉跋跐跚跜距跢跧跫跱跺踂踃踆踍踒踗踘踙踛踜踠踥踭踰踴踸踻踽蹀蹁蹂蹅蹆蹉蹊蹋蹌蹏蹐蹕蹗蹙蹛蹡蹣蹥蹨蹩蹯つくばい蹷蹸みずかき躁躂躆躇躉躌躍躐躑躒躔躘躚躞躠躡躤躥躧躨躪躬躭躮躯からだ躲躳躶躹躺躼躽軀軁軂軃軉軔軜軠軡軧軨軮軱軶軷輇輎輒輖輘輙輛輞輤輥輦輩輫輭輮輯輳輴輵輶輸輹轃轄轆轇轋轍轐轓轔轕轗轜轝轞轢轣轤辨たつはずかしめのう辳辴辶辷辸边つじこみ达辿迁迂まで迅迆迉迊迋迌迍迎迏运きん迒迓かえし迕迖迗迚迠迡迢迣迤迥迦迨すすむさこ迭迮じゅつ迴迵迶迷迸迹迺迻迼つい迾迿退すさおく适逃逄逅ぎゃく逈逋逌逍とおる逐逑递途逕逖逗這どおり逛逜逝逞そくづくり逡逢れん逤逭逮逯しゅうしん逳逴逵逶逷逸逼逽逾逿遁遂遄遆ぐう遉遊うん遌遍遏遐遑遒どうたちたがえ遖遘はるか遚遛遜遝遞とおさかのぼ遢遣遤遧遨適遫遬遭遮遯遰おそ遳遴遵遶遷選遹遺遻遼遽遾避邀邁邂邃還邅邆邇邈邋邍邏邐邙邦よこしま邳邶てい邿郁郔郘郢郩郪郬郮郯郰郵郺郾鄀鄁鄃鄄鄅鄋鄏鄑鄘鄙鄚鄝鄠鄡鄤鄦鄩鄬てい鄯鄰鄳鄴鄵鄸鄹鄺鄾鄿酀酁酃酄酅酇酈酉酊酋しゃくはい酎酏酐酑しゅ酓酕酖酗酘酙酚酜酞酟酠酡たけなわ酤酥酧酨酩酪むくい酮酯酰酲酳酴酵酶こくさん酹酺酼醀醁醂醃醄醅醆あつしよい醊醋醌醍醎醏醐醑醒醓醙醚醛醜醝醞醟醠醡醢醣醥醧醨醩醪醬醭醮醯醰醱醲醳醴醵醶醷醹醺醻醼醽醾釀釁釂釃釄釅釉釋釐釶釸釹釽釾鈆鈉鈌鈐鈑鈒鈓鈕鈖鈚ひとし鈥鈭鈮鈴鈸鉅なまり鉠鉥鉯鉹鉺銂じゅう銇銋銎銏銓銘銠銣銤銨銩銪銮銳銵銶銷銹鋁鋄鋆鋋鋑鋗鋘鋟鋠鋡鋣鋥鋩鋷鋺錂ろくさび錑錓錕錖おもり錚錜錝錟錥錨錭錴錵錹錼鍇鍈鍋鍏鍐鍑鍒鍖鍣鍤鍥鍦鍨鍩鍫くわ鍭鍱鍳鍻鎀鎁鎂鎈鎉鎎鎏鎐鎒鎗鎙鎚鎛鎜鎝鎞鎟鎣鎥鎩鎪鎳鏂鏃鏅鏈鏊鏋鏌鏎鏏鏐鏕鏖鏘鏝鏞鏟鏠鏢ちりばめ鏬鏮鏵鏶鏷鏹鏻鏼鏾鏿鐄鐇鐉鐌鐍鐏鐒鐕鐖鐥鐩鐪鐭鐯鐰鐳てつ鐷鐹鐻鐼鐽鑀鑃鑅鑉鑊鑐鑑鑒鑗こう鑝鑞鑠鑢鑣鑤鑧鑨たたら鑬鑮鑱鑴鑵鑶鑷鑹鑿钀镇閣ごう閦閭閱閷閹閼闀闉闋闑闒闙闞闟闥阤ばん阰阺阾陁陊降陏陖陛陝陫陬かげ陱陲りょうりく陻陾隁隃すみ隇隉ずいかいずい隗隙ぎわ隞隡となり隧隨隩隱隳隴隶隸雂雅しゅうやとい雕雗雘雚ざつ雟雡はなれ雩雪雯雰雱雲雴雵れいかみなり雸雹雺電雽雿需霂霃霄霅霆ふるえ霈霉霋霍霎霏霐霑霒霓霖霘霙霛しも霝霞霟霠霡霢霣霤霥霦きり霨霩霪霫霬霮霯霰霱露霴霵霶霸霹霺霽霾霿靀靁靂靃靄靆靇れい靉靊靋青やすし靘靚靛靜靟靠靡靨うつぼ靲靴靸靹鞅鞍鞏鞓鞗鞘鞙鞚きく鞢鞣鞦鞨鞳鞶鞸鞻鞾鞿韂韃韄韆韈韉韌韍かん韖韘韙韛韞韠韡韮韰韵韺韽頀領頛頞頨頯頷顃顄顅顈顒顙顝るい顟顠顢顧顬顱顲顳顴風颩颬颭颮颯颰颱颲颳颴颶颷颸颹颺颻颼颽颾颿飀飁飂飃飄飆飇飈飉飊飋飌しょく飠飡かつえ飣飥飦飧飩飪飫飬飭飯飱飲あめ飵飶飹飺飼飽かざり餀餂餃餅餇餈餉養えさ餎餐餑餒かつえ餔餕餖餗あまり餙餚餛餜はなむけ餟餡餤餥餧館餩餪餫餬餭餮餯餰餱餲餳餵餷餸餹餺餻餼餽餾餿饀饁饂饃饅饇饈饉饊饋饌饍饎饏饐ひだるにょう饓饔饕饖きょう饘饙饛饜饝饞饟饡饢香馛馜馠馡馣馤馥馧かおる馫馲はせ馺馿駂駃えき駌駏駑駓駖駚駩駬駸駹駽駾駿しゅん騃騄騆騉騐騑騔騕騙騚騞騣騤騥騧騩騪騬騱騲騴騷騸騼騽驀驁驃驄驅驆驈驉驊驎驖驘驚驟驠うさぎうま驥驦驧驨驩驪こつ骪骫骬骭骮骯骰骱骳骴骵骶骷骸骹骺骻骼骽骾骿髀髁髂髃髄髆髇髈髊髍髏髐髑髒髓たい髕髖髗髢髬髭かみ髶髾鬃鬆鬇鬉鬋鬌鬍鬏鬐鬔鬕鬗かずら鬞鬣鬫鬭くじ鬯鬳鬵鬷鬻鬼鬽鬾鬿魀さきがけたましい魃魄魆魈魊魋魌魍魎魏魐魑魒魔魕魖魗魘魙魠魤魥魬魲魵魶魾魿鮁鮆鮟鮤ずしまぐろ鮵鮹鮿鯀鯄鯈鯓鯖鯗鯚たい鯜鯞にしん鯤鯥鯦鯪鯫鯰しゃち鯳鯴鯸鰅鰇鰈鰋鰌かじかふぐ鰗鰠鰣鰥鰦鰨鰩鰬ひれいわし鰱鰲鰵鰶鰷鰻鰼鰾鱀鱁鱃鱈鱊鱋鱌鱒鱔鱕うろこ鱘鱢鱦鱨鱮鱱鱲鱳鱴鱵ふかすずき鱹鱺ばと鳹鴂鴃鴄鴅鴇からす鴒鴛みみずく鴥鴦鴱鴳鴷鴽鵀鵃鵉鵎鵑鵔鵖鵚いかる鵦鵰鵱鵳鵴鵵鵷鵼鶄鶈鶌鶐鶓鶔鶖鶘鶛鶜鶞鶟鶠鶡鶣鶦鶧鶬うぐいすひたき鶷鶸鶺鶻鶾鷀はいたか鷃鷅鷈鷉鷋鷐鷔鷖鷗鷚鷛鷜鷝鷟鷡鷥鷨鷬鷰鷲鷵鷷しぎ鸁鸅鸆鸌鸏鸐鸒鸔鸕鸗鸘鸚こうのとり鸝鹺鹿しか麀麁麂麃麄麅麆麇麈麉麊麋麌麍麎麐麑麓麔麕麖麗麘麙麚麛麜麝麞麟麠麡麢麤むぎ麧麩麪麫麬麭麮麯麰麱麴麵麶麷あさ麼麽麾麿黀黁黂黃黅黆黇黈黌黍はじむ黏黐黓黔黖默黚黜黝點黟黢黤黥黦黫黭黮黰黲黳黴黵黶黷黸黹黺黻黼黽黿鼀鼁鼂鼆鼇鼈鼉鼊鼘鼙鼛鼜鼞鼠鼢鼣鼤鼥鼦鼧鼨鼩鼪鼫いたち鼭鼮鼯鼰鼱鼲鼳鼴鼵鼶鼷鼸鼹齀齂齃齄齅齇齈とき齌齍齎齏齓齔齕齖齗齘齙齚齛齜齝齞齟齠よわいよわいこま齥齦齧齩齪齫齬齮齯齰齱齲齴齵齶齷齸齹齺齻齾りゅう龐龑龒龔がん龗龘かめ龟龣龤鿓鿛鿢鿣鿤鿦鿨鿫𠂊𠘑𠣽𠪚𠭤𠮟𠹭𡌶𡐓𡑒𡪯𢆕𢕭𢯽𢹂𣊟𣕚𣗎𣜿𣳾𤋮𤺍𥕢𥕵𥧌𥴊𥻗𥻘𥼲𥾵𦉪𦍌𦐂𦗪𦙀𦤇𦥑𦪧𦰡𧄍𧗐𧪄𧿨𨅺𨥉𨨩𨸶𩍉𪊲𫶔𭅞𭗐𭴼𮡜𰻞𱁬"


-- Change one variant character to another variant character.
-- Change one variant character to another variant character.
Line 23: Line 31:
function export.change_to_variant(text)
function export.change_to_variant(text)
local count = 0
local count = 0
local text = mw.ustring.gsub(text, ('([%s])'):format(chars_variant_both), function(char)
local text = gsub(text, ('([%s])'):format(m_data.chars_variant_both), function(char)
count = count + 1
count = count + 1
if (count > 1) then return '' end -- add |t2= manually, please
if (count > 1) then return '' end -- add |t2= manually, please
local this_char_index = mw.ustring.find(chars_variant_both, char)
local this_char_index = find(m_data.chars_variant_both, char)
local first_or_second = (this_char_index % 2)
local first_or_second = (this_char_index % 2)
local other_char_index = this_char_index + (first_or_second == 1 and 1 or -1)
local other_char_index = this_char_index + (first_or_second == 1 and 1 or -1)
return mw.ustring.sub(chars_variant_both, other_char_index, other_char_index)
return sub(m_data.chars_variant_both, other_char_index, other_char_index)
end)
end)
return (count == 1 and text or '')
return (count == 1 and text or '')
end

local zh_link_impl = nil
local function zh_link(...)
if zh_link_impl == nil then
zh_link_impl = require("Module:zh/link")
end
return zh_link_impl.link(unpack(arg))
end
end


Line 39: Line 55:
["s"] = { list = true },
["s"] = { list = true },
["t"] = { list = true },
["t"] = { list = true },
["ss"] = {}, ["ns"] = {}, ["alt"] = {}, ["type"] = {}, ["delink"] = {}, ["lit"] = {}, ["note"] = {}, ["gloss"] = {}
["ss"] = {}, ["ns"] = {}, ["alt"] = {}, ["type"] = {}, ["delink"] = {}, ["lit"] = {}, ["note"] = {}, ["gloss"] = {}, ["align"] = {}
}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local args = require("Module:parameters").process(frame:getParent().args, params)
Line 45: Line 61:
local s, t = {}, {}
local s, t = {}, {}
local annotation = {}
local annotation = {}
local pagename = mw.loadData("Module:headword/data").pagename
local current_title = mw.title.getCurrentTitle()
local content = current_title:getContent()
if not frame:getParent().args["t"] then
if not frame:getParent().args["t"] then
table.insert(t, 1, mw.title.getCurrentTitle().subpageText)
insert(t, 1, current_title.subpageText)
end
local PAGENAME = mw.title.getCurrentTitle().text
local content = mw.title.new(PAGENAME):getContent()
local function insert_st(set, text)
table.insert(set, text)
end
end
for i = 1, #args.s do
for i = 1, #args.s do
if (#args.s == 1) and PAGENAME == args.s[i] then error('Redundant text in |s=.') end
if (#args.s == 1) and pagename == args.s[i] then error('Redundant text in |s=.') end
insert_st(s, args.s[i])
insert(s, args.s[i])
end
end
for i = 1, #args.t do
for i = 1, #args.t do
if (#args.t == 1) and PAGENAME == args.t[i] then error('Redundant text in |t=.') end
if (#args.t == 1) and pagename == args.t[i] then error('Redundant text in |t=.') end
insert_st(t, args.t[i])
insert(t, args.t[i])
end
end
local t1 = t[1]
local t1_len = len(t1)
-- temp tracking
-- temp tracking
if #s == 0 and (gsub(t[1], '.', require("Module:zh/data/ts").ts)) ~= t[1] then
if #s == 0 and require("Module:zh").ts(t1) ~= t1 then
require('Module:debug').track('zh-forms/entry possibly missing a simplified form')
require('Module:debug').track('zh-forms/entry possibly missing a simplified form')
end
end
if #t == 1 then
if #t == 1 then
local to_variant = export.change_to_variant(t[1])
local to_variant = export.change_to_variant(t1)
if (to_variant ~= '') then
if (to_variant ~= '') then
-- automatically generate a |t2=
-- automatically generate a |t2=
insert_st(t, export.change_to_variant(t[1]))
insert(t, export.change_to_variant(t1))
elseif find(t[1], ('[%s]'):format(chars_variant_both .. chars_variant_one)) then
elseif find(t1, ('[%s]'):format(m_data.chars_variant_both .. m_data.chars_variant_one)) then
require('Module:debug').track('zh-forms/entry possibly missing a variant form')
require('Module:debug').track('zh-forms/entry possibly missing a variant form')
end
end
Line 82: Line 99:
if #t ~= 1 and #s == 0 then
if #t ~= 1 and #s == 0 then
table.insert(s, t[1])
insert(s, t1)
end
end


local function asterisk(term, iscomp)
local function asterisk(term, iscomp)
if iscomp and len(t[1]) > 1 then return "" end
if iscomp and t1_len > 1 then return "" end
if term == mw.title.getCurrentTitle().subpageText or not (mw.title.new(term) or {}).exists then return "" end
if term == current_title.subpageText or not (new_title(term) or {}).exists then return "" end
local content = mw.title.new(term):getContent()
local content = new_title(term):getContent()
content = gsub(content, "zh%-pron", "Ꙁ")
content = gsub(content, "zh%-pron", "Ꙁ")
content = gsub(content, "zh%-see", "Ꙁ")
content = gsub(content, "zh%-see", "Ꙁ")
content = gsub(content, "[^Ꙁ]", "")
content = gsub(content, "[^Ꙁ]", "")
return mw.ustring.len(content) > 1 and '<sup><span class="explain" title="This form has one or more other meanings.">*</span></sup>' or ''
return len(content) > 1 and '<sup><span class="explain" title="This form has one or more other meanings.">*</span></sup>' or ''
end
end


Line 110: Line 127:
local function header(length, var_count)
local function header(length, var_count)
return ((length > 3 or var_count * length > 5) and '{|' or '{| align=right') ..
return ((length > 3 or var_count * length > 5 or args.align == 'left') and '{|' or '{| class="floatright"') ..
' style="clear: right;margin: 1em;border-collapse: collapse;text-align: center"' ..
' style="clear: right;margin: 1em 0 1em 1em;border-collapse: collapse;text-align: center"' ..
(length ~= 1 and '\n|-\n! colspan=2|' or '')
(length ~= 1 and '\n|-\n! colspan=2|' or '')
end
end
Line 118: Line 135:
return '\n! style="padding: 0.' .. (length > 8 and '3' or '5') ..
return '\n! style="padding: 0.' .. (length > 8 and '3' or '5') ..
'em;border: 1px solid #aaa;background:#F5F5DC;font-weight: normal;font-size: 85%; width:' ..
'em;border: 1px solid #aaa;background:#F5F5DC;font-weight: normal;font-size: 85%; width:' ..
(length <= 8 and (30 * word + 30) or (25 * word + 25)) .. 'px" colspan=' .. (colspan or 1) ..'|'
(length <= 8 and (40 * word + 40) or (25 * word + 25)) .. 'px" colspan=' .. (colspan or 1) ..'|'
end
end


Line 124: Line 141:
local fmtd_text = {}
local fmtd_text = {}
for i,value in ipairs(text) do
for i,value in ipairs(text) do
fmtd_text[i] = links.language_link({ lang = lang.getByCode("zh"), term = value }) .. asterisk(value, false)
fmtd_text[i] = links.language_link{ lang = lang.getByCode("zh"), term = value } .. asterisk(value, false)
end
end
return length ~= 1 and ((length > 8 and '' or '<span style="font-size:140%">') ..
return length ~= 1 and ((length > 8 and '' or '<span style="font-size:140%">') ..
'(<span lang="zh-' .. sc[script] .. '" class="' .. sc[script] .. '">' .. table.concat(fmtd_text, "/") .. '</span>)' ..
'(<span lang="zh-' .. sc[script] .. '" class="' .. sc[script] .. '">' .. concat(fmtd_text, "/") .. '</span>)' ..
(length > 8 and '' or '</span>')) or ''
(length > 8 and '' or '</span>')) or ''
end
end
local function char_fmt(text, length, script)
local function char_fmt(text, length, script)
return (#text ~= 1 and (char_gap(length, script) .. table.concat(text, char_gap(length, script), 1, #text-1)) or '') .. char_gap(length, script, true) .. text[#text]
return (#text ~= 1 and (char_gap(length, script) .. concat(text, char_gap(length, script), 1, #text-1)) or '') .. char_gap(length, script, true) .. text[#text]
end
end
local test_word = t[1]
local length = len(test_word)
local word_division = {}
local word_division = {}
local i = 1
local i = 1
Line 143: Line 158:
if comp_type then
if comp_type then
for index in mw.text.gsplit(comp_type, "", true) do
for index in mw.text.gsplit(comp_type, "", true) do
if find(mw.ustring.sub(test_word, i, i), '[,%-]') then
if find(sub(t1, i, i), '[,%-]') then
table.insert(word_division, { i, i } )
insert(word_division, { i, i } )
i = i + 1
i = i + 1
elseif mw.ustring.sub(test_word, i, i) == '…' then
elseif sub(t1, i, i) == '…' then
table.insert(word_division, { i, i + 1 } )
insert(word_division, { i, i + 1 } )
i = i + 2
i = i + 2
end
end
table.insert(word_division, { i, i + index - 1 } )
insert(word_division, { i, i + index - 1 } )
i = i + index
i = i + index
end
end
if i - 1 ~= len(gsub(test_word, '…+$', '')) and not find(table.concat(t) .. table.concat(s), "[⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻]") then
if i - 1 ~= len(gsub(t1, '…+$', '')) and not find(concat(t) .. concat(s), "[⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻]") then
error("'type' parameter does not match word length.")
error("'type' parameter does not match word length.")
end
end
else
else
for i = 1, length do
for i = 1, t1_len do
table.insert(word_division, { i, i } )
insert(word_division, { i, i } )
end
end
decomposable = len(gsub(test_word, '…+$', '')) > 2 and true or false
decomposable = len(gsub(t1, '…+$', '')) > 2 and true or false
end
end
Line 184: Line 199:
local char_string = ""
local char_string = ""
for j = 1, #id do
for j = 1, #id do
local word_form = mw.ustring.sub(id[j], position[1], position[2])
local word_form = sub(id[j], position[1], position[2])
if not find(char_string, word_form) then
if not find(char_string, word_form) then
char_string = (char_string ~= "" and (char_string .. '/') or "") .. word_form
char_string = (char_string ~= "" and (char_string .. '/') or "") .. word_form
Line 192: Line 207:
local hash = {}
local hash = {}
for thing in mw.text.gsplit(char_string, (delink[i] and "" or "/")) do
for thing in mw.text.gsplit(char_string, (delink[i] and "" or "/")) do
table.insert(hash, links.language_link({ lang = lang.getByCode("zh"), term = thing }) .. asterisk(thing, true))
insert(hash, links.language_link{ lang = lang.getByCode("zh"), term = thing } .. asterisk(thing, true))
end
end
char_string = table.concat(hash, (delink[i] and "" or "/"))
char_string = concat(hash, (delink[i] and "" or "/"))
end
end
table.insert(char_set[id.name], char_string)
insert(char_set[id.name], char_string)
end
end
for _, item in ipairs(id) do
for _, item in ipairs(id) do
if not (mw.title.new(item) or {}).exists and item ~= mw.title.getCurrentTitle().subpageText then
if not (new_title(item) or {}).exists and item ~= current_title.subpageText then
table.insert(uncreated, '"[[' .. item .. ']]"')
insert(uncreated, '"[[' .. item .. ']]"')
end
end
end
end
end
end

local scripts = { ['いち-鿿㐀-䶿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩𠀀-𪛟𪜀-𮯯𰀀-𱍏'] = 'Hani' , ['a-zA-ZāēīōūĀĒĪŌŪa-zA-Z'] = 'Latn', ['0-90-9'] = 'Numb', ['Ͱ-Ͽ'] = 'Grek' }
local scripts = { [m_scripts.getByCode("Hani"):getCharacters()] = "Hani" , [m_scripts.getByCode("Latn"):getCharacters()] = "Latn", ["0-90-9"] = "Numb", [m_scripts.getByCode("Polyt"):getCharacters()] = "Grek", [m_scripts.getByCode("Bopo"):getCharacters()] = "Bopo" }
local script = {}
local script = {}
for range, script_name in pairs(scripts) do
for range, script_name in pairs(scripts) do
if find(test_word, '[' .. range .. ']') then
if find(t1, '[' .. range .. ']') then
table.insert(script, script_name)
insert(script, script_name)
end
end
end
end


if find(t[1], "([^─…]+)%1") and args['gloss'] ~= '-' and len(t[1]) < 7 then
if find(t1, "([^─…]+)%1") and args['gloss'] ~= '-' and t1_len < 7 then
if gsub(comp_type or "", "1", "") == "" then
if gsub(comp_type or "", "1", "") == "" then
table.insert(annotation, '[[Category:Chinese reduplications]]')
insert(annotation, '[[Category:Chinese reduplications]]')
elseif find(t[1], "([^…][^…]+)%1") or find(table.concat(char_set['trad'], " "), "([^─…%[%]a-z]+)%1") then
elseif find(t1, "([^…][^…]+)%1") or find(concat(char_set['trad'], " "), "([^─…%[%]a-z]+)%1") then
local evil
local evil
for _, component in ipairs(char_set['trad']) do
for _, component in ipairs(char_set['trad']) do
if len(component) > 1 then
if len(component) > 1 then
local comp_content = mw.title.new(links.remove_links(component)):getContent() or false
local comp_content = new_title(links.remove_links(component)):getContent() or false
if not comp_content or find(comp_content, "|gloss=-") or not find(comp_content, "==Chinese==") then
if not comp_content or find(comp_content, "|gloss=-") or not find(comp_content, "==Chinese==") then
evil = true
evil = true
Line 226: Line 241:
end
end
end
end
if not evil then table.insert(annotation, '[[Category:Chinese reduplications]]') end
if not evil then insert(annotation, '[[Category:Chinese reduplications]]') end
end
end
end
end


table.insert(annotation, #script > 1 and '[[Category:Chinese terms written in multiple scripts]]' or nil)
insert(annotation, #script > 1 and '[[Category:Chinese terms written in multiple scripts]]' or nil)
table.insert(annotation, (decomposable and args['gloss'] ~= '-' and not args['note'] and not args['lit']) and '[[Category:Chinese entries with potentially decomposable titles]]' or nil)
insert(annotation, (decomposable and args['gloss'] ~= '-' and not args['note'] and not args['lit']) and '[[Category:Chinese entries with potentially decomposable titles]]' or nil)
table.insert(annotation, (#uncreated > 0 and mw.title.getCurrentTitle().nsText == "") and '[[Category:Chinese terms with uncreated forms]]' ..
insert(annotation, (#uncreated > 0 and current_title.nsText == "") and '[[Category:Chinese terms with uncreated forms]]' ..
'<small class="attentionseeking">(' .. (#uncreated == 1 and 'This form' or 'These forms') ..
'<small class="attentionseeking">(' .. (#uncreated == 1 and 'This form' or 'These forms') ..
' in the hanzi box ' .. (#uncreated == 1 and 'is' or 'are') .. ' uncreated: ' ..
' in the hanzi box ' .. (#uncreated == 1 and 'is' or 'are') .. ' uncreated: ' ..
table.concat(uncreated, ", ") .. '.)</small>' or nil)
concat(uncreated, ", ") .. '.)</small>' or nil)
local ss = ""
local ss = ""
if args["ss"] then
if args["ss"] then
ss = var_fmt(length, 'FFFFE0') .. '[[w:Second round of simplified Chinese characters|2nd round simp.]]' .. mw.ustring.sub(char_gap(length, 'simp', true), 1, -45)
ss = var_fmt(t1_len, 'FFFFE0') .. '[[w:Second round of simplified Chinese characters|2nd round simp.]]' .. sub(char_gap(t1_len, 'simp', true), 1, -45)
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. ' colspan="' .. #word_division .. '"|' .. m_zh.link(nil, nil, { args["ss"], tr = "-" }, mw.title.getCurrentTitle().subpageText)
.. ' colspan="' .. #word_division .. '"|' .. zh_link(nil, nil, { "*" .. args["ss"], tr = "-" }, current_title.subpageText)
end
end
local ns = ""
local ns = ""
if args["ns"] then
if args["ns"] then
ns = var_fmt(length, 'FFFFE0') .. 'nonstandard simp.' .. mw.ustring.sub(char_gap(length, 'simp', true), 1, -45)
ns = var_fmt(t1_len, 'FFFFE0') .. 'nonstandard simp.' .. sub(char_gap(t1_len, 'simp', true), 1, -45)
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. ' colspan="' .. #word_division .. '"|' .. m_zh.link(nil, nil, { args["ns"], tr = "-" }, mw.title.getCurrentTitle().subpageText)
.. ' colspan="' .. #word_division .. '"|' .. zh_link(nil, nil, { "*" .. args["ns"], tr = "-" }, current_title.subpageText)
end
end
Line 257: Line 272:
local altdecomp = mw.text.split(altform, ":")
local altdecomp = mw.text.split(altform, ":")
local altdecomp2 = mw.text.split(altdecomp[1], "-")
local altdecomp2 = mw.text.split(altdecomp[1], "-")
altdecomp3 = altdecomp2[2] and ' <span style="font-size:70%"><i>' .. gsub(altdecomp2[2], "‡", frame:expandTemplate{
local altdecomp3 = altdecomp2[2] and ' <span style="font-size:80%"><i>' .. gsub(altdecomp2[2], "‡", frame:expandTemplate{
title = "Template:zh-historical-dict",
title = "Template:zh-historical-dict",
args = { type = "form", nocat = "1" }
args = { type = "form", nocat = "1" }
}) .. '</i></span>' or ''
}) .. '</i></span>' or ''
table.insert(altform_list, '<span style="white-space:nowrap;">' ..
insert(altform_list, '<span style="white-space:nowrap;">' ..
m_zh.link(nil, nil, { altdecomp2[1], tr = (altdecomp[2] or "-") }, mw.title.getCurrentTitle().subpageText) ..
zh_link(nil, nil, { altdecomp2[1], tr = (altdecomp[2] or "-") }, current_title.subpageText) ..
altdecomp3 .. '</span>')
altdecomp3 .. '</span>')
end
end
if #altform_list > 5 then
if #altform_list > 5 then
altforms = '<div class="vsSwitcher" data-toggle-category="Chinese alternative forms"><span class="vsToggleElement">&nbsp;</span>' ..
altforms = '<div class="vsSwitcher" data-toggle-category="Chinese alternative forms">' ..
'<div class="vsShow">' .. table.concat(altform_list, "<br>", 1, 5) ..
'<div class="vsShow">' .. concat(altform_list, "<br>", 1, 5) ..
'</div><div class="vsHide">' .. table.concat(altform_list, "<br>") .. '</div></div>'
'</div><div class="vsHide">' .. concat(altform_list, "<br>") .. '</div><span class="vsToggleElement" style="display:block;width:fit-content;margin:auto">&nbsp;</span></div>'
else
else
altforms = table.concat(altform_list, "<br>")
altforms = concat(altform_list, "<br>")
end
end
altforms = var_fmt(length, 'F0FFE0') .. 'alternative forms' .. mw.ustring.sub(char_gap(length, "trad", true), 1, -45)
altforms = var_fmt(t1_len, 'F0FFE0') .. 'alternative forms' .. sub(char_gap(t1_len, "trad", true), 1, -45)
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. ' colspan="' .. #word_division .. '"|' .. altforms
.. ' colspan="' .. #word_division .. '"|' .. altforms
end
end
local anagram = ""
local anagrams = ""
if len(t[1]) == 2 and not find(t[1], "(.)%1") then
if t1_len >= 2 and t1_len <= 5 then
local anagram_link = mw.ustring.sub(t[1], 2, 2) .. mw.ustring.sub(t[1], 1, 1)
local function generate_anagrams(term, n, anagrams, checked)
local anagram_content = mw.title.new(anagram_link):getContent() or false
if n == 0 then
if anagram_content and find(anagram_content, "==Chinese==") then
local anagram = concat(term)
anagram = var_fmt(length, 'F0FFE0') .. 'anagram' .. mw.ustring.sub(char_gap(length, 'trad', true), 1, -45)
if checked[anagram] then
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
return
.. ' colspan="' .. #word_division .. '"|' .. m_zh.link(nil, nil, { anagram_link, tr = "-" }, mw.title.getCurrentTitle().subpageText)
end
local title = new_title(anagram)
if not title then
return
end
title = title:getContent()
if title and get_section(title, "Chinese", 2) then
insert(anagrams, anagram)
end
checked[anagram] = true
else
for i = 1, n do
generate_anagrams(term, n - 1, anagrams, checked)
local i = n % 2 == 0 and i or 1
term[i], term[n] = term[n], term[i]
end
end
return anagrams
end
local term, checked = explode(t1), {[t1] = true}
anagrams = generate_anagrams(term, #term, {}, checked)
local anagrams_num = #anagrams
for i = 1, anagrams_num do
anagrams[i] = "<span style=\"white-space:nowrap;\">" ..
zh_link(nil, nil, {anagrams[i], tr = "-"}, current_title.subpageText) ..
"</span>"
end
if anagrams_num == 0 then
anagrams = ""
else
anagrams = concat(anagrams, "<br>")
local label = anagrams_num == 1 and "anagram" or "anagrams"
anagrams = var_fmt(t1_len, 'F0FFE0') .. label .. sub(char_gap(t1_len, "trad", true), 1, -45)
.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
.. ' colspan="' .. #word_division .. '"|' .. anagrams
end
end
end
end
local literal = (args["lit"] or args["note"]) and '\n|-' ..
local literal = (args["lit"] or args["note"]) and '\n|-' ..
gloss_fmt(length, #word_division + 2, length) ..
gloss_fmt(t1_len, #word_division + 2, t1_len) ..
(args["lit"] and '<i>Literally:</i> “' .. args["lit"] ..
(args["lit"] and '<i>Literally:</i> “' .. args["lit"] ..
(find(args["lit"], "%.$") and "”" or "”.") or args["note"]) or ""
(find(args["lit"], "%.$") and "”" or "”.") or args["note"]) or ""
Line 295: Line 348:
local gloss = {}
local gloss = {}
if args['gloss'] == '-' then
if args['gloss'] == '-' then
gloss = { gloss_fmt(length * 1.6, #word_division, length) .. '<i>phonetic</i>' }
gloss = { gloss_fmt(t1_len * 1.6, #word_division, t1_len) .. '<i>phonetic</i>' }
elseif length == 1 then
elseif t1_len == 1 then
gloss = {}--{ gloss_fmt(1.6, #word_division) .. '-' }
gloss = {}--{ gloss_fmt(1.6, #word_division) .. '-' }
else
else
for i, position in ipairs(word_division) do
for i, position in ipairs(word_division) do
local character = mw.ustring.sub(t[1], position[1], position[2])
local character = sub(t1, position[1], position[2])
local gloss_text = args[1][i]
local gloss_text = args[1][i]
Line 325: Line 378:
}
}
end)
end)
if gloss_text == "" and find(character, "^[いち-鿿㐀-䶿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩]+$") and not find(glosses.nonlemma, character) then
if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") and not find(glosses.nonlemma, character) then
require('Module:debug').track('zh-forms/no gloss found for Chinese character')
require('Module:debug').track('zh-forms/no gloss found for Chinese character')
end
end
Line 340: Line 393:
]]
]]
if find(gloss_text, "-", nil, true) then
if find(gloss_text, "-", nil, true) then
gloss_text = gsub(gloss_text, "^%-", nonbreaking_hyphen)
local nonbreaking_hyphen = mw.ustring.char(0x2011)
gloss_text = mw.ustring.gsub(gloss_text, "^%-", nonbreaking_hyphen)
gloss_text = gsub(gloss_text, "(%s)%-", "%1" .. nonbreaking_hyphen)
gloss_text = mw.ustring.gsub(gloss_text, "(%s)%-", "%1" .. nonbreaking_hyphen)
end
end
if gloss_text == "" and position[2] > position[1] then
if gloss_text == "" and position[2] > position[1] then
local senses = {}
local content = new_title(character):getContent() or false
local content = mw.title.new(character):getContent() or false
if content then
if content then
gloss_text = m_zh.extract_gloss(content, false)
gloss_text = require("Module:zh/extract").extract_gloss(content, false)
if gloss_text == "" and find(character, "^[いち-鿿㐀-䶿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩]+$") then
if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") then
require('Module:debug').track('zh-forms/no gloss found but entry exists')
require('Module:debug').track('zh-forms/no gloss found but entry exists')
end
end
--[[
if not string.match(content, character) then
if not string.match(content, character) then
require('Module:debug').track('zh-forms/compounds not mentioned in derived terms on the component pages')
require('Module:debug').track('zh-forms/compounds not mentioned in derived terms on the component pages')
end
end
]]--
else
else
if gloss_text == "" and find(character, "^[いち-鿿㐀-䶿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩]+$") then
if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") then
table.insert(annotation, '[[Category:Chinese redlinks/zh-forms]]')
insert(annotation, '[[Category:Chinese redlinks/zh-forms]]')
end
end
end
end
Line 366: Line 419:
gloss_text = gsub(gloss_text, ";+", ";")
gloss_text = gsub(gloss_text, ";+", ";")
if len(gsub(gloss_text, '[^;]', '')) > 2 then
if len(gsub(gloss_text, '[^;]', '')) > 2 then
gloss_text = '<div class="vsSwitcher" data-toggle-category="glosses"><span class="vsToggleElement">&nbsp;</span><div class="vsShow">' ..
gloss_text = '<div class="vsSwitcher" data-toggle-category="glosses"><div class="vsShow">' ..
match(gloss_text, '^[^;]+;[^;]+;[^;]+') .. '</div><div class="vsHide">' .. gloss_text .. '</div></div>'
match(gloss_text, '^[^;]+;[^;]+;[^;]+') .. '</div><div class="vsHide">' .. gloss_text .. '</div><span class="vsToggleElement" style="display:block;width:fit-content;margin:auto">&nbsp;</span></div>'
end
end
local word_length = match(character, '[,…%-]') and 0 or
local word_length = match(character, '[,…%-]') and 0 or
(delink[i] and len(character) or len(character) * (len(gsub(char_set['trad'][i], '[^/]', '')) + 1))
(delink[i] and len(character) or len(character) * (len(gsub(char_set['trad'][i], '[^/]', '')) + 1))
table.insert(gloss, gloss_fmt(word_length, 1, length) .. gloss_text)
insert(gloss, gloss_fmt(word_length, 1, t1_len) .. gloss_text)
end
end
end
end
if content then
if content then
--[[
local applicable_pos = { ["Noun"] = 1, ["Verb"] = 1, ["Adjective"] = 1, ["Adverb"] = 1,
local applicable_pos = { ["Noun"] = 1, ["Verb"] = 1, ["Adjective"] = 1, ["Adverb"] = 1,
["Definitions"] = 1, ["Pronunciation"] = 1 }
["Definitions"] = 1, ["Pronunciation"] = 1 }
local previous_level = 2
local previous_level = 2
local subheading_wanted
local subheading_wanted
]]--
--[=[
--[=[
-- Used under headers for Chinese varieties, for instance in [[āu-piah]]
-- Used under headers for Chinese varieties, for instance in [[āu-piah]]
Line 387: Line 442:
end
end
--]=]
--]=]
if length == 1 and not string.match(content, "===Definitions===") then
if t1_len == 1 and not string.match(content, "===Definitions===") then
require('Module:debug').track('zh-forms/no definitions section found')
require('Module:debug').track('zh-forms/no definitions section found')
end
end
--[[ disable, {{zh-der}} has been deprecated so this expression will always be false
if length == 1 and not string.match(content, "===Compounds===") and string.match(content, "zh-der") then
if t1_len == 1 and not string.match(content, "===Compounds===") and string.match(content, "zh-der") then
require('Module:debug').track('zh-forms/derived terms probably needing renaming')
require('Module:debug').track('zh-forms/derived terms probably needing renaming')
end
end
]]--
--[[ comment out relatively expensive parsing
for equals, heading_text in string.gmatch(content, "\n(%=%=+)([^%=]+)%=%=+") do
for equals, heading_text in string.gmatch(content, "\n(%=%=+)([^%=]+)%=%=+") do
local current_level = #equals
local current_level = #equals
Line 403: Line 461:
subheading_wanted = string.find(heading_text, " [0-9]+") and true or false
subheading_wanted = string.find(heading_text, " [0-9]+") and true or false
end
end
]]--
end
end
local simp_note = ""
local simp_note = ""
--This is not a complete list!
--This is not a complete list!
if #identity == 1 and find(chars_unified, '[' .. test_word .. ']') then
if #identity == 1 and find(m_data.chars_unified, '[' .. t1 .. ']') then
simp_note = '<sup><span class="explain" title="Using the same code point' .. (length>1 and 's' or '') .. ' as the traditional form due to Han unification. Without proper font support, it may be displayed as the same as the traditional form.">#</span></sup>'
simp_note = '<sup><span class="explain" title="Using the same code point' .. (t1_len > 1 and 's' or '') .. ' as the traditional form due to Han unification. Without proper font support, it may be displayed as the same as the traditional form.">#</span></sup>'
char_set['simp'] = char_set['trad']
char_set['simp'] = char_set['trad']
end
end
return table.concat{
return concat{
header(length, math.max(#t, #s)), table.concat(gloss, ""),
header(t1_len, math.max(#t, #s)), concat(gloss, ""),
((#identity == 1 and simp_note == '') and
((#identity == 1 and simp_note == '') and
(var_fmt(length) .. '[[Simplified Chinese|simp.]] and [[Traditional Chinese|trad.]]<br>' ..
(var_fmt(t1_len) .. '[[Simplified Chinese|simp.]] and [[Traditional Chinese|trad.]]<br>' ..
form_fmt(t, length, 'both') .. char_fmt(char_set['trad'], length, 'both'))
form_fmt(t, t1_len, 'both') .. char_fmt(char_set['trad'], t1_len, 'both'))
or
or
var_fmt(length) .. '[[Traditional Chinese|trad.]] ' ..
var_fmt(t1_len) .. '[[Traditional Chinese|trad.]] ' ..
form_fmt(t, length, 'trad') .. char_fmt(char_set['trad'], length, 'trad') ..
form_fmt(t, t1_len, 'trad') .. char_fmt(char_set['trad'], t1_len, 'trad') ..


(var_fmt(length) .. '[[Simplified Chinese|simp.]] ' .. simp_note ..
(var_fmt(t1_len) .. '[[Simplified Chinese|simp.]] ' .. simp_note ..
form_fmt(#s == 0 and t or s, length, 'simp') .. char_fmt(char_set['simp'], length, 'simp'))
form_fmt(#s == 0 and t or s, t1_len, 'simp') .. char_fmt(char_set['simp'], t1_len, 'simp'))


), ss, ns, altforms, anagram, literal, '\n|}', table.concat(annotation)
), ss, ns, altforms, anagrams, literal, '\n|}', concat(annotation)
}
}
end
end

Revision as of 21:03, 19 June 2024


New Chinese Character box, used by {{zh-forms}}.


local export = {}
local links = require("Module:links")
local lang = require("Module:languages")
local m_data = require("Module:zh-forms/data")
local m_scripts = require("Module:scripts")
local m_str_utils = require("Module:string utilities")

local concat = table.concat
local explode = m_str_utils.explode_utf8
local find = m_str_utils.find
local get_section = require("Module:utilities").get_section
local gsub = m_str_utils.gsub
local insert = table.insert
local len = m_str_utils.len
local match = m_str_utils.match
local new_title = mw.title.new
local sub = m_str_utils.sub
local u = m_str_utils.char

local Hani_chars = m_scripts.getByCode("Hani"):getCharacters()
local nonbreaking_hyphen = u(0x2011)

local sc = {
	["trad"] = "Hant",
	["simp"] = "Hans",
	["both"] = "Hani",
}

-- Change one variant character to another variant character.
-- Currently, only do so once. Return false if there is more than one character to change, or if there is no change.
function export.change_to_variant(text)
	local count = 0
	local text = gsub(text, ('([%s])'):format(m_data.chars_variant_both), function(char)
		count = count + 1
		if (count > 1) then return '' end -- add |t2= manually, please
		local this_char_index = find(m_data.chars_variant_both, char)
		local first_or_second = (this_char_index % 2)
		local other_char_index = this_char_index + (first_or_second == 1 and 1 or -1)
		return sub(m_data.chars_variant_both, other_char_index, other_char_index)
	end)
	return (count == 1 and text or '')
end

local zh_link_impl = nil
local function zh_link(...)
	if zh_link_impl == nil then
		zh_link_impl = require("Module:zh/link")
	end
	return zh_link_impl.link(unpack(arg))
end

function export.make(frame)
	local params = {
		[1] = { list = true, allow_holes = true, allow_empty = true },
		["s"] = { list = true },
		["t"] = { list = true },
		["ss"] = {}, ["ns"] = {}, ["alt"] = {}, ["type"] = {}, ["delink"] = {}, ["lit"] = {}, ["note"] = {}, ["gloss"] = {}, ["align"] = {}
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local comp_type = args["type"]
	local s, t = {}, {}
	local annotation = {}
	
	local pagename = mw.loadData("Module:headword/data").pagename
	local current_title = mw.title.getCurrentTitle()
	local content = current_title:getContent()
	
	if not frame:getParent().args["t"] then
		insert(t, 1, current_title.subpageText)
	end
	
	for i = 1, #args.s do
		if (#args.s == 1) and pagename == args.s[i] then error('Redundant text in |s=.') end
		insert(s, args.s[i])
	end
	for i = 1, #args.t do
		if (#args.t == 1) and pagename == args.t[i] then error('Redundant text in |t=.') end
		insert(t, args.t[i])
	end
	
	local t1 = t[1]
	local t1_len = len(t1)
	
	-- temp tracking
	if #s == 0 and require("Module:zh").ts(t1) ~= t1 then
		require('Module:debug').track('zh-forms/entry possibly missing a simplified form')
	end
	if #t == 1 then
		local to_variant = export.change_to_variant(t1)
		if (to_variant ~= '') then
			-- automatically generate a |t2=
			insert(t, export.change_to_variant(t1))
		elseif find(t1, ('[%s]'):format(m_data.chars_variant_both .. m_data.chars_variant_one)) then
			require('Module:debug').track('zh-forms/entry possibly missing a variant form')
		end
	end
	s.name = "simp"
	t.name = "trad"
	
	if #t ~= 1 and #s == 0 then
		insert(s, t1)
	end

	local function asterisk(term, iscomp)
		if iscomp and t1_len > 1 then return "" end
		if term == current_title.subpageText or not (new_title(term) or {}).exists then return "" end
		local content = new_title(term):getContent()
		content = gsub(content, "zh%-pron", "Ꙁ")
		content = gsub(content, "zh%-see", "Ꙁ")
		content = gsub(content, "[^Ꙁ]", "")
		return len(content) > 1 and '<sup><span class="explain" title="This form has one or more other meanings.">*</span></sup>' or ''
	end

	local function var_fmt(length, color)
		return '\n|-\n! style="padding: 0.' .. (length > 8 and '3' or '5') ..
			'em;border: 1px solid #aaa;background: #' .. (color or 'E0FFFF') ..
			';font-weight: normal;font-size: smaller;" colspan="2" |'
	end
	
	local function char_gap(length, script, last)
		return '\n| style="padding: 0.' .. (length > 8 and '3' or '5') ..
			'em; background-color:white;' ..
			(last and 'border-right: 1px solid #aaa;border' .. (length ~= 1 and '-bottom' or '') .. ': 1px solid #aaa; '
				or 'border-bottom: 1px solid #aaa; ') ..
			'font-size:x-large" lang="zh-' .. sc[script] .. '" class="' .. sc[script] .. '" | '
	end
	
	local function header(length, var_count)
		return ((length > 3 or var_count * length > 5 or args.align == 'left') and '{|' or '{| class="floatright"') .. 
			' style="clear: right;margin: 1em 0 1em 1em;border-collapse: collapse;text-align: center"' ..
			(length ~= 1 and '\n|-\n! colspan=2|' or '')
	end
	
	local function gloss_fmt(word, colspan, length)
		return '\n! style="padding: 0.' .. (length > 8 and '3' or '5') ..
			'em;border: 1px solid #aaa;background:#F5F5DC;font-weight: normal;font-size: 85%; width:' ..
			(length <= 8 and (40 * word + 40) or (25 * word + 25)) .. 'px" colspan=' .. (colspan or 1)  ..'|'
	end

	local function form_fmt(text, length, script)
		local fmtd_text = {}
		for i,value in ipairs(text) do
			fmtd_text[i] = links.language_link{ lang = lang.getByCode("zh"), term = value } .. asterisk(value, false)
		end
		return length ~= 1 and ((length > 8 and '' or '<span style="font-size:140%">') ..
			'(<span lang="zh-' .. sc[script] .. '" class="' .. sc[script] .. '">' .. concat(fmtd_text, "/") .. '</span>)' ..
			(length > 8 and '' or '</span>')) or ''
	end
	
	local function char_fmt(text, length, script)
		return (#text ~= 1 and (char_gap(length, script) .. concat(text, char_gap(length, script), 1, #text-1)) or '') .. char_gap(length, script, true) .. text[#text]
	end
	
	local word_division = {}
	local i = 1
	local decomposable

	if comp_type then
		for index in mw.text.gsplit(comp_type, "", true) do
			if find(sub(t1, i, i), '[,%-]') then
				insert(word_division, { i, i } )
				i = i + 1
			elseif sub(t1, i, i) == '…' then
				insert(word_division, { i, i + 1 } )
				i = i + 2
			end
			insert(word_division, { i, i + index - 1 } )
			i = i + index
		end
		if i - 1 ~= len(gsub(t1, '…+$', '')) and not find(concat(t) .. concat(s), "[⿰⿱⿲⿳⿴⿵⿶⿷⿸⿹⿺⿻]") then
			error("'type' parameter does not match word length.")
		end
	else
		for i = 1, t1_len do
			insert(word_division, { i, i } )
		end
		decomposable = len(gsub(t1, '…+$', '')) > 2 and true or false
	end
	
	local delink = {}
	if args["delink"] then
		if args["delink"] == "y" then
			for del_index, _ in ipairs(word_division) do
				delink[del_index] = "yes"
			end
		else
			for position in mw.text.gsplit(args["delink"], ",") do
				delink[tonumber(position)] = "yes"
			end
		end
	end
	
	local char_set = { ['simp'] = {}, ['trad'] = {} }
	local identity = #s == 0 and {t} or {s,t}
	local uncreated = {}
	
	for _, id in ipairs(identity) do
		for i, position in ipairs(word_division) do
			local char_string = ""
			for j = 1, #id do
				local word_form = sub(id[j], position[1], position[2])
				if not find(char_string, word_form) then
					char_string = (char_string ~= "" and (char_string .. '/') or "") .. word_form
				end
			end
			if not find(char_string, '[,%-]') then
				local hash = {}
				for thing in mw.text.gsplit(char_string, (delink[i] and "" or "/")) do
					insert(hash, links.language_link{ lang = lang.getByCode("zh"), term = thing } .. asterisk(thing, true))
				end
				char_string = concat(hash, (delink[i] and "" or "/"))
			end
			insert(char_set[id.name], char_string)
		end
		for _, item in ipairs(id) do
			if not (new_title(item) or {}).exists and item ~= current_title.subpageText then
				insert(uncreated, '"[[' .. item .. ']]"')
			end
		end
	end
	
	local scripts = { [m_scripts.getByCode("Hani"):getCharacters()] = "Hani" , [m_scripts.getByCode("Latn"):getCharacters()] = "Latn", ["0-90-9"] = "Numb", [m_scripts.getByCode("Polyt"):getCharacters()] = "Grek", [m_scripts.getByCode("Bopo"):getCharacters()] = "Bopo" }
	local script = {}
	for range, script_name in pairs(scripts) do
		if find(t1, '[' .. range .. ']') then
			insert(script, script_name)
		end
	end

	if find(t1, "([^─…]+)%1") and args['gloss'] ~= '-' and t1_len < 7 then
		if gsub(comp_type or "", "1", "") == "" then
			insert(annotation, '[[Category:Chinese reduplications]]')
		elseif find(t1, "([^…][^…]+)%1") or find(concat(char_set['trad'], " "), "([^─…%[%]a-z]+)%1") then
			local evil
			for _, component in ipairs(char_set['trad']) do
				if len(component) > 1 then
					local comp_content = new_title(links.remove_links(component)):getContent() or false
					if not comp_content or find(comp_content, "|gloss=-") or not find(comp_content, "==Chinese==") then
						evil = true
					end
				end
			end
			if not evil then insert(annotation, '[[Category:Chinese reduplications]]') end
		end
	end

	insert(annotation, #script > 1 and '[[Category:Chinese terms written in multiple scripts]]' or nil)
	insert(annotation, (decomposable and args['gloss'] ~= '-' and not args['note'] and not args['lit']) and '[[Category:Chinese entries with potentially decomposable titles]]' or nil)
	insert(annotation, (#uncreated > 0 and current_title.nsText == "") and '[[Category:Chinese terms with uncreated forms]]' .. 
		'<small class="attentionseeking">(' .. (#uncreated == 1 and 'This form' or 'These forms') ..
		' in the hanzi box ' .. (#uncreated == 1 and 'is' or 'are') .. ' uncreated: ' .. 
		concat(uncreated, ", ") .. '.)</small>' or nil)
	
	local ss = ""
	if args["ss"] then
		ss = var_fmt(t1_len, 'FFFFE0') .. '[[w:Second round of simplified Chinese characters|2nd round simp.]]' .. sub(char_gap(t1_len, 'simp', true), 1, -45)
			.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
			.. ' colspan="' .. #word_division .. '"|' .. zh_link(nil, nil, { "*" .. args["ss"], tr = "-" }, current_title.subpageText)
	end
	
	local ns = ""
	if args["ns"] then
		ns = var_fmt(t1_len, 'FFFFE0') .. 'nonstandard simp.' .. sub(char_gap(t1_len, 'simp', true), 1, -45)
			.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
			.. ' colspan="' .. #word_division .. '"|' .. zh_link(nil, nil, { "*" .. args["ns"], tr = "-" }, current_title.subpageText)
	end
	
	local altforms = ""
	if args["alt"] then
		local altform_list = {}
		for altform in mw.text.gsplit(args["alt"], ",") do
			local altdecomp = mw.text.split(altform, ":")
			local altdecomp2 = mw.text.split(altdecomp[1], "-")
			local altdecomp3 = altdecomp2[2] and  ' <span style="font-size:80%"><i>' .. gsub(altdecomp2[2], "‡", frame:expandTemplate{
					title = "Template:zh-historical-dict",
					args = { type = "form", nocat = "1" }
				}) .. '</i></span>' or ''
			insert(altform_list, '<span style="white-space:nowrap;">' ..
				zh_link(nil, nil, { altdecomp2[1], tr = (altdecomp[2] or "-") }, current_title.subpageText) .. 
				altdecomp3 .. '</span>')
		end
		if #altform_list > 5 then
			altforms = '<div class="vsSwitcher" data-toggle-category="Chinese alternative forms">' ..
				'<div class="vsShow">' .. concat(altform_list, "<br>", 1, 5) ..
				'</div><div class="vsHide">' .. concat(altform_list, "<br>") .. '</div><span class="vsToggleElement" style="display:block;width:fit-content;margin:auto">&nbsp;</span></div>'
		else
			altforms = concat(altform_list, "<br>")
		end
		altforms = var_fmt(t1_len, 'F0FFE0') .. 'alternative forms' .. sub(char_gap(t1_len, "trad", true), 1, -45)
			.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
			.. ' colspan="' .. #word_division .. '"|' .. altforms
	end
	
	local anagrams = ""
	if t1_len >= 2 and t1_len <= 5 then
		
		local function generate_anagrams(term, n, anagrams, checked)
			if n == 0 then
				local anagram = concat(term)
				if checked[anagram] then
					return
				end
				local title = new_title(anagram)
				if not title then
					return
				end
				title = title:getContent()
				if title and get_section(title, "Chinese", 2) then
					insert(anagrams, anagram)
				end
				checked[anagram] = true
			else
				for i = 1, n do
					generate_anagrams(term, n - 1, anagrams, checked)
					local i = n % 2 == 0 and i or 1
					term[i], term[n] = term[n], term[i]
				end
			end
			return anagrams
		end
		
		local term, checked = explode(t1), {[t1] = true}
		anagrams = generate_anagrams(term, #term, {}, checked)
		local anagrams_num = #anagrams
		
		for i = 1, anagrams_num do
			anagrams[i] = "<span style=\"white-space:nowrap;\">" ..
				zh_link(nil, nil, {anagrams[i], tr = "-"}, current_title.subpageText) ..
				"</span>"
		end
		
		if anagrams_num == 0 then
			anagrams = ""
		else
			anagrams = concat(anagrams, "<br>")
			local label = anagrams_num == 1 and "anagram" or "anagrams"
			anagrams = var_fmt(t1_len, 'F0FFE0') .. label .. sub(char_gap(t1_len, "trad", true), 1, -45)
				.. '; padding-top: 10px; padding-bottom: 10px; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa"'
				.. ' colspan="' .. #word_division .. '"|' .. anagrams
		end
	end
	
	local literal = (args["lit"] or args["note"]) and '\n|-' .. 
		gloss_fmt(t1_len, #word_division + 2, t1_len) .. 
		(args["lit"] and '<i>Literally:</i> “' .. args["lit"] .. 
		(find(args["lit"], "%.$") and "”" or "”.") or args["note"]) or ""
	
	local gloss = {}
	if args['gloss'] == '-' then
		gloss = { gloss_fmt(t1_len * 1.6, #word_division, t1_len) .. '<i>phonetic</i>' }
	elseif t1_len == 1 then
		gloss = {}--{ gloss_fmt(1.6, #word_division) .. '-' }
	else
		for i, position in ipairs(word_division) do
			local character = sub(t1, position[1], position[2])
			
			local gloss_text = args[1][i]
			-- Load glosses module if no gloss was supplied and the word is a single character.
			if not gloss_text and position[1] == position[2] then
				local glosses = mw.loadData("Module:zh/data/glosses")
				gloss_text = glosses.glosses[character] or ""
				gloss_text = gsub(gloss_text, "{{taxlink|([^{}]+)}}",
					function (taxlink_text)
						local taxlink_args, argi = {}, 1
						for arg in mw.text.gsplit(taxlink_text, "|") do
							local arg_split = mw.text.split(arg, "=")
							if arg_split[2] then
								taxlink_args[arg_split[1]] = arg_split[2]
							else
								taxlink_args[argi] = (arg ~= "" and arg or nil)
								argi = argi + 1
							end
						end
						local frame = mw.getCurrentFrame()
						return frame:expandTemplate{
							title = 'taxlink',
							args = taxlink_args
						}
					end)
				if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") and not find(glosses.nonlemma, character) then
					require('Module:debug').track('zh-forms/no gloss found for Chinese character')
				end
			end
			if gloss_text == "-" then gloss_text = "''phonetic''" end
			if not gloss_text then
				gloss_text = ""
			end
			
			--[[
				To ensure that suffixes are not broken up between lines, like this:
				-
				ist
			]]
			if find(gloss_text, "-", nil, true) then
				gloss_text = gsub(gloss_text, "^%-", nonbreaking_hyphen)
				gloss_text = gsub(gloss_text, "(%s)%-", "%1" .. nonbreaking_hyphen)
			end
		
			if gloss_text == "" and position[2] > position[1] then
				local content = new_title(character):getContent() or false
				if content then
					gloss_text = require("Module:zh/extract").extract_gloss(content, false)
					if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") then
						require('Module:debug').track('zh-forms/no gloss found but entry exists')
					end
					--[[
					if not string.match(content, character) then
						require('Module:debug').track('zh-forms/compounds not mentioned in derived terms on the component pages')
					end
					]]--
				else
					if gloss_text == "" and find(character, "^[" .. Hani_chars .. "]+$") then
						insert(annotation, '[[Category:Chinese redlinks/zh-forms]]')
					end
				end
			end
			gloss_text = gsub(gloss_text, ";[^a-zA-Z0-9]+;", ";")
			gloss_text = gsub(gloss_text, ";[^a-zA-Z0-9]*$", "")
			gloss_text = gsub(gloss_text, ";+", ";")
			if len(gsub(gloss_text, '[^;]', '')) > 2 then
				gloss_text = '<div class="vsSwitcher" data-toggle-category="glosses"><div class="vsShow">' ..
					match(gloss_text, '^[^;]+;[^;]+;[^;]+') .. '</div><div class="vsHide">' .. gloss_text .. '</div><span class="vsToggleElement" style="display:block;width:fit-content;margin:auto">&nbsp;</span></div>'
			end
			local word_length = match(character, '[,…%-]') and 0 or 
				(delink[i] and len(character) or len(character) * (len(gsub(char_set['trad'][i], '[^/]', '')) + 1))
			insert(gloss, gloss_fmt(word_length, 1, t1_len) .. gloss_text)
		end
	end
	
	if content then
		--[[
		local applicable_pos = { ["Noun"] = 1, ["Verb"] = 1, ["Adjective"] = 1, ["Adverb"] = 1, 
			["Definitions"] = 1, ["Pronunciation"] = 1 }
		local previous_level = 2
		local subheading_wanted
		]]--
		--[=[
		-- Used under headers for Chinese varieties, for instance in [[āu-piah]]
		local Chinese_section = string.match(content, "\n==Chinese==\n(.-)\n==[^=]")
		if not Chinese_section then
			error("No Chinese section found.")
		end
		--]=]
		if t1_len == 1 and not string.match(content, "===Definitions===") then
			require('Module:debug').track('zh-forms/no definitions section found')
		end
		--[[ disable, {{zh-der}} has been deprecated so this expression will always be false
		if t1_len == 1 and not string.match(content, "===Compounds===") and string.match(content, "zh-der") then
			require('Module:debug').track('zh-forms/derived terms probably needing renaming')
		end
		]]--
		--[[ comment out relatively expensive parsing
		for equals, heading_text in string.gmatch(content, "\n(%=%=+)([^%=]+)%=%=+") do
			local current_level = #equals
			if subheading_wanted and current_level ~= previous_level + 1 then
				if applicable_pos[heading_text] then
					error("The heading \"===Etymology ''n''===\" or \"===Pronunciation ''n''===\" must be followed by a subheading one level lower.")
				end
			end
			previous_level = current_level
			subheading_wanted = string.find(heading_text, " [0-9]+") and true or false
		end
		]]--
	end
	
	local simp_note = ""
	--This is not a complete list!
	
	if #identity == 1 and find(m_data.chars_unified, '[' .. t1 .. ']') then
		simp_note = '<sup><span class="explain" title="Using the same code point' .. (t1_len > 1 and 's' or '') .. ' as the traditional form due to Han unification. Without proper font support, it may be displayed as the same as the traditional form.">#</span></sup>'
		char_set['simp'] = char_set['trad']
	end
	
	return concat{
		header(t1_len, math.max(#t, #s)), concat(gloss, ""),
		((#identity == 1 and simp_note == '') and
			(var_fmt(t1_len) .. '[[Simplified Chinese|simp.]] and [[Traditional Chinese|trad.]]<br>' .. 
				form_fmt(t, t1_len, 'both') .. char_fmt(char_set['trad'], t1_len, 'both'))
		or
			 var_fmt(t1_len) .. '[[Traditional Chinese|trad.]] ' .. 
			 	form_fmt(t, t1_len, 'trad') .. char_fmt(char_set['trad'], t1_len, 'trad') .. 

			(var_fmt(t1_len) .. '[[Simplified Chinese|simp.]] ' .. simp_note ..
				form_fmt(#s == 0 and t or s, t1_len, 'simp') .. char_fmt(char_set['simp'], t1_len, 'simp'))

		), ss, ns, altforms, anagrams, literal, '\n|}', concat(annotation)
	}
end

return export