Title: Module:Footnotes/anchor id list - freem
URL Source: https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list
Published Time: Fri, 31 Jul 2026 09:46:30 GMT
Markdown Content:
[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#)
- [x]
* [Home](https://freemwiki.com/wiki/Main_Page)
* [Random](https://freemwiki.com/wiki/Special:Random)
* [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AFootnotes%2Fanchor+id+list&returntoquery=mobileaction%3Dtoggle_view_mobile)
* [Settings](https://freemwiki.com/index.php?title=Special:MobileOptions&returnto=Module%3AFootnotes%2Fanchor+id+list)
* [About](https://freemwiki.com/wiki/About)
* [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service)
[freem](https://freemwiki.com/wiki/Main_Page)
Search
# Module:Footnotes/anchor id list
* [Language](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#p-lang "Language")
* [Watch](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AFootnotes%2Fanchor+id+list)
* [Edit](https://freemwiki.com/index.php?title=Module:Footnotes/anchor_id_list&action=edit)
<[Module:Footnotes](https://freemwiki.com/wiki/Module:Footnotes "Module:Footnotes")
_Documentation for this module may be created at [Module:Footnotes/anchor id list/doc](https://freemwiki.com/index.php?title=Module:Footnotes/anchor\_id\_list/doc&action=edit&redlink=1 "Module:Footnotes/anchor id list/doc (page does not exist)")_
[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-1)require('strict');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-2)local data = mw.loadData (['Module:Footnotes/anchor id list/data'](https://freemwiki.com/wiki/Module:Footnotes/anchor_id_list/data));[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-3)local whitelist = mw.loadData (['Module:Footnotes/whitelist'](https://freemwiki.com/wiki/Module:Footnotes/whitelist));[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-4)local Lang_obj = mw.language.getContentLanguage();-- used by template_list_add() to uppercase first letter of template name TODO: better way to do that?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-5)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-6)local redirects_date = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-7)['date'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-8)['datetomos'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-9)['formatdate'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-10)['isotodmymdy'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-11)['isotomos'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-12)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-13)local redirects_patent = {-- special case cs1-like templates because uses different parameters for name and date in anchor ID[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-14)['Cite patent'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-15)['Citeref patent'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-16)['Ref patent'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-17)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-18)local redirects_sfnref = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-19)['sfnref'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-20)['harvid'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-21)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-22)local aliases_author = {-- these use pseudo-patterns in the same way as cs1|2; '#' represents 1 or more enumerator digits[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-23)'last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-24)'author#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-25)'surname#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-26)'author-last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-27)'author#-last',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-28)'subject#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-29)'host#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-30)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-31)local aliases_contributor = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-32)'contributor#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-33)'contributor-last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-34)'contributor#-last',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-35)'contributor-surname#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-36)'contributor#-surname',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-37)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-38)local aliases_editor = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-39)'editor#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-40)'editor-last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-41)'editor#-last',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-42)'editor-surname#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-43)'editor#-surname',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-44)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-45)local aliases_harvc_author = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-46)'last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-47)'author#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-48)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-49)local aliases_inventor = {-- cite patent[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-50)'inventor#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-51)'inventor-last#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-52)'inventor#-last',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-53)'inventor-surname#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-54)'inventor#-surname',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-55)'invent#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-56)'invent-#',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-57)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-58)local alias_patterns_date = {-- normal lua patterns for most cs1|2-like templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-59)'|%s*year%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-60)'|%s*date%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-61)'|%s*publication%-?date%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-62)'|%s*air%-?date%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-63)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-64)local alias_patterns_harvc_date = {-- normal lua patterns for harvc template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-65)'|%s*anchor%-year%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-66)'|%s*year%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-67)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-68)local alias_patterns_patent_date = {-- normal lua patterns for cite patent templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-69)'|%s*issue%-date%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-70)'|%s*gdate%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-71)'|%s*publication%-date%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-72)'|%s*pubdate%s*=%s*',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-73)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-74)local patterns_date = {-- normal lua patterns[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-75)-- '(%d%d%d%d–%d%d%d%d%l?)$', -- YYYY–YYYY four-digit year range at end (Season YYYY–YYYY); with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-76)'(%d%d%d%d)%D+(%d%d%d%d%l?)$',-- any range with four-digit years; with or without dab; not two captures[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-77)'^(%d%d%d%d–%d%d%l?)$',-- YYYY–YY two-digit year range; with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-78)'^(c%. %d%d%d%d?%l?)$',-- three- or four-digit circa year; with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-79)'(%d%d%d%d?%l?)$',-- three- or four-digit year at end of date (dmy or mdy); with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-80)'^(%d%d%d%d?%l?)',-- three- or four-digit year at beginning of date (ymd or YYYY); with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-81)'^(n%.d%.%l?)$',-- 'no date' with dots; with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-82)'^(nd%l?)$',-- 'no date' without dots; with or without dab[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-83)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-84)local patterns_tags = {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-85)'.-',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-86)'',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-87)'
.-
',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-88)'.-',[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-89)'.-',-- deprecated alias of syntaxhighlight tag[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-90)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-91)local template_skip = {-- templates to be skipped for whatever reason; mostly because they resemble cs1-like templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-92)['Citation-attribution'] = true,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-93)}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-94)local global_article_content = nil[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-95)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-96)local global_anchor_id_list = nil-- exported tables[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-97)local global_template_list = nil[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-98)local global_article_whitelist = nil[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-99)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-100)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-101)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-102)--[[--------------------------< A R T I C L E _ C O N T E N T _ G E T >----------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-103)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-104)get article content, remove certain html-like tags and their content so that this code doesn't include any citation[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-105)templates inside the tags as valid tagets; they are not.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-106)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-107)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-108)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-109)local function article_content_get ()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-110) if global_article_content then return global_article_content end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-111) local article_content = mw.title.getCurrentTitle():getContent() or '';-- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-112)for _, tag in ipairs (patterns_tags) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-113) article_content = article_content:gsub (tag, '');-- remove certain html-like tags and their content[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-114)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-115)global_article_content = article_content[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-116) return article_content[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-117)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-118)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-119)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-120)--[[--------------------------< S F N R E F _ G E T >----------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-121)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-122)make an anchor id from the contents of {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}. this function assumes that {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} and {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-123)are correctly formed.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-124)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-125)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-126)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-127)local function sfnref_get (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-128)template = template:gsub ('{{%s*(.-)%s*}}', '%1');-- strip bounding template markup and trim[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-129)local parts = mw.text.split (template, '%s*|%s*');-- split at the pipe and remove extraneous space characters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-130)local anchor_id = {};[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-131)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-132)if redirects_sfnref[parts[1]:lower()] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-133)anchor_id[1] = 'CITEREF';[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-134)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-135)return nil;-- not an sfnref or harvid template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-136)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-137)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-138)local i = 2;-- indexer into parts{} table[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-139)local j = 2;-- indexer into anchor_id{} table which already has 'CITEREF' at [1][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-140)while parts[i] and 7 > j do-- loop through what should be just positional parameters for names and year (2-6 four names and a date)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-141)if not parts[i]:find ('=') then-- look for equal sign (named paraneter in a template that doesn't support named parameters)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-142)anchor_id[j] = parts[i];-- positional parameters are saved[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-143)j = j+1;-- bump the anchor_id{} indexer[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-144)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-145)i = i+ 1;-- bump the parts{} indexer[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-146)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-147)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-148)return table.concat (anchor_id, '');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-149)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-150)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-151)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-152)--[[--------------------------< D A T E _ G E T >--------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-153)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-154)extract year from one of |year=, |date=, |publicationdate=, or |publication-date in that order. Does not error[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-155)check (that is left to the cs1|2 templates to do)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-156)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-157)also gets date from |={{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")|...}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-158)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-159)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-160)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-161)local function date_get (template, aliases)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-162)local rvalue;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-163)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-164)for _, pattern in ipairs (aliases) do-- spin through the date alias patterns[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-165)rvalue = tostring(template):match (pattern);-- is this |= used (tostring() because something makes match() think template is a table)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-166)if rvalue then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-167)rvalue = tostring(template):match (pattern .. '(%b{})');-- is rvalue a template?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-168)if rvalue then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-169)rvalue = rvalue:gsub ('{{%s*(.-)%s*}}', '%1');-- strip bounding template markup and trim[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-170)local parts = mw.text.split (rvalue, '%s*|%s*');-- split at the pipe and remove extraneous space characters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-171)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-172)if redirects_date[parts[1]:lower()] then-- if parts[1] names {{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")}} or redirect[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-173)rvalue = parts[2];-- assume that date template is properly formed, first positional parameter is the date[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-174)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-175)return '';-- |date= holds some other template than {{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")}} or redirect[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-176)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-177)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-178)rvalue = template:match (pattern .. '([^|}]+)');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-179)if rvalue then-- if rvalue is something[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-180)rvalue = mw.text.trim (rvalue);-- trim it[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-181)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-182)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-183)if not rvalue or '' == rvalue then-- if rvale was nothing or trimed to nothing[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-184)rvalue = nil;-- ensure that it is unset so we can try the next parameter in the list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-185)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-186)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-187)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-188)if rvalue then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-189)for _, pattern in ipairs (patterns_date) do-- spin through the recognized date formats[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-190)-- date = rvalue:match (pattern); -- attempt to extract year portion according to the pattern[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-191)local date, date2 = rvalue:match (pattern);-- attempt to extract year portion according to the pattern; gets second year in any range[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-192)if date then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-193)if date2 then-- when a second year[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-194)date = table.concat ({date, '–', date2});-- build a date range[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-195)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-196)return date;-- matched so return;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-197)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-198)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-199)break;-- found a date but it was malformed so abandon[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-200)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-201)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-202)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-203)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-204)return '';-- no date param or date param doesn't hold a recognized date; empty string for concatenation[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-205)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-206)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-207) [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-208)--[[--------------------------< V N A M E S _ G E T >----------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-209)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-210)extract names from |vauthors= or |veditors=; there is no |vcontributors= parameter.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-211)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-212)splits the v parameter value at the comma; correctly handles accept-as-witten markup when used to wrap a comma-[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-213)separated names (corporate)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-214)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-215)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-216)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-217)local function vnames_get (params, vparam)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-218)local vnames = {};-- first four author or editor names go here[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-219)local split = {};-- temp table to assist in decoding accept-as-witten-markup[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-220)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-221)if params[vparam] then-- test for |vauthors= or |veditor=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-222)split = mw.text.split (params[vparam], '%s*,%s*');-- this will separate portions of ((Black, Brown, White, an Co.))[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-223)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-224)local i = 1;-- an indexer[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-225)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-226)while split[i] do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-227)if split[i]:match ('^%(%(.*[^%)][^%)]$') then-- first segment of comma-separated accept-as-witten; this segment has the opening doubled parens[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-228)local name = split[i];[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-229)i=i+1;-- bump indexer to next segment[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-230)while split[i] do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-231)name = name .. ', ' .. split[i];-- concatenate with previous segments[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-232)if split[i]:match ('^.*%)%)$') then-- if this table member has the closing doubled parens[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-233)break;-- and done reassembling so[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-234)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-235)i=i+1;-- bump indexer[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-236)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-237)table.insert (vnames, name);-- and add accept-as-witten name to the vnames table[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-238)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-239)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-240)table.insert (vnames, split[i]);-- and add name to the vnames table[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-241)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-242)i=i+1;-- bump indexer[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-243)if 5 == i then break; end-- limit to four names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-244)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-245)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-246)for i, vname in ipairs (vnames) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-247)if not vname:match ('%(%(.-%)%)') then-- without accept-this-value-as-written markup[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-248)vnames[i] = vname:gsub ('(.-)%s+%u+$', '%1');-- extract and save surname(s)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-249)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-250)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-251)for i, vname in ipairs (vnames) do-- repeat, this time for accept-this-value-as-written markup[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-252)vnames[i] = vname:gsub ('%(%((.-)%)%)', '%1');-- remove markup if present and save the whole name[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-253)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-254)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-255)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-256)return 0 ~= #vnames and table.concat (vnames) or nil-- return a concatenation of the vnames; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-257)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-258)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-259)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-260)--[[--------------------------< N A M E S _ G E T >------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-261)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-262)cs1|2 makes anchor id from contributor, author, or editor name-lists in that order[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-263)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-264)get the names from the cs1|2 template; if there are no contributor names, try author names, then try editor names.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-265)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-266)returns concatenated names in enumeration order when successful; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-267)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-268)empty name (nameholding parameter n is present without value) and missing name (nameholding parameter n is not[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-269)present) are included as empty string with all other names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-270)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-271)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-272)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-273)local function names_get (params, aliases_list)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-274)local names = {};-- first four author or editor names go here[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-275)local enum_alias;-- alias with '#' replaced with a digit[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-276)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-277)for enum=1, 4 do-- four names only[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-278)for i, alias in ipairs (aliases_list) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-279)if not names[enum] then-- hanven't found a previous alias with this [enum]? see if we can find this alias with this enum[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-280)enum_alias = alias:gsub ('#', enum);-- replace '#' to make 'lastn'[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-281)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-282)if 1 == enum then-- because |last= and last1= are exact aliases[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-283)if params[enum_alias] then-- test |last1= first[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-284)names[enum] = params[enum_alias];-- found so save the value assigned to |last1=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-285)break;-- next enum[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-286)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-287)enum_alias = alias:gsub ('#', '');-- replace '#' to make 'last'[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-288)if params[enum_alias] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-289)names[enum] = params[enum_alias];-- found so save the value assigned to |last=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-290)break;-- next enum[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-291)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-292)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-293)else-- here for enum 2, 3, 4[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-294)if params[enum_alias] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-295)names[enum] = params[enum_alias];-- found so save the value assigned to |lastn=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-296)break;-- next enum[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-297)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-298)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-299)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-300)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-301)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-302)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-303)for enum=1, 4 do-- spin through the names table and[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-304)local name = names[enum];[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-305)if not name then-- when nameholding parameter n is not present (nil)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-306)name = '';-- convert to empty string for concatenation[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-307)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-308)name = name:gsub('%(%((.-)%)%)', '%1');-- remove accept-as-written markup if present[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-309)names[enum] = name;-- save the modified name[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-310)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-311)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-312)local name_str = table.concat (names);-- concatenate the names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-313)return '' ~= name_str and name_str or nil;-- return the concatenation if not empty string; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-314)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-315)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-316)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-317)--[[--------------------------< T E M P L A T E _ S T R I P >--------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-318)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-319)removes the citation or havrc template's {{[and](https://freemwiki.com/wiki/Template:And "Template:And")}} markup then removes, in whole, any templates found inside the[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-320)citation or harvc template.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-321)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-322)Templates are not allowed in parameters that are made part of COinS metadata; yet, they will appear. cs1|2 does[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-323)not see the template markup but instead sees the result of the template as html. cs1|2 strips the html which[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-324)leaves the displayed value for the anchor id. We can't do that here so, because templates aren't allowed in[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-325)parameters, we simply discard any templates found in the cs1|2 template.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-326)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-327)this may leave a |lastn= parameter empty which will be treated as if it were really empty as cs1|2 do (three authors,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-328)|last2= empty -> CITEREFLast1Last3YYYY (the harv and sfn render: 'Last1, & Last3 YYYY' with CITEREFLast1Last3YYYY).[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-329)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-330)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-331)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-332)local function template_strip (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-333)template = template:gsub ('^{{%s*', ''):gsub ('%s*}}$', '', 1);-- remove outer {{[and](https://freemwiki.com/wiki/Template:And "Template:And")}} (cs1|2 template delimiters with trailing/leading whitespace)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-334)template = template:gsub ('%b{}', '');-- remove any templates from the cs1|2 template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-335)return template;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-336)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-337)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-338)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-339)--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-340)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-341)Returns a string where all of lua's magic characters have been escaped. This is important because functions like[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-342)string.gsub() treat their pattern and replace strings as patterns, not literal strings.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-343)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-344)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-345)local function escape_lua_magic_chars (argument)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-346)argument = argument:gsub("%%", "%%%%");-- replace % with %%[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-347)argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1");-- replace all other lua magic pattern characters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-348)return argument;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-349)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-350)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-351)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-352)--[=[-------------------------< W I K I L I N K _ S T R I P >--------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-353)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-354)Wikilink markup does not belong in an anchor id and can / does confuse the code that parses apart citation and[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-355)harvc templates so here we remove any wiki markup:[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-356)[[[link|label]]](https://freemwiki.com/wiki/Link "Link") -> label[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-357)[[[link]]](https://freemwiki.com/wiki/Link "Link") -> link[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-358)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-359)]=][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-360)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-361)local function wikilink_strip (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-362)for wikilink in template:gmatch ('%[%b[]%]') do-- get a wikilink[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-363)template = template:gsub ('%[%b[]%]', '__57r1P__', 1);-- install a marker[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-364)if wikilink:match ('%[%[.-|(.-)%]%]') then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-365)wikilink = wikilink:match ('%[%[.-|(.-)%]%]');-- extract label from complex [[[link|label]]](https://freemwiki.com/wiki/Link "Link") wikilink[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-366)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-367)wikilink = wikilink:match ('%[%[(.-)%]%]');-- extract link from simple [[[link]]](https://freemwiki.com/wiki/Link "Link") wikilinks[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-368)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-369)wikilink = escape_lua_magic_chars (wikilink);-- in case there are lua magic characters in wikilink[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-370)template = template:gsub ('__57r1P__', wikilink, 1);-- replace the marker with the appropriate text[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-371)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-372)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-373)return template;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-374)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-375)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-376)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-377)--[[--------------------------< T E M P L A T E _ N A M E _ G E T >--------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-378)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-379)return the citation or harvc template's name; convert to lower case and trim leading and trailing whitespace;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-380)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-381)when the template is a sandbox the subpage portion of the template name is omitted from the returned template name[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-382) {{[Cite book/new](https://freemwiki.com/wiki/Template:Cite_book/new "Template:Cite book/new")|...}} returns cite book[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-383)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-384)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-385)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-386)local function template_name_get (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-387)local template_name = template:match ('^{{%s*([^/|}]+)');-- get template name; ignore subpages ~/new, ~/sandbox; parser functions[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-388)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-389)if not template_name or template_name:match ('^#') then-- parser functions, magic words don't count as templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-390)return nil;-- could not get template name from (possibly corrupt) template; extraneous opening { mid template can cause this;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-391)end;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-392)template_name = template_name:gsub ('%s*$', '');-- trim trailing whitespace; leading whitespace already removed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-393)return Lang_obj:ucfirst (template_name);-- first character in template name must be uppercase (same as canonical template name) TODO: better way to do this?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-394)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-395)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-396)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-397)--[[--------------------------< T E M P L A T E _ P A R A M S _ G E T >----------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-398)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-399)parse apart a template's parameters and store in the params table where key is the parameter's name and value is[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-400)the parameter's value; empty parameters are not saved[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-401)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-402)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-403)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-404)local function template_params_get (template, params_t)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-405)template = wikilink_strip (template);-- because piped wikilinks confuse code that builds params_t{} and because wikilinks not allowed in an anchor id[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-406)-- strip templates after getting |ref= value because |ref={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} and |ref={{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} are allowed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-407)template = template_strip (template);-- because template markup can confuse code that builds params_t{} and because templates in name parameters are not allowed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-408)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-409)local temp_t = mw.text.split (template, '%s*|%s*');--split on the pipe[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-410)for _, param in ipairs (temp_t) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-411)if param:find ('=', 1, true) then-- a named parameter?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-412)local k, v = param:match ('%s*([^=]-)%s*=%s*([^|}]+)');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-413)if v then-- there must be a value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-414)if '' ~= v and not v:match ('^%s$') then-- skip when value is empty string or only whitespace[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-415)params_t[k] = mw.text.trim (v);-- add trimmed value else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-416)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-417)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-418)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-419)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-420)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-421)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-422)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-423)--[[--------------------------< C I T E R E F _ M A K E _ H A R V C >------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-424)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-425)makes anchor_id from {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} or redirects[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-426)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-427)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-428)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-429)local function anchor_id_make_harvc (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-430)local date = date_get (template, alias_patterns_harvc_date);-- get date; done here because might be in {{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")}}; return date if valid; empty string else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-431)local anchor_id;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-432)local params = {};-- table of harvc parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-433)local id;-- custom anchor id for this {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-434)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-435)id = template:match ('|%s*id%s*=%s*(%b{})');-- in case |id={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}}; done here because templates will be stripped[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-436)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-437)template_params_get (template, params);-- build a table of template parameters and their values; this strips wikilinks and templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-438)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-439)if id then-- when set is {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-440)return sfnref_get (id);-- returns content of {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-441)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-442)if params.id then-- custom anchor for this {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} template (text)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-443)return params.id;-- |id= value as written[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-444)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-445)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-446)anchor_id = names_get (params, aliases_harvc_author);-- get the harvc contributor names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-447)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-448)if anchor_id then-- if names were gotten[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-449)return 'CITEREF' .. anchor_id .. date;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-450)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-451)return nil;-- no names; no anchor_id[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-452)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-453)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-454)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-455)--[[--------------------------< A N C H O R _ I D _ M A K E _ W R A P P E R >----------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-456)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-457)for wrapper templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-458)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-459)inspect externally visible |ref= to decide what to do:[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-460) |ref= - empty or missing: get names and date from whitelist defaults; override defaults from externally visible template parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-461) |ref=harv - same as empty or missing[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-462) |ref={{[SfnRef](https://freemwiki.com/wiki/Template:SfnRef "Template:SfnRef")|name|name|name|name|year}} - assemble an anchor id from {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} positional parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-463) |ref={{[Harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")|name|name|name|name|year}} - assemble an anchor id from {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} positional parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-464) |ref=none - skip; do nothing because an anchor id intentionally suppressed; TODO: keep with a type code of '0'?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-465) |ref= - save param value because may match an anchor id override value in {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}} template |ref= parameter or {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} |id= parameter[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-466)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-467)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-468)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-469)local function anchor_id_make_wrapper (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-470)local ref;-- content of |ref=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-471)local template_name;-- name of the template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-472)local anchor_id;-- the assembled anchor id from this template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-473)local date;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-474)local name_default;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-475)local date_default;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-476)local vol;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-477)local params = {};-- table of template parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-478)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-479)template_name = template_name_get (template);-- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-480)if not template_name or template_skip[template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-481)return nil;-- could not extract template name from (possibly corrupted) template (extraneous opening { in the template will cause this)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-482)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-483)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-484)date = date_get (template, alias_patterns_date);-- get date; done here because might be in {{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-485)-- if '' == date then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-486)-- date = whitelist.wrapper_templates[template_name][2] or ''; -- no externally visible date so get default date[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-487)-- end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-488)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-489)ref = template:match ('|%s*ref%s*=%s*(%b{})');-- first look for |ref={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or |ref={{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} because we will strip templates from the wrapper template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-490)if not ref then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-491)if template:match ('|%s*ref%s*=([^|}]+)') then-- |ref={{[template](https://freemwiki.com/wiki/Template:Template "Template:Template")}} not found; if there is a |ref= param with an assigned value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-492)ref = template:match ('|%s*ref%s*=([^|}]+)');-- get the value; whitespace is a 'value'[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-493)if ref then-- nil when |ref=|... or when |ref=}} (no spaces between assignment operator and pipe or closing brace)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-494)ref = mw.text.trim (ref);-- something, could be just whitespace, so trim leading / trailing whitespace[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-495)if '' == ref then-- trimming a string of whitespace makes an empty string[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-496)ref = nil;-- make empty ref same as missing ref[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-497)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-498)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-499)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-500)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-501)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-502)template_params_get (template, params);-- build a table of template parameters and their values[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-503)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-504) local wrap_data = whitelist.wrapper_templates[template_name][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-505)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-506)if wrap_data[1] then -- is this wrapper a simple-default wrapper?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-507)name_default = wrap_data[1]; -- get the default names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-508)date_default = wrap_data[2]; -- get the default date[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-509)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-510)vol = params['volume'] or 'default';[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-511) local fascicle = params['fascicle'] -- some templates use "fascicle" to mean "subvolume"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-512) if fascicle then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-513) local subvol = vol..'/'..fascicle -- if fascicle is used, subvolume = "vol/fascicle"[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-514) if wrap_data[subvol] then -- if subvolume exists, use it, otherwise fall back to volume[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-515) vol = subvol[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-516) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-517) end [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-518)if not wrap_data[vol] then -- make sure this volume exists[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-519)vol = 'default';-- doesn't exist, use default volume[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-520)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-521)name_default = wrap_data[vol][1]; -- get the default names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-522)date_default = wrap_data[vol][2]; -- get the default date[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-523)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-524)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-525)if 'harv' == ref or not ref then-- |ref=harv specified or |ref= missing or empty[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-526)anchor_id = names_get (params, aliases_contributor) or-- get contributor, author, or editor names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-527)names_get (params, aliases_author) or[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-528)vnames_get (params, 'vauthors') or-- |vauthors=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-529)names_get (params, aliases_editor) or[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-530)vnames_get (params, 'veditors') or-- |veditors=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-531)name_default;-- default names from whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-532)-- whitelist.wrapper_templates[template_name][1]; -- default names from whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-533)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-534)if '' == date then-- if date not provided in the template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-535)date = date_default;-- use the default date from whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-536)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-537)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-538)if anchor_id then-- if names were gotten[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-539)anchor_id = 'CITEREF' .. anchor_id .. date;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-540)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-541)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-542)elseif ref:match ('%b{}') then-- ref holds a template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-543)anchor_id = sfnref_get (ref);-- returns content of {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-544)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-545)elseif 'none' == ref then-- |ref=none[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-546)return nil;-- anchor id expicitly suppressed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-547)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-548)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-549)anchor_id = ref;-- |ref= may match an anchor id override value in {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}} template |ref= parameter[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-550)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-551)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-552)return anchor_id;-- anchor_id text; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-553)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-554)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-555)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-556)--[[--------------------------< A N C H O R _ I D _ M A K E _ C S 1 2 >----------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-557)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-558)for cs1|2 template and cs1-like templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-559)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-560)inspect |ref= to decide what to do:[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-561) |ref= - empty or missing: get names and date from template parameters; all cs1|2 create CITEREF anchor IDs[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-562) |ref=harv - get names and date from template parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-563) |ref={{[SfnRef](https://freemwiki.com/wiki/Template:SfnRef "Template:SfnRef")|name|name|name|name|year}} - assemble an anchor id from {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} positional parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-564) |ref={{[Harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")|name|name|name|name|year}} - assemble an anchor id from {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} positional parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-565) |ref=none - skip; do nothing because an anchor id intentionally suppressed; TODO: keep with a type code of '0'?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-566) |ref= - save param value because may match an anchor id override value in {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}} template |ref= parameter or {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} |id= parameter[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-567)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-568)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-569)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-570)local function anchor_id_make_cs12 (template)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-571)local ref;-- content of |ref=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-572)local template_name;-- name of the template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-573)local anchor_id;-- the assembled anchor id from this template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-574)local date;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-575)local params = {};-- table of template parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-576)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-577)template_name = template_name_get (template);-- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-578)if not template_name or template_skip[template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-579)return nil;-- could not extract template name from (possibly corrupted) template (extraneous opening { in the template will cause this)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-580)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-581)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-582)if redirects_patent[template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-583)date = date_get (template, alias_patterns_patent_date);-- get date; done here because might be in {{[date](https://freemwiki.com/wiki/Template:Date "Template:Date")}} [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-584)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-585)date = date_get (template, alias_patterns_date);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-586)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-587)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-588)ref = template:match ('|%s*ref%s*=%s*(%b{})');-- first look for |ref={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or |ref={{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} because we will strip templates from the cs1|2 template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-589)if not ref then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-590)if template:match ('|%s*ref%s*=([^|}]+)') then-- |ref={{[template](https://freemwiki.com/wiki/Template:Template "Template:Template")}} not found; if there is a |ref= param with an assigned value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-591)ref = template:match ('|%s*ref%s*=([^|}]+)');-- get the value; whitespace is a 'value'[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-592)if ref then-- nil when |ref=|... or when |ref=}} (no spaces between assignment operator and pipe or closing brace)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-593)ref = mw.text.trim (ref);-- something, could be just whitespace, so trim leading / trailing whitespace[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-594)if '' == ref then-- trimming a string of whitespace makes an empty string[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-595)ref = nil;-- make empty ref same as missing ref[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-596)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-597)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-598)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-599)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-600)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-601)template_params_get (template, params);-- build a table of template parameters and their values[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-602)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-603)if 'harv' == ref or not ref then-- |ref=harv specified or |ref= missing or empty[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-604)if redirects_patent[template_name] then-- if this is a cite patent template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-605)anchor_id = names_get (params, aliases_inventor);-- inventor names only[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-606)else-- cs1|2 template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-607)anchor_id = names_get (params, aliases_contributor) or-- get contributor, author, or editor names[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-608)names_get (params, aliases_author) or[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-609)vnames_get (params, 'vauthors') or-- |vauthors=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-610)names_get (params, aliases_editor) or[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-611)vnames_get (params, 'veditors');-- |veditors=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-612)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-613)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-614)if anchor_id then-- if names were gotten[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-615)anchor_id = 'CITEREF' .. anchor_id .. date;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-616)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-617)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-618)elseif ref:match ('%b{}') then-- ref holds a template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-619)anchor_id = sfnref_get (ref);-- returns content of {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-620)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-621)elseif 'none' == ref and not redirects_patent[template_name] then-- |ref=none; not supported by cite patent[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-622)return nil;-- anchor id expicitly suppressed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-623)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-624)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-625)anchor_id = ref;-- |ref= may match an anchor id override value in {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}} template |ref= parameter[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-626)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-627)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-628)return anchor_id;-- anchor_id text; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-629)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-630)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-631)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-632)--[[--------------------------< L I S T _ A D D >--------------------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-633)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-634)adds an - to
table; for anchor IDs, the boolean argument must be set true; no return value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-635)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-636)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-637)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-638)local function list_add (item, list, encode)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-639)if item then-- if there was an item[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-640)if encode then-- for anchor IDs ...[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-641)item = mw.uri.anchorEncode (item);-- encode to remove wikimarkup, convert spaces to underscores etc[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-642)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-643)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-644)if not list[item] then-- if not already saved[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-645)list[item] = 1;-- save it [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-646)else-- here when this item already saved[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-647)list[item] = list[item] + 1;-- to indicate that there are multiple items[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-648)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-649)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-650)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-651)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-652)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-653)--[[--------------------------< A N C H O R _ I D _ M A K E _ A N C H O R >------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-654)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-655)make anchor IDs from {{[anchor](https://freemwiki.com/wiki/Template:Anchor "Template:Anchor")}}; there may be more than one because {{[anchor](https://freemwiki.com/wiki/Template:Anchor "Template:Anchor")}} is not limited to the number of[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-656)anchors it may hold.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-657)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-658)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-659)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-660)local function anchor_id_make_anchor (template, anchor_id_list)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-661)template = template:gsub ('^{{[^|]+|', ''):gsub ('}}$', '', 1);-- remove outer {{[and](https://freemwiki.com/wiki/Template:And "Template:And")}} and template name[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-662)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-663)template = wikilink_strip (template);-- strip any wikilink markup (there shouldn't be any but just in case)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-664)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-665)local params = {};[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-666)local anchor_id;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-667)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-668)for param in template:gmatch ('%b{}') do-- loop through the template; remove and save templates (presumed to be sfnref or harvid)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-669)table.insert (params, param);-- save it[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-670)template = template:gsub ('%b{}', '', 1);-- remove it from source template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-671)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-672)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-673)for _, t in ipairs (params) do-- spin through the templates in params[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-674)anchor_id = sfnref_get (t);-- attempt to decode {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} and {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-675)if anchor_id then-- nil when not {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-676)list_add (anchor_id, anchor_id_list, true);-- add anchor ID to the list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-677)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-678)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-679)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-680)template = template:gsub ('|%s*|', '|');-- when pipe follows pipe with or without white space, remove extraneous pipe[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-681)template = template:gsub ('^|', ''):gsub('|$', '');-- remove extraneous leading and trailing pipes[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-682)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-683)params = mw.text.split (template, '%s*|%s*');-- split at the pipe and remove extraneous space characters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-684)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-685)for _, t in ipairs (params) do-- spin through the anchor IDs[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-686)anchor_id = mw.text.trim (t);-- trim white space[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-687)if '' ~= anchor_id then-- should always have something[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-688)list_add (anchor_id, anchor_id_list, true);-- add anchor ID to the list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-689)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-690)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-691)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-692)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-693)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-694)--[[--------------------------< T E M P L A T E _ L I S T _ A D D >--------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-695)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-696)makes a list of templates use in the article.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-697)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-698)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-699)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-700)local function template_list_add (template, template_list)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-701)local template = template:match ('{{%s*(.-)[|}]');-- keep the case of the template - this is different from template_name_get()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-702)if template and not template:match ('^#') then-- found a template or magic word; ignore magic words[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-703)template=mw.text.trim (template);-- trim whitespace[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-704)template = Lang_obj:ucfirst (template);-- first character in template name must be uppercase (same as canonical template name) TODO: better way to do this?[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-705)list_add (template, template_list);-- add to list with (unused) tally[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-706)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-707)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-708)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-709)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-710)--[[--------------------------< A N C H O R _ I D _ L I S T _ M A K E >----------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-711)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-712)makes a list of anchor ids from cs1|2, cs1|2-like, vcite xxx, harvc, anchor, wikicite templates[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-713)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-714)Because cs1|2 wrapper templates can, and often do, hide the author and date parameters inside the wrapper,[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-715)these parameters are not available in the article's wikisource so {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}}, {{[sfn](https://freemwiki.com/wiki/Template:Sfn "Template:Sfn")}}, and {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} templates that[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-716)link correctly to those wrapper templates will incorrectly show error messages. Use |ignore-err=yes in the {{[harv](https://freemwiki.com/wiki/Template:Harv "Template:Harv")}},[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-717){{[sfn](https://freemwiki.com/wiki/Template:Sfn "Template:Sfn")}}, and {{[harvc](https://freemwiki.com/wiki/Template:Harvc "Template:Harvc")}} templates to supress the error message.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-718)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-719)creates a list of templates used in the article for use with the whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-720)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-721)creates a list of article-local whitelisted anchor IDs from {{[sfn whitelist](https://freemwiki.com/wiki/Template:Sfn_whitelist "Template:Sfn whitelist")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-722)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-723)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-724)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-725)local function anchor_id_list_make ()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-726) local anchor_id_list = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-727) local template_list = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-728) local article_whitelist = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-729)local article_content = article_content_get ();-- attempt to get this article's content[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-730)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-731)if article_content == '' then-- when there is no article content[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-732)return '';-- no point in continuing[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-733)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-734)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-735)local template;-- place to hold the template that we found[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-736)local template_name;[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-737)local anchor_id;-- place to hold an anchor id as it is extracted / decoded[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-738)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-739)local find_pattern = '%f[{]{{[^{]';[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-740)local tstart, tend = article_content:find (find_pattern);-- find the first template; do not find template variables: {{{[template var](https://freemwiki.com/wiki/Template:Template_var "Template:Template var")|}}} [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-741)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-742)while tstart do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-743)template = article_content:match ('%b{}', tstart);-- get the whole template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-744)if not template then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-745)break;-- template is nil for some reason (last template missing closing }} for example) so declare ourselves done[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-746)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-747)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-748)template_name = template_name_get (template);-- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-749)template_list_add (template, template_list);-- add this template's name to the list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-750)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-751)if data.known_templates_cs12 [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-752)anchor_id = anchor_id_make_cs12 (template);-- extract an anchor id from this template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-753)list_add (anchor_id, anchor_id_list, true)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-754)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-755)elseif data.known_templates_vcite [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-756)local ref = template:match ('|%s*ref%s*=%s*(%b{})');-- first look for |ref={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or |ref={{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}} because we will strip templates from the vcite template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-757)if ref then-- |ref={{[template](https://freemwiki.com/wiki/Template:Template "Template:Template")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-758)anchor_id = sfnref_get (ref);-- returns content of {{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or {{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}; nil else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-759)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-760)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-761)local params = {};[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-762)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-763)template_params_get (template, params);-- build a table of template parameters and their values[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-764)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-765)anchor_id = params['ref'];-- when both set, vcite uses value from |ref=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-766)if not anchor_id and params['harvid'] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-767)anchor_id = 'CITEREF' .. params['harvid'];-- in vcite, |harvid= auto-adds 'CITEREF' prefix to the value in |harvid=[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-768)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-769)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-770)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-771)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-772)elseif data.known_templates_harvc [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-773)anchor_id = anchor_id_make_harvc (template);-- extract an anchor id from this template[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-774)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-775)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-776)elseif data.known_templates_wikicite [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-777)local ref = template:match ('|%s*ref%s*=%s*(%b{})');-- first look for |ref={{[sfnref](https://freemwiki.com/wiki/Template:Sfnref "Template:Sfnref")}} or |ref={{[harvid](https://freemwiki.com/wiki/Template:Harvid "Template:Harvid")}}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-778)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-779)if ref then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-780)anchor_id = sfnref_get (ref);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-781)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-782)elseif template:match ('|%s*ref%s*=([^|}]+)') then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-783)anchor_id = template:match ('|%s*ref%s*=([^|}]+)');-- plain-text[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-784)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-785)elseif template:match ('|%s*id%s*=%s*(%b{})') then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-786)ref = template:match ('|%s*id%s*=%s*(%b{})');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-787)anchor_id = 'Reference-' .. sfnref_get (ref);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-788)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-789)elseif template:match ('|%s*id%s*=([^|}]+)') then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-790)anchor_id = 'Reference-' .. template:match ('|%s*id%s*=([^|}]+)');-- plain-text[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-791)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-792)else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-793)anchor_id = nil;-- no matches, ensure that anchor_id has no value[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-794)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-795)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-796)if anchor_id then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-797)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-798)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-799)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-800)elseif data.known_templates_anchor [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-801)anchor_id_make_anchor (template, anchor_id_list);-- extract anchor ids from this template if any[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-802)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-803)elseif data.known_templates_sfn_whitelist [template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-804)template = template:gsub ('^{{[^|]+|', ''):gsub ('}}$', '', 1);-- remove outer {{[and](https://freemwiki.com/wiki/Template:And "Template:And")}} and template name[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-805)template = mw.text.trim (template, '%s|');-- trim leading trailing white space and pipes[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-806)template = mw.text.split (template, '%s*|%s*');-- make a table of the template's parameters[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-807)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-808)for _, anchor_id in ipairs (template) do-- spin through this template's parameter[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-809)if '' ~= anchor_id and not article_whitelist[anchor_id] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-810)anchor_id = mw.uri.anchorEncode (anchor_id)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-811)article_whitelist[anchor_id] = 1;-- add to the whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-812)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-813)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-814)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-815) elseif template_name and whitelist.wrapper_templates[template_name] then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-816)anchor_id = anchor_id_make_wrapper (template);-- extract an anchor id from this template if possible[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-817)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-818)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-819)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-820)elseif template_name and template_name:match ('^Cit[ea]') then-- not known, not known wrapper; last gasp, try as cs1-like[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-821)anchor_id = anchor_id_make_cs12 (template);-- extract an anchor id from this template if possible[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-822)list_add (anchor_id, anchor_id_list, true);[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-823)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-824)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-825)tstart, tend = article_content:find (find_pattern, tend);-- search for another template; begin at end of last search[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-826)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-827)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-828)mw.logObject (anchor_id_list, 'anchor_id_list');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-829)mw.logObject (template_list, 'template_list');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-830)mw.logObject (article_whitelist, 'article_whitelist');[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-831)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-832)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-833) global_anchor_id_list = anchor_id_list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-834) global_template_list = template_list[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-835) global_article_whitelist = article_whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-836)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-837)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-838)--[[--------------------------< C I T E R E F _ P A T T E R N S _ M A K E >--------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-839)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-840)Scans template_list to look for wrapper templates that generate citerefs that require Lua patterns.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-841)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-842)This scan is only done once per page load, to save time[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-843)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-844)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-845)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-846)local function citeref_patterns_make()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-847) if not global_template_list then return end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-848) local citeref_patterns = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-849) local template_patterns = whitelist.wrapper_template_patterns[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-850) for _, p in ipairs(template_patterns) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-851) for _, t in ipairs(p[1]) do -- loop through list of template wrappers[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-852) if global_template_list[t] then -- if wrapper is found in article, record corresponding patterns[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-853) for _, pat in ipairs(p[2]) do[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-854) table.insert(citeref_patterns, pat)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-855) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-856) break[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-857) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-858) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-859) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-860)mw.logObject(citeref_patterns,'citeref_patterns')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-861) return citeref_patterns[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-862)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-863)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-864)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-865)--[[--------------------------< E X P O R T E D _ T A B L E S >------------------------------------------------[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-866)]][](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-867)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-868)-- First create global_anchor_id_list, global_template_list, global_article_whitelist[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-869)anchor_id_list_make()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-870)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-871)-- Then stuff them (and derived tables) into return table[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-872)return {[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-873)anchor_id_list = global_anchor_id_list or {}, -- table of anchor ids available in this article[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-874)article_whitelist = global_article_whitelist or {},-- table of anchor ids with false-positive error message to be suppressed[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-875)template_list = global_template_list or {}, -- table of templates used in this article[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-876) citeref_patterns = citeref_patterns_make() or {} -- table of Lua patterns to search for citeref from wrappers[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3AFootnotes%2Fanchor_id_list#L-877)}
Retrieved from "[https://freemwiki.com/index.php?title=Module:Footnotes/anchor_id_list&oldid=580070](https://freemwiki.com/index.php?title=Module:Footnotes/anchor_id_list&oldid=580070)"
[**Last edited 9 months ago** by Lukegao](https://freemwiki.com/index.php?title=Module:Footnotes/anchor_id_list&action=history)
#### Languages
* [English](https://freemwiki.com/wiki/Module:Footnotes/ "Module:Footnotes/ – English")
freem
* This page was last edited on 21 October 2025, at 06:18.
* Content is available under [Creative Commons Attribution-ShareAlike 4.0](https://creativecommons.org/licenses/by-sa/4.0/) unless otherwise noted. FreemWiki is operated by **FINGERPOWER DIGITAL TECHNOLOGY LLC** (Colorado, Entity ID 20221978727).
* [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy)
* [About](https://freemwiki.com/wiki/About)
* [Terms of Service](https://freemwiki.com/wiki/Terms_of_Service)
* [Desktop](https://freemwiki.com/index.php?title=Module:Footnotes/anchor_id_list&mobileaction=toggle_view_desktop)