Title: Module:Anchor - freem URL Source: https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor Markdown Content: Revision as of 22:32, 24 September 2020 by [en>Pppery](https://freemwiki.com/wiki/User:Pppery "en:User:Pppery") _Documentation for this module may be created at [Module:Anchor/doc](https://freemwiki.com/index.php?title=Module:Anchor/doc&action=edit&redlink=1 "Module:Anchor/doc (page does not exist)")_ [](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-1)-- This module implements {{[anchor](https://freemwiki.com/wiki/Template:Anchor "Template:Anchor")}}.[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-2)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-3)local getArgs = require(['Module:Arguments'](https://freemwiki.com/wiki/Module:Arguments)).getArgs[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-4)local tableTools = require(['Module:TableTools'](https://freemwiki.com/wiki/Module:TableTools))[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-5)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-6)local p = {}[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-7)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-8)function p.main(frame)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-9)-- Get the positional arguments from #invoke, remove any nil values,[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-10)-- and pass them to p._main.[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-11)local args = getArgs(frame)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-12)local argArray = tableTools.compressSparseArray(args)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-13)return p._main(unpack(argArray))[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-14)end[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-15)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-16)function p._main(...)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-17)-- Generate the list of anchors.[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-18)local anchors = {...}[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-19)local ret = {}[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-20)for _, anchor in ipairs(anchors) do[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-21)ret[#ret + 1] = ''[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-22)end[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-23)return table.concat(ret)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-24)end[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-25)[](https://freemwiki.com/index.php?oldid=579793&title=Module%3AAnchor#L-26)return p