fbpx
วิกิพีเดีย

มอดูล:AutomaticTOC/sandbox

คู่มือการใช้งานมอดูล[ดู] [แก้] [ประวัติ] [ล้างแคช]

การใช้งาน

พารามิเตอร์

  1. name: เป็นชื่อของตาราง ถ้าไม่ระบุจะไม่แสดงผล อาจระบุเป็น {{MediaWiki:Toc}}: ก็ได้
  2. short: หากระบุ จะทำให้ name อยู่บรรทัดเดียวกับข้อมูล แต่ถ้าไม่ระบุจะทำให้ name อยู่บนสุด และลอยอยู่ตรงกลาง
  3. delim: ไว้ใช้เป็นตัวแบ่งสำหรับพารามิเตอร์ include, exclude, pre, post ค่ามาตรฐานคือ ","
  4. sep: ไว้ใช้เป็นตัวแบ่งเวลาแสดงผล TOC ค่ามาตรฐานคือ " " (ช่องว่าง) สามารถกำหนดเป็นอย่างอื่น เช่น " · " ได้
  5. pre: เป็นรายการอะไรก็ได้ที่ต้องการให้แสดงผลก่อนลิงก์ที่สร้างขึ้นโดยอัตโนมัติ เช่น [[#top|บนสุด]]
  6. post: เป็นรายการอะไรก็ได้ที่ต้องการให้แสดงผลหลังลิงก์ที่สร้างขึ้นโดยอัตโนมัติ เช่น [[#อ้างอิง|อ้างอิง]]
  7. prebreak: เป็นตัวคั่นระหว่าง pre กับชุดข้อมูล โดยปกติจะมีค่าเป็น sep อาจระบุเป็น <br> หากต้องการให้ pre กับชุดข้อมูลอยู่คนละบรรทัดกัน
  8. postbreak: เป็นตัวคั่นระหว่าง post กับชุดข้อมูล โดยปกติจะมีค่าเป็น sep อาจระบุเป็น <br> หากต้องการให้ post กับชุดข้อมูลอยู่คนละบรรทัดกัน
  9. include: เป็นรายการหัวเรื่องที่ต้องการให้รวมเป็นกรณีพิเศษ เช่น "0-9"
  10. exclude: เป็นรายการหัวเรื่องที่ต้องการให้นำออกเป็นกรณีพิเศษ
  11. top: หากกำหนด จะมีลิงก์โยงไปยังบนสุดของหน้า โดยมีชื่อแสดงผลลิงก์ตามที่กำหนดไว้ ค่ามาตรฐานคือค่าว่าง (นั่นคือไม่แสดงผล)
  12. anchor: จับกับ anchor ที่สร้างผ่านแม่แบบ anchor ด้วย
  13. title: หากกำหนดจะดึงข้อมูลจากหน้านั้น ๆ ค่ามาตรฐานคือหน้าปัจจุบันที่กำลังเปิดอยู่
  14. prefix: หากกำหนด จะใส่ข้อความแสดงผลลิงก์จะมีข้อความนี้เติมเข้าไปข้างหน้า
  15. suffix: หากกำหนด จะใส่ข้อความแสดงผลลิงก์จะมีข้อความนี้เติมเข้าไปด้านหลัง
  16. level: รวบรวมลิงก์ที่มีความยาวน้อยกว่าหรือเท่ากับ level มาสร้างตาราง ค่ามาตรฐานคือ 1

ข้อจำกัด

  1. เมื่อมีการเปลี่ยนแปลงหัวข้อย่อย อาจจะต้องทำการล้างแคชเซิร์ฟเวอร์เสียก่อน จึงจะแสดงผลถูกต้อง

ดูเพิ่ม

z = {};  -- main function function z.main(frame)  local args = frame.args  local pargs = frame:getParent().args  local title = nil  if (pargs.title or args.title) then  title = mw.title.new(pargs.title or args.title)  else  title = mw.title.getCurrentTitle()  end  local delim = args.delim or ","  local seperator = args.seperator or " "  local include = args.include and Set(Split(args.include, "%" .. delim)) or {}  local exclude = args.exclude and Set(Split(args.exclude, "%" .. delim)) or {}  local top = args.top and '[[#top|' .. args.top .. ']] - ' or ''  local anchor = args.anchor  local wiki_text = title:getContent()  local all = {}   eval = function(v)  v = v:match "^%s*(.-)%s*$"  if v ~= "" then  if (mw.ustring.len(v) == 1 or include[v]) then table.insert(all, v) end  end  end   for line in wiki_text:gmatch("[^\n]+") do  ---  eval(string.gsub(line:match("^=+%s*(.-)%s*=+%s-$") or "", "%b{}", ""))  if anchor then  for _, v in pairs(Split(line:match("%{%{[Aa]nchor%|(.-)%}%}") or "", "%|")) do eval(v) end  end  ---  end   complete_list = {}  table.sort(all, function(a, b) return mw.ustring.codepoint(a) < mw.ustring.codepoint(b) end)  for k, v in pairs(all) do  if not exclude[v] and (k == 0 or (k > 0 and all[k - 1] ~= v)) then  table.insert(complete_list, table.concat{"[[#", v, "|", v, "]]"})  end  end  out = '{| class="toccolours" style="margin: 0px auto;"\n! {{MediaWiki:Toc}}:\n' ..  '| ' .. top .. table.concat(complete_list, seperator) .. ' __NOTOC__\n|}'  if args.db then  return frame:preprocess('<pre>' .. out .. '</pre>')  else  return frame:preprocess(out)  end end  -- http://stackoverflow.com/questions/656199/search-for-an-item-in-a-lua-list function Set (list)  local set = {}  for _, l in pairs(list) do set[l] = true end  return set end  -- http://lua-users.org/wiki/SplitJoin function Split(str, delim, maxNb)  -- Eliminate bad cases...  if string.find(str, delim) == nil then  return { str }  end  if maxNb == nil or maxNb < 1 then  maxNb = 0 -- No limit  end  local result = {}  local pat = "(.-)" .. delim .. "()"  local nb = 0  local lastPos  for part, pos in string.gfind(str, pat) do  nb = nb + 1  result[nb] = part  lastPos = pos  if nb == maxNb then break end  end  -- Handle the last field  if nb ~= maxNb then  result[nb + 1] = string.sub(str, lastPos)  end  return result end  return z  -- 2 May 2013:‎ Thanks to [[:en:User:Darklama]] for helping improving the code :) 

มอด, automatictoc, sandbox, อหน, ากระบะทรายมอด, ลของ, มอด, automatictoc, ความแตกต, าง, อการใช, งานมอด, แก, ประว, างแคช, เน, อหา, การใช, งาน, พาราม, เตอร, อจำก, เพ, การใช, งาน, แก, ไข, วนน, รอเพ, มเต, มข, อม, ณสามารถช, วยเพ, มข, อม, ลส, วนน, ได, พาราม, เตอร, แก. nikhuxhnakrabathraymxdulkhxng mxdul AutomaticTOC dukhwamaetktang khumuxkarichnganmxdul du aek prawti langaekhch enuxha 1 karichngan 2 pharamietxr 3 khxcakd 4 duephim karichngan aekikh swnnirxephimetimkhxmul khunsamarthchwyephimkhxmulswnniidpharamietxr aekikh name epnchuxkhxngtarang thaimrabucaimaesdngphl xacrabuepn MediaWiki Toc kid short hakrabu cathaih name xyubrrthdediywkbkhxmul aetthaimrabucathaih name xyubnsud aelalxyxyutrngklang delim iwichepntwaebngsahrbpharamietxr include exclude pre post khamatrthankhux sep iwichepntwaebngewlaaesdngphl TOC khamatrthankhux chxngwang samarthkahndepnxyangxun echn id pre epnraykarxairkidthitxngkarihaesdngphlkxnlingkthisrangkhunodyxtonmti echn top bnsud post epnraykarxairkidthitxngkarihaesdngphlhlnglingkthisrangkhunodyxtonmti echn xangxing xangxing prebreak epntwkhnrahwang pre kbchudkhxmul odypkticamikhaepn sep xacrabuepn lt br gt haktxngkarih pre kbchudkhxmulxyukhnlabrrthdkn postbreak epntwkhnrahwang post kbchudkhxmul odypkticamikhaepn sep xacrabuepn lt br gt haktxngkarih post kbchudkhxmulxyukhnlabrrthdkn include epnraykarhweruxngthitxngkarihrwmepnkrniphiess echn 0 9 exclude epnraykarhweruxngthitxngkarihnaxxkepnkrniphiess top hakkahnd camilingkoyngipyngbnsudkhxnghna odymichuxaesdngphllingktamthikahndiw khamatrthankhuxkhawang nnkhuximaesdngphl anchor cbkb anchor thisrangphanaemaebb anchor dwy title hakkahndcadungkhxmulcakhnann khamatrthankhuxhnapccubnthikalngepidxyu prefix hakkahnd caiskhxkhwamaesdngphllingkcamikhxkhwamnietimekhaipkhanghna suffix hakkahnd caiskhxkhwamaesdngphllingkcamikhxkhwamnietimekhaipdanhlng level rwbrwmlingkthimikhwamyawnxykwahruxethakb level masrangtarang khamatrthankhux 1khxcakd aekikh emuxmikarepliynaeplnghwkhxyxy xaccatxngthakarlangaekhchesirfewxresiykxn cungcaaesdngphlthuktxngduephim aekikh drrchnixtonmti khumuxkarichnganthipraktdanbnnidungmacak mxdul AutomaticTOC doc aek prawti phuekhiynsamarththakarthdlxngidthikrabathray aek dukhwamaetktang aelachudthdsxb srang khxngmxdulnioprdephimhmwdhmuipthihnayxy doc hnayxykhxngmxdulniz main function function z main frame local args frame args local pargs frame getParent args local title nil if pargs title or args title then title mw title new pargs title or args title else title mw title getCurrentTitle end local delim args delim or local seperator args seperator or local include args include and Set Split args include delim or local exclude args exclude and Set Split args exclude delim or local top args top and top args top or local anchor args anchor local wiki text title getContent local all eval function v v v match s s if v then if mw ustring len v 1 or include v then table insert all v end end end for line in wiki text gmatch n do eval string gsub line match s s s or b if anchor then for v in pairs Split line match Aa nchor or do eval v end end end complete list table sort all function a b return mw ustring codepoint a lt mw ustring codepoint b end for k v in pairs all do if not exclude v and k 0 or k gt 0 and all k 1 v then table insert complete list table concat v v end end out class toccolours style margin 0px auto n MediaWiki Toc n top table concat complete list seperator NOTOC n if args db then return frame preprocess lt pre gt out lt pre gt else return frame preprocess out end end http stackoverflow com questions 656199 search for an item in a lua list function Set list local set for l in pairs list do set l true end return set end http lua users org wiki SplitJoin function Split str delim maxNb Eliminate bad cases if string find str delim nil then return str end if maxNb nil or maxNb lt 1 then maxNb 0 No limit end local result local pat delim local nb 0 local lastPos for part pos in string gfind str pat do nb nb 1 result nb part lastPos pos if nb maxNb then break end end Handle the last field if nb maxNb then result nb 1 string sub str lastPos end return result end return z 2 May 2013 Thanks to en User Darklama for helping improving the code ekhathungcak https th wikipedia org w index php title mxdul AutomaticTOC sandbox amp oldid 4918142, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม