Каждое его изменение создаёт дополнительную нагрузку на серверы проекта. Пожалуйста, убедитесь в адекватности и правильности ваших изменений, проверьте их на тестовых страницах.
Этот модуль относится к критическим. У него очень много включений или он используется с подстановкой. Из-за опасности вандализма или ошибочного редактирования он был защищён.
Прежде, чем вносить какие-либо изменения в данный модуль, просьба оттестировать их в /песочнице и проверить результат на странице с /контрольными примерами. Изменения могут быть внесены после этого в данный модуль всего одной правкой.
Выдаёт вики-текст ссылки на заданный источник для подстановки внутрь сноски или списка литературы. См. шаблоны {{source}} и {{ВД-Источник}}, использующие данную функцию. Поддерживает следующие аргументы:
Кол программы
Комментарии к нему
текст = frame.args[1]
текст =
— анонимный аргумент, задающий идентификатор объекта на викиданных, по которому нужно сгенерировать ссылку. Например, Q20750516.
Кол программы
Комментарии к нему
текст = frame.args['ref']
текст =
— задаёт метку ref, которую в дальнейшем можно будет использовать в шаблонах типа {{sfn}}.
Кол программы
Комментарии к нему
текст = frame.args['ref-year']
текст =
— задаёт метку ref-year, которая используется аналогично метке ref.
Кол программы
Комментарии к нему
текст = frame.args['part']
текст =
— дополнительный аргумент, позволяющий уточнить часть источника, на которую идёт ссылка (например, главу в книге).
Кол программы
Комментарии к нему
текст = frame.args['parturl']
текст =
— ссылка, которую следует поставить на часть, описанную предыдущим аргументом.
Кол программы
Комментарии к нему
текст = frame.args['pages']
текст =
— конкретные страницы в источнике, на которые ведётся ссылка.
Кол программы
Комментарии к нему
текст = frame.args['url']
текст =
— позволяет явно указать, какую ссылку нужно будет проставить на источник.
Кол программы
Комментарии к нему
текст = frame.args['volume']
текст =
— позволяет явно указать том источника, на который идёт ссылка.
Кол программы
Комментарии к нему
текст = frame.args['issue']
текст =
— позволяет явно указать выпуск источника, на который идёт ссылка.
Пробрасывание большей части аргументов происходит в utils.copyArgsToSnaks. Сам переданный фрейм сохраняется в p.currentFrame для дальнейшего использования, а на основе переданных аргументов функцией artificialSnaks создаются искусственные снеки, которые ссылаются на источник, указанный в
Кол программы
Комментарии к нему
текст = frame.args[1]
текст =
, через свойства P248 (stated in) и P805 (statement is subject of). Затем данные передаются в renderReferenceImpl для дальнейшей обработки.
Выдаёт вики-текст готовой сноски на заданный источник. Поддерживает те же аргументы, что и p.renderSource, кроме ref и ref-year. См. шаблоны {{source-ref}} и {{ВД-Сноска}}, использующие данную функцию. Также используется в Модуль:Wikidata для отображения ссылок, указанных возле утверждений на викиданных. Если currentEntity и reference отсутствуют, создаются искусственные снеки с помощью функции artificialSnaks, после чего они передаются в renderReferenceImpl. Если вики-текст для сноски был успешно сгенерирован, он оборачивается в тэг
Преобразует полное имя в пару {фамилии через пробел, инициалы имён через пробел}. Реализована в виде разбора случаев, которые можно встретить на викиданных:
Преобразует список имён value в викитекст в соответствии со списком опций options. В опциях должны быть проставлены следующие поля:
separator — разделитель в списке;
conjunction — разделитель перед последним элементом списка;
format — функция, преобразующая имена к некоторому нормализованному виду (например, personNameToAuthorName);
nolinks — логическое значение, должно быть истинным если проставление ссылок нежелательно;
preferids — логическое значение, должно быть истинным если нужно вернуть id с викиданных, а не имена.
Если в списке больше maxAuthors (на текущий момент 10) людей, заменяет остальных на и др. или его аналоги (если в контексте указан язык, то используется i18nEtAl[context.lang], иначе используется i18nEtAlDefault).
Если context.lang отличается от i18nDefaultLanguage (в нашем разделе русский), то указание об этом приписывается к result с помощью Модуль:Languages в формате {{ref-lang}}.
если хотя бы один из указанных параметров определён. Неуказанная часть опускается вместе с соответствующей пунктуацией. В частности, двоеточие ставится только если указано src.place и хотя бы что-то из src.publisher и src.year, запятая ставится только если указаны и src.publisher, и src.year. Тире и точка ставятся если указан хотя бы один из параметров.
текст = — letter_vol src.volume, letter_iss src.issue.
текст =
если хотя бы один из указанных параметров определён. Запятая ставится если указаны оба параметра. letter_vol и letter_iss определяются по context.lang (например,
если src.pages определён, при этом в качестве разделителя в src.pages, если это диапозон страниц, используется символ «—», а letter определяется исходя из context.lang (например,
текст = — (src.bookSeries; letter_vol src.bookSeriesVolume, letter_iss src.bookSeriesIssue)
текст =
если src.bookSeries определено. Точка с запятой ставится только если определено src.bookSeriesVolume или src.bookSeriesIssue, запятая ставится если определены оба параметра. letter_vol и letter_iss определяются из context.lang, аналогично тому, как это делается в appendVolumeAndIssue.
Добавляет к result идентификаторы ISBN, ISSN, DOI, PMID и arXiv если те определены. Идентификаторы приписываются через тире, более точный формат определён в таблицах options_commas, options_issn, options_doi, options_pmid и options_arxiv.
Создаёт искусственные снеки, которые ссылаются на источник с идентификатором frame.args[1] через свойства P248 (stated in) и P805 (statement is subject of), а также пробрасывает в них аргументы (том, выпуск и т. д.).
localp={};localu=require('Module:Sources/utils')locali18nDefaultLanguage='ru';locali18nEtAlDefault=' et al.';locali18nEtAl={ru=' и др.',}locali18nEditors={fr='',de='Hrsg.: ',es='',en='',it='',ru='под ред. ',}locali18nVolume={fr='Vol.',es='Vol.',en='Vol.',it='Vol.',ru='Т.',}locali18nIssue={en='Iss.',ru='вып.',}locali18nPages={fr='P.',de='S.',es='P.',en='P.',it='P.',ru='С.',}locali18nNumberOfPages={en='p.',ru='с.',}locali18nTirage={en='ed. size: %d',ru='%d экз.',}localmonthg={'января','февраля','марта','апреля','мая','июня','июля','августа',"сентября","октября","ноября","декабря"};localPREFIX_CITEREF="CITEREF_";localoptions_commas={separator=', ',conjunction=', ',format=function(src)returnsrcend,nolinks=false,preferids=false};localoptions_commas_short={separator=', ',conjunction=', ',format=function(src)returnsrcend,nolinks=false,preferids=false,short=true};localoptions_commas_nolinks={separator=', ',conjunction=', ',format=function(src)returnsrcend,nolinks=true,preferids=false};localoptions_commas_it={separator=', ',conjunction=', ',format=function(src)return"''"..src.."''"end,nolinks=false,preferids=false};localoptions_commas_it_short={separator=', ',conjunction=', ',format=function(src)return"''"..src.."''"end,nolinks=false,preferids=false,short=true};localoptions_commas_it_nolinks={separator=', ',conjunction=', ',format=function(src)return"''"..src.."''"end,nolinks=true,preferids=false};localoptions_citetypes={separator=' ',conjunction=' ',format=function(src)return'citetype_'..srcend,nolinks=true,preferids=true};localoptions_commas_authors={separator=', ',conjunction=', ',format=personNameToAuthorName,nolinks=false,preferids=false};localoptions_commas_responsible={separator=', ',conjunction=', ',format=personNameToResponsibleName,nolinks=false,preferids=false};localoptions_arxiv={separator='; ',conjunction='; ',format=function(id)return'[http://arxiv.org/abs/'..id..' arXiv:'..id..']'end,nolinks=true,preferids=false};localoptions_doi={separator='; ',conjunction='; ',format=function(doi)return'[http://dx.doi.org/'..doi..' doi:'..doi..']'end,nolinks=true,preferids=false};localoptions_issn={separator='; ',conjunction='; ',format=function(issn)return'[https://www.worldcat.org/issn/'..issn..' '..issn..']'end,nolinks=true,preferids=false};functionrenderSource(context,src)options_commas_authors.format=personNameToAuthorName;options_commas_responsible.format=personNameToResponsibleName;context.lang=getLangCode(getSingle(src.lang))ori18nDefaultLanguage;preprocessPlaces(src,context.lang);src.title=src.titleorgetSingle(src.url)or'\'\'(unspecified title)\'\''if(src.sourceIdandnotsrc.url)thenlocalentity=getEntity(context,src.sourceId);if(entity.sitelinksandentity.sitelinks[context.lang..'wikisource'])thensrc.url=':'..context.lang..':s:'..entity.sitelinks[context.lang..'wikisource'].title;endendif(notsrc.yearandsrc.dateOfPublication)thenlocaldate=getSingle(src.dateOfPublication);src.year=mw.ustring.sub(date,2,5);endif(notsrc.yearandsrc.dateOfCreation)thenlocaldate=getSingle(src.dateOfCreation);src.year=mw.ustring.sub(date,2,5);endlocalresult;if(src.author)thenresult=getPeopleAsWikitext(context,src.author,options_commas_authors);endif(notisEmpty(result))thenresult='<i class="wef_low_priority_links">'..result..'</i> ';elseresult='';endif(src.part)thenif(src.url)thenresult=result..wrapInUrl(src.url,toString(context,src.part,options_commas_nolinks));elseresult=result..toString(context,src.part,options_commas);endresult=result..' // '..toString(context,src.title,options_commas);else-- title onlyif(src.url)thenresult=result..wrapInUrl(src.url,toString(context,src.title,options_commas_nolinks));elseresult=result..toString(context,src.title,options_commas);endendif(src.subtitle)thenresult=result..": "..toString(context,src.subtitle,options_commas);endif(src.originaltitle)thenresult=result..' = '..toString(context,src.originaltitle,options_commas);endif(src.publication)thenif(type(src.publication.titleor'')~='string')thenerror('type of src.publication.title is not string but '..type(src.publication.title))end;result=result..' // '..toString(context,src.publication,options_commas_it_short);if(src.publication.subtitle)thenresult=result..': '..toString(context,src.publication.subtitle,options_commas_it_short);endendresult=result..'<span class="wef_low_priority_links">';if(src.editor)thenlocalprefix=i18nEditors[context.lang]ori18nEditors[i18nDefaultLanguage];result=result..' / '..prefix..getPeopleAsWikitext(context,src.editor,options_commas_responsible);endif(src.edition)thenresult=result..' — '..toString(context,src.edition,options_commas);endif(src.placeorsrc.publisherorsrc.year)thenresult=result..' — ';if(src.place)thenresult=result..toString(context,src.place,options_commas_short);if(src.publisherorsrc.year)thenresult=result..': ';endendif(src.publisher)thenresult=result..toString(context,src.publisher,options_commas_short);if(src.year)thenresult=result..', ';endendif(src.year)thenresult=result..toString(context,src.year,options_commas);endresult=result..'.';endif(src.volumeorsrc.issue)thenresult=result..' — ';if(src.volume)thenlocalletter=i18nVolume[context.lang]ori18nVolume[i18nDefaultLanguage];result=result..letter..' '..toString(context,src.volume,options_commas);if(src.issue)thenlocalletter=i18nIssue[context.lang]ori18nIssue[i18nDefaultLanguage];result=result..', '..letter..' '..toString(context,src.issue,options_commas)..'.';elseresult=result..'.';endelselocalletter=i18nIssue[context.lang]ori18nIssue[i18nDefaultLanguage];result=result..letter..' '..toString(context,src.issue,options_commas)..'.';endendif(src.pages)thenlocalletter=i18nPages[context.lang]ori18nPages[i18nDefaultLanguage];localstrPages=toString(context,src.pages,options_commas);strPages=mw.ustring.gsub(strPages,'[-—]','–');result=result..' — '..letter..' '..strPages..'.';endif(src.numberOfPages)thenlocalletter=i18nNumberOfPages[context.lang]ori18nNumberOfPages[i18nDefaultLanguage];result=result..' — '..toString(context,src.numberOfPages,options_commas)..' '..letter;endif(src.bookSeries)thenresult=result..' — ('..toString(context,src.bookSeries,options_commas)if(src.bookSeriesVolumeorsrc.bookSeriesIssue)thenresult=result..'; ';if(src.bookSeriesVolume)thenlocalletter=i18nVolume[context.lang]ori18nVolume[i18nDefaultLanguage];result=result..letter..' '..toString(context,src.bookSeriesVolume,options_commas);if(src.bookSeriesIssue)thenlocalletter=i18nIssue[context.lang]ori18nIssue[i18nDefaultLanguage];result=result..', '..letter..' '..toString(context,src.bookSeriesIssue,options_commas);elseresult=result;endelselocalletter=i18nIssue[context.lang]ori18nIssue[i18nDefaultLanguage];result=result..letter..' '..toString(context,src.bookSeriesIssue,options_commas);endendresult=result..')';endif(src.tirage)thenlocaltirageTemplate=i18nTirage[context.lang]ori18nTirage[i18nDefaultLanguage];result=result..' — '..toString(context,src.tirage,{separator='; ',conjunction=';',format=function(data)returnmw.ustring.format(tirageTemplate,data)end});endif(src.isbn)thenresult=result..' — ISBN '..toString(context,src.isbn,options_commas);endif(src.issn)thenresult=result..' — ISSN '..toString(context,src.issn,options_issn);endif(src.doi)thenresult=result..' — '..toString(context,src.doi,options_doi);endif(src.arxiv)thenresult=result..' — '..toString(context,src.arxiv,options_arxiv);endif(src.sourceId)thenif(src.typeandsrc.sourceId)then-- wrap into span to target from JSresult='<span class="wikidata_cite '..toString(context,src.type,options_citetypes)..'" data-entity-id="'..getSingle(src.sourceId)..'">'..result..'</span>'elseresult='<span class="wikidata_cite citetype_unknown" data-entity-id="'..getSingle(src.sourceId)..'">'..result..'</span>'endendif(src.accessdate)thenlocaldate=getSingle(src.accessdate);localpattern="(%-?%d+)%-(%d+)%-(%d+)T";localy,m,d=mw.ustring.match(date,pattern);y,m,d=tonumber(y),tonumber(m),tonumber(d);result=result.." <small>Проверено "..tostring(d).." "..monthg[m].." "..tostring(y)..".</small>";endresult=result..'</span>';-- append invisible links to all elements used by source for tracking purposeslocalresult=result..'<div style="display:none">';forkey,entityinpairs(context.cache)doresult=result..'<a href="https://wikidata.org'..mw.uri.localUrl('Track:'..key).path..'"></a>';endresult=result..'</div>'return{text=result,code=src.code};endfunctionrenderShortReference(src)context={cache={},lang=getSingle(src.lang)ori18nDefaultLanguage;};src.title=src.titleor'\'\'(unspecified title)\'\''localresult='[[#'..PREFIX_CITEREF..src.code..'|';if(src.author)thenresult=result..toString(context,src.author,options_authors_nolinks);elseresult=result..toString(context,src.title,options_commas_it_nolinks);endresult=result..']]'if(src.year)thenresult=result..', '..toString(context,src.year,options_commas);endif(src.volume)thenlocalletter=i18nVolume[context.lang]ori18nVolume[i18nDefaultLanguage];result=result..' — '..letter..' '..toString(context,src.volume,options_commas)..'.';endif(src.issue)thenlocalletter=i18nIssue[context.lang]ori18nIssue[i18nDefaultLanguage];result=result..' — '..letter..' '..toString(context,src.issue,options_commas)..'.';endif(src.pages)thenlocalletter=i18nPages[context.lang]ori18nPages[i18nDefaultLanguage];result=result..' — '..letter..' '..toString(context,src.pages,options_commas)..'.';endendfunctiongetPeopleAsWikitext(context,value,options)if(type(value)=='string')thenreturnoptions.format(value);elseif(type(value)=='table')thenif(value.id)then-- this is linkif(options.preferids)thenreturnvalue.id;elseif(options.nolinks)thenreturngetPersonNameAsLabel(context,value.id,value.label,options);elsereturngetPersonNameAsWikitext(context,value.id,value.label,options);endendendlocalresultList={};fori,tableValueinpairs(value)dolocalnextWikitext=getPeopleAsWikitext(context,tableValue,options);if(notisEmpty(nextWikitext))thentable.insert(resultList,nextWikitext);if(#resultList==4)then-- even 4 is too much, but we preserve 4th to mark that "it's more than 3"break;endendendlocalresultWikitext='';fori,wikitextinpairs(resultList)doif(i==4)thenresultWikitext=resultWikitext..(i18nEtAl[context.lang]ori18nEtAlDefault);break;endif(i~=1)thenresultWikitext=resultWikitext..', ';endresultWikitext=resultWikitext..wikitext;endreturnresultWikitext;endreturnoptions.format('(unknown type)');endfunctiongetPersonNameAsWikitext(context,entityId,customLabel,options)localpersonName=getPersonNameAsLabel(context,entityId,customLabel,options);if(personName==nil)thenreturnnil;endlocallink=getElementLink(context,entityId,nil);returnwrapInUrl(link,personName);endfunctiongetPersonNameAsLabel(context,entityId,providedLabel,options)-- would custom label provided we don't need to check entity at allif(notisEmpty(providedLabel))thenmw.log('Custom label provided for '..entityId);returnoptions.format(providedLabel);endlocalentity=getEntity(context,entityId);if(notentity)thenreturn'\'\'(entity '..entityId..' is missing)\'\''end;localpersonName=nil;-- support only labels so farif(entity.labels[context.lang])thenpersonName=entity.labels[context.lang].value;mw.log('Got person name of '..entityId..' from label: «'..personName..'»')endif(notisInstanceOf(entity,'Q5'))thenmw.log('Entity '..entityId..' is not a person');returnpersonName;endif(isEmpty(personName))thenreturn'\'\'(not translated to '..context.lang..')\'\'';elsereturnoptions.format(personName);endendfunctionpersonNameToAuthorName(fullName)if(notfullName)thenreturnfullName;endlocalf,i,o=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)\,%s(%a[%a\-]*)%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Fa, I. O.» match');returnf..' '..mw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'.';endlocalf1,f2,i=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a[%a\-]*)\,%s(%a[%a\-]*)%s*$');if(f1)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Fa Fa, I» match');returnf1..' '..f2..' '..mw.ustring.sub(i,1,1)..'.';endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «I. O. Fa» match');returnf..' '..i..'. '..o..'.';endlocali1,i2,i3,f=mw.ustring.match(fullName,'^%s*(%a)\.%s(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «I. O. ?. Fa» match');returnf..' '..i1..'. '..i2..'. '..i3..'.';end-- Joel J. P. C. Rodrigueslocali1,i2,i3,i4,f=mw.ustring.match(fullName,'^%s*(%a)[%a\-]+%s(%a)\.%s(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «I. O. ?. Fa» match');returnf..' '..i1..'. '..i2..'. '..i3..'. '..i4..'.';endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a)\.%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Im O. Fa» match');returnf..' '..mw.ustring.sub(i,1,1)..'. '..o..'.';endlocali1,i2,i3,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a)\.%s(%a)\.%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Im I. I. Fa» match');returnf..' '..mw.ustring.sub(i1,1,1)..'. '..i2..'. '..i3..'.';endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a[%a\-]*)%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Im Ot Fa» match');returnf..' '..mw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'.';endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]+)%s(%a[%a\-]+)%s+оглы%s+(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Im Ot оглы Fa» match');returnf..' '..mw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'.';endlocali1,i2,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]+)%s(%a[%a\-]+)%s+de%s+(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «I1 I2 de Fa» match');returnf..' '..mw.ustring.sub(i1,1,1)..'. '..mw.ustring.sub(i2,1,1)..'.';endlocali,f=mw.ustring.match(fullName,'^%s*(%a[%a\-\']+)%s(%a[%a\-\']+)%s*$');if(f)thenmw.log('personNameToAuthorName: «'..fullName..'»: have «Im Fa» match');returnf..' '..mw.ustring.sub(i,1,1)..'.';endmw.log('Unmatched any pattern: «'..fullName..'»');returnfullName;endfunctionpersonNameToResponsibleName(fullName)if(notfullName)thenreturnfullName;endlocalf,i,o=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)\,%s(%a[%a\-]*)%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Fa, I. O.» match');returnmw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'. '..f;endlocalf1,f2,i=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a[%a\-]*)\,%s(%a[%a\-]*)%s*$');if(f1)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Fa Fa, I» match');returnmw.ustring.sub(i,1,1)..' '..f1..' '..f2;endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('v: «'..fullName..'»: have «I. O. Fa» match');returni..'. '..o..'. '..f;endlocali1,i2,i3,f=mw.ustring.match(fullName,'^%s*(%a)\.%s(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «I. O. ?. Fa» match');returni1..'. '..i2..'. '..i3..'. '..f;end-- Joel J. P. C. Rodrigueslocali1,i2,i3,i4,f=mw.ustring.match(fullName,'^%s*(%a)[%a\-]+%s(%a)\.%s(%a)\.%s(%a)\.%s(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «I. O. ?. Fa» match');returni1..'. '..i2..'. '..i3..'. '..i4..'. '..f;endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a)\.%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Im O. Fa» match');returnmw.ustring.sub(i,1,1)..'. '..o..'. '..f;endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]*)%s(%a[%a\-]*)%s(%a[%a\-]*)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Im Ot Fa» match');returnmw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'. '..f;endlocali,o,f=mw.ustring.match(fullName,'^%s*(%a[%a\-]+)%s(%a[%a\-]+)%s+оглы%s+(%a[%a\-]+)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Im Ot оглы Fa» match');returnmw.ustring.sub(i,1,1)..'. '..mw.ustring.sub(o,1,1)..'. '..f;endlocali,f=mw.ustring.match(fullName,'^%s*(%a[%a\-\']+)%s(%a[%a\-\']+)%s*$');if(f)thenmw.log('personNameToResponsibleName: «'..fullName..'»: have «Im Fa» match');returnmw.ustring.sub(i,1,1)..'. '..f;endmw.log('Unmatched any pattern: «'..fullName..'»');returnfullName;endfunctionp.renderSource(frame)p.currentFrame=frame;localarg=frame.args[1];localrefAnchor=frame.args['ref'];localrefAnchorYear=frame.args['ref-year'];localargs={};args.part=frame.args['part'];args.parturl=frame.args['parturl'];args.pages=frame.args['pages'];args.refAnchor=frame.args['ref'];args.refAnchorYear=frame.args['ref-year'];args.url=frame.args['url'];returnp.renderSourceImpl(mw.text.trim(arg),args);endfunctionp.renderSourceImpl(entityId,args)args=argsor{};localsnaks={};snaks.P248={toWikibaseEntityIdSnak('P248',entityId)};copyArgsToSnaks(args,snaks);localrendered=renderReferenceImpl(mw.wikibase.getEntity(),{snaks=snaks},args.refAnchor,args.refAnchorYear);if(rendered)thenreturnrendered.textend;endfunctionp.renderReference(frame,currentEntity,reference)p.currentFrame=frame;-- template callif(frameandnotcurrentEntityandnotreference)thenlocalargs=frame.args;if(#frame.args==0)thenargs=frame:getParent().args;endlocalsnaks={};if(args[1])thensnaks.P248={toWikibaseEntityIdSnak("P248",args[1])};endcopyArgsToSnaks(args,snaks);currentEntity=mw.wikibase.getEntity();reference={snaks=snaks};endlocalrendered=renderReferenceImpl(currentEntity,reference);if(notrendered)thenreturn'';endlocalresult;localcode=rendered.codeorrendered.text;-- Про выбор алгоритма хеширования см. [[Модуль:Hash]]. Знак подчёркивания в начале позволяет-- исключить ошибку, когда имя сноски — чисто числовое значение, каковыми иногда бывают хеши.result=frame:extensionTag('ref',rendered.text,{name='_'..mw.hash.hashValue('fnv164',code)})..'[[Category:Википедия:Статьи с источниками из Викиданных]]';returnresult;endfunctionrenderReferenceImpl(currentEntity,reference,refAnchor,refAnchorYear)if(notreference.snaks)thenreturnnil;end-- контекст, содержит также кеш элементовlocalcontext={cache={},}-- данные в простом формате, согласованном с модулями формирования библиографического описанияlocaldata={};-- забрать данные из referencepopulateDataFromClaims(context,nil,reference.snaks,data)-- update ref name with ref-specific propertiesif(data.code)thenif(data.part)thendata.code=data.code..'-'..getSingle(data.part)endif(data.pages)thendata.code=data.code..'-'..getSingle(data.pages)endif(data.volume)thendata.code=data.code..'-'..getSingle(data.volume)endif(data.issue)thendata.code=data.code..'-'..getSingle(data.issue)endif(data.url)thendata.code=data.code..'-'..getSingle(data.url)endendexpandSpecials(context,currentEntity,reference,data);localsourceEntity=nil;if(data.sourceId)thensourceEntity=getEntity(context,data.sourceId);if(sourceEntity)thenpopulateSourceDataImpl(context,sourceEntity,data);endendif(data.publication)thenexpandPublication(context,sourceEntity,data);endexpandBookSeries(context,data);if(next(data)==nil)thenreturnnil;endlocalrendered;if(p.short)thenrendered=renderShortReference(data);if(mw.ustring.len(rendered.text)==0)thenreturnnil;endelserendered=renderSource(context,data);if(mw.ustring.len(rendered.text)==0)thenreturnnil;endif(refAnchor)thenlocalanchorValue='CITEREF'..refAnchor..(coalesce(refAnchorYear,data.year)or'');rendered.text='<span class="citation" id="'..mw.uri.anchorEncode(anchorValue)..'">'..rendered.text..'</span>';endendreturnrendered;endreturnp;