Jump to content
Wikipedia The Free Encyclopedia

Module:Anchor/sandbox

From Wikipedia, the free encyclopedia
This is the module sandbox page for Module:Anchor (diff).
See also the companion subpage for test cases (run).
Module documentation[view] [edit] [history] [purge]
[画像:Warning] This Lua module is used in system messages, and on approximately 93,000 pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
This module depends on the following other modules:

This module implements {{anchor }}. Please see the Template:Anchor/doc page for documentation.

The above documentation is transcluded from Module:Anchor/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Add categories to the /doc subpage. Subpages of this module.
 -- This module implements {{anchor}}.

 localgetArgs=require('Module:Arguments').getArgs
 localtableTools=require('Module:TableTools')

 localp={}

 functionp.main(frame)
 -- Get the positional arguments from #invoke, remove any nil values,
 -- and pass them to p._main.
 localargs=getArgs(frame)
 localargArray=tableTools.compressSparseArray(args)
 returnp._main(unpack(argArray))
 end

 functionp._main(...)
 -- Generate the list of anchors.
 localanchors={...}
 localret={}
 for_,anchorinipairs(anchors)do
 ret[#ret+1]='<span class="anchor" id="'..anchor..'"></span>'
 end
 returntable.concat(ret)
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /