请输入您要查询的百科知识:

 

词条 Module:Auto compact ToC
释义

local p = {}

local start = [[

__NOTOC__

local function make_TOC_item(anchor, link_text)

link_text = link_text or anchor

return ("* %s"):format(anchor, link_text)

end

local Array_mt = { __index = table }

local function Array()

return setmetatable({}, Array_mt)

end

function p.make_TOC(frame)

local content = mw.title.getCurrentTitle():getContent()

if not content then

error "The current page has no content"

end

local letters = Array()

-- Find uppermost headers containing a single ASCII letter.

for letter in content:gmatch "%f[^\]==%s*(%a)%s*==%f[^=]" do

letter = letter:upper()

letters:insert(make_TOC_item(letter))

end

local yesno = require "Module:Yesno"

local rest = Array()

local other_headers = require "Module:TableTools".listToSet{

"See also", "References", "Notes", "Further reading", "External links",

}

for header in content:gmatch "%f[^\]==%s*(..-)%s*==%f[^=]" do

if other_headers[header] then

rest:insert(make_TOC_item(header))

end

end

return start .. letters:concat("\") .. "\\" .. rest:concat("\") .. close

end

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 18:46:20