Movatterモバイル変換


[0]ホーム

URL:


跳转到内容
维基词典自由的多语言词典
搜索

模組:Table of contents

維基詞典,自由的多語言詞典

此模块缺少說明文檔。請協助創建
相關連結:子頁面列表链入嵌入包含測試用例沙盒

localexport={}localm_languages=require("Module:languages")localtitle=mw.title.getCurrentTitle()localrsplit=mw.text.splitlocalfunctionmakeUrl(queryType,target)iftitleandtitle.fullUrltheniftargetthenifqueryTypethenlocalquery={[queryType]=target}returntitle:fullUrl(query,"https")elsereturntitle:fullUrl(nil,"https")endendendendlocalfunctionlink(queryType,target,display,lang_code,script_code)localurl=makeUrl(queryType,target)ifurlthenlocalext_link="["..url.." "..(displayortarget).."]"ext_link=mw.html.create("span"):wikitext(ext_link)ext_link=lang_codeandext_link:attr("lang",lang_code)orext_linkext_link=script_codeandext_link:addClass(script_code)orext_linkreturntostring(ext_link)endendfunctionexport.show(frame)localoutput={}localparams={[1]={list=true},["lang"]={type="string"},["subcat"]={type="boolean"},["top"]={},}localargs=require("Module:parameters").process(frame.args[1]andframe.argsorframe:getParent().args,params)locallang=args.langandm_languages.getByCode(args.lang)ornillocaltargets=args[1]localdisplays={}fori,charinipairs(targets)doifchar:find(":")thenlocaltarget,display=char:match("([^:]+):(.+)")iftargetthentargets[i]=langand(lang:makeSortKey(target))ortargetdisplays[i]=displayelseerror('Parameter '..i..' is badly formatted. It should contain a key to use in the link, a colon, and then the displayed text.')endelsetargets[i]=langand(lang:makeSortKey(char))orchardisplays[i]=charendendlocalscript_codeiflangthenscript_code=lang:findBestScript(table.concat(displays)):getCode()elseiftable.concat(displays)~=""thenscript_code=require("Module:scripts").findBestScriptWithoutLang(table.concat(displays)):getCode()endlocalsubcat,queryType=args.subcatifsubcatthenqueryType="subcatfrom"-- [[Special:WhatLinksHere/Wiktionary:Tracking/table-of-contents/subcat]]require("Module:debug").track("table-of-contents/subcat")elsequeryType="from"endifargs.topthenlocallink=link(nil,args.top)table.insert(output,link)iftargetsandtargets[1]thentable.insert(output," – ")endendfori,charinipairs(targets)dolocallink=link(queryType,char,displays[i],langandlang:getCode()ornil,script_code)table.insert(output,link)endifnotlangthentable.insert(output,"[[Category:User:Theknightwho/table of contents]]")endreturntable.concat(output," ")..require("Module:TemplateStyles")("Module:table of contents/style.css")endfunctionexport.full(frame)localparams={[1]={list=true},["char2"]={},["lang"]={type="string",required=true},["subcat"]={type="boolean"}}localargs=require("Module:parameters").process(frame.args[1]andframe.argsorframe:getParent().args,params)locallang=m_languages.getByCode(args.lang)locallang_code=lang:getCode()localtargets=args[1]localdisplays={}localscript_code=lang:findBestScript(table.concat(args[1])):getCode()localsubcat,queryType=args.subcatifsubcatthenqueryType="subcatfrom"-- [[Special:WhatLinksHere/Wiktionary:Tracking/table-of-contents/subcat]]require("Module:debug").track("table-of-contents/subcat")elsequeryType="from"endlocaloutput=mw.html.create("table"):attr("id","toc"):addClass("wikitable plainlinks categoryTOC-full"):attr("summary","Contents"):css("text-align","center"):tag("tr"):tag("th"):attr("colspan",#args[1]):wikitext("目錄("..link(nil,"回頂部")..")"):allDone()localrow=output:tag("tr")localcell={}fori,charinipairs(args[1])dolocaltarget=lang:makeSortKey(char)table.insert(cell,link(queryType,target,char,lang_code,script))endcell=row:tag("td"):wikitext(table.concat(cell," ")):attr("colspan",#args[1])localchar2_list=args.char2andrsplit(args.char2,",")orargs[1]fori,char1inipairs(args[1])dolocalrow=output:tag("tr"):attr("class","tocrow")fori,char2inipairs(char2_list)dolocalcell=row:tag("td")localdisplay=char1..char2iflang:hasDottedDotlessI()thendisplay=display:gsub("İ","i"):gsub("I","ı")enddisplay=display:ulower()localtarget=lang:makeSortKey(display)cell=cell:wikitext(link(queryType,target,display,lang_code,script))endendlocalrow=output:tag("tr")localcell={}fori=0,9dolocaldisplay=tostring(i)localtarget=lang:makeSortKey(display)table.insert(cell,link(queryType,target,display,lang_code,script))endcell=row:tag("td"):wikitext(table.concat(cell," ")):attr("colspan",#args[1])returntostring(output)..require("Module:TemplateStyles")("Module:table of contents/style.css")endreturnexport
来自“https://zh.wiktionary.org/w/index.php?title=Module:Table_of_contents&oldid=9391748
分类:​

[8]ページ先頭

©2009-2025 Movatter.jp