Модуль:Wikidata — Версийн башхалла

[теллина верси][теллина верси]
Чулацам дӀабаьккхина Чулацам тӀетоьхна
Юхадаьккхина декъашхочун Дагиров Умар (дийц.) нисдар 1699513
Нисдарах лаьцна йаздина дац
МогӀа 19:
["somevalue"] = "''неизвестно''",
["novalue"] = "",
["approximatecirca"] = '<span style="border-bottom: 1px dotted; cursor: help;" title="около, приблизительно">прибл. </span>',
["presumably"] = '<span style="border-bottom: 1px dotted; cursor: help;" title="предположительно">предп. </span>',
}
 
-- settings, may differ from project to project
local categoryLinksToEntitiesWithMissingLabel = '[[Категори:Википеди:Викихаамаш чохь элементаш тӀе нохчийн куьг доцу хьажоргаш йолу яззамаш]]';
local categoryLinksToEntitiesWithMissingLocalLanguageLabel = '[[Категори:Википеди:Викихаамаш чохь элементаш тӀе нохчийн куьг доцу хьажоргаш йолу яззамаш]]';
local categoryLocalValuePresent = '[[Категори:Википеди:Викихаамаш чохь маьӀнаш карладаьхна яззамаш]]';
local fileDefaultSize = '267x400px';
local outputReferences = true;
 
МогӀа 40 ⟶ 42 :
 
-- Ссылки на используемые модули, которые потребуются в 99% случаев загрузки страниц (чтобы иметь на виду при переименовании)
local moduleSources = require( 'Module:Sources' )
 
-- Константы
local contentLanguageCode = mw.getContentLanguage():getCode();
 
local p = {}
 
local formatDatavalue, formatEntityId, formatRefs, formatSnak, formatStatement,
formatStatementDefault, formatProperty, getSourcingCircumstances,
getPropertyDatatype, getPropertyParams, loadCacheSafe, throwError, toBoolean;
 
local function copyTo( obj, target )
МогӀа 61 ⟶ 68 :
end
 
local function parseISO8601splitISO8601(str)
if 'table' == type(str) then
if str.args and str.args[1] then
МогӀа 87 ⟶ 94 :
return tonumber(sign .. oh), tonumber(sign .. om);
end )(str)
return tonumber(os.time({year=Y, month=M, day=D, hour=(h+oh), min=(m+om), sec=s})) * 1000;
end
 
local function parseTimeBoundaries( time, precision )
local s = splitISO8601( time );
if (not s) then return nil; end
 
if ( precision >= 0 and precision <= 8 ) then
local powers = { 1000000000 , 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10 }
local power = powers[ precision + 1 ];
local left = s.year - ( s.year % power );
return { tonumber(os.time( {year=left, month=1, day=1, hour=0, min=0, sec=0} )) * 1000,
tonumber(os.time( {year=left + power - 1, month=12, day=31, hour=29, min=59, sec=58} )) * 1000 + 1999 };
end
 
if ( precision == 9 ) then
return { tonumber(os.time( {year=s.year, month=1, day=1, hour=0, min=0, sec=0} )) * 1000,
tonumber(os.time( {year=s.year, month=12, day=31, hour=23, min=59, sec=58} )) * 1000 + 1999 };
end
 
if ( precision == 10 ) then
local lastDays = {31, 28.25, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local lastDay = lastDays[s.month];
return { tonumber(os.time( {year=s.year, month=s.month, day=1, hour=0, min=0, sec=0} )) * 1000,
tonumber(os.time( {year=s.year, month=s.month, day=lastDay, hour=23, min=59, sec=58} )) * 1000 + 1999 };
end
 
if ( precision == 11 ) then
return { tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=0, min=0, sec=0} )) * 1000,
tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=23, min=59, sec=58} )) * 1000 + 1999 };
end
 
if ( precision == 12 ) then
return { tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=s.hour, min=0, sec=0} )) * 1000,
tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=s.hour, min=59, sec=58} )) * 1000 + 19991999 };
end
 
if ( precision == 13 ) then
return { tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=s.hour, min=s.min, sec=0} )) * 1000,
tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=s.hour, min=s.min, sec=58} )) * 1000 + 1999 };
end
 
if ( precision == 14 ) then
local t = tonumber(os.time( {year=s.year, month=s.month, day=s.day, hour=s.hour, min=s.min, sec=0} ) );
return { t * 1000, t * 1000 + 999 };
end
 
error('Unsupported precision: ' .. precision );
end
 
МогӀа 97 ⟶ 151 :
]]
local function toBoolean( valueToParse, defaultValue )
if ( valueToParse ~= nil ) then
if valueToParse == false or valueToParse == '' or valueToParse == 'false' or valueToParse == '0' then
return false
end
МогӀа 218 ⟶ 272 :
return '' --TODO error?
end
 
-- проброс всех параметров из шаблона {wikidata}
local p_frame = g_frame:getParent();
if p_frame and p_frame:getTitle() == mw.site.namespaces[10].name .. ':Wikidata' then
copyTo( p_frame.args, options );
end
 
-- improve options
МогӀа 233 ⟶ 293 :
 
-- create context
local context = {
entity = options.entity,
formatSnak = formatSnak,
formatPropertyDefault = formatPropertyDefault,
formatStatementDefault = formatStatementDefault }
context.formatProperty = function( options )
local func = getUserFunction( options, 'property', context.formatPropertyDefault );
МогӀа 244 ⟶ 308 :
context.parseTimeFromSnak = function( snak )
if ( snak and snak.datavalue and snak.datavalue.value and snak.datavalue.value.time ) then
localreturn timeISO6801tonumber(os.time( =splitISO8601( tostring( snak.datavalue.value.time ) ) ) ) * 1000;
end
return parseISO8601( timeISO6801 );
return nil;
end
context.parseTimeBoundariesFromSnak = function( snak )
if ( snak and snak.datavalue and snak.datavalue.value and snak.datavalue.value.time and snak.datavalue.value.precision ) then
return parseTimeBoundaries( snak.datavalue.value.time, snak.datavalue.value.precision );
end
return nil;
МогӀа 280 ⟶ 349 :
 
-- создание текстовой строки со списком оформленых заявлений из таблицы
returnlocal out = mw.text.listToText( formattedClaims, options.separator, options.conjunction )
if out ~= '' then
if options.before then
out = options.before .. out
end
if options.after then
out = out .. options.after
end
end
 
return out
end
 
МогӀа 314 ⟶ 393 :
and qualifier.datavalue.value["entity-type"] == 'item' ) then
local circumstance = 'Q' .. qualifier.datavalue.value["numeric-id"];
if ( 'Q18086598Q5727902' == circumstance ) then
circumstances.approximatecirca = true;
end
if ( 'Q18122778' == circumstance ) then
МогӀа 340 ⟶ 419 :
 
local circumstances = context.getSourcingCircumstances( statement );
 
if statement.qualifiers then
options.qualifiers = statement.qualifiers;
end
 
if ( options.references ) then
МогӀа 369 ⟶ 452 :
 
if snak.snaktype == 'somevalue' then
if ( options['somevalue'] and options['somevalue'] ~= '' ) then
return before .. options['somevalue'] .. after;
end
return before .. options.i18n['somevalue'] .. after;
elseif snak.snaktype == 'novalue' then
if ( options['novalue'] and options['novalue'] ~= '' ) then
return before .. options['novalue'] .. after;
end
return before .. options.i18n['novalue'] .. after;
elseif snak.snaktype == 'value' then
МогӀа 376 ⟶ 465 :
before = before .. options.i18n.presumably;
end
if ( circumstances.approximatecirca ) then
before = before .. options.i18n.approximatecirca;
end
 
return before .. formatDatavalue( context, options, snak.datavalue, snak.datatype ) .. after;
else
throwError( 'unknown-snak-type' );
МогӀа 398 ⟶ 487 :
elseif options['subvalue'] == 'longitude' then -- долготы
return value['longitude']
elseif options['nocoord'] and options['nocoord'] ~= '' then
-- если передан параметр nocoord, то не выводить координаты
-- обычно это делается при использовании нескольких карточек на странице
return ''
else
-- в противном случае формируются параметры для вызова шаблона {{coord}}
МогӀа 403 ⟶ 496 :
-- любое изменние его парамеров должно быть согласовано с кодом тут
local eps = 0.0000001 -- < 1/360000
local globe = options.globe or '' -- TODO
local lat = {}
lat['abs'] = math.abs(value['latitude'])
МогӀа 409 ⟶ 502 :
lat['d'] = math.floor(lat['abs'] + eps)
lat['m'] = math.floor((lat['abs'] - lat['d']) * 60 + eps)
lat['s'] = math.max(0, ((lat['abs'] - lat['d']) * 60 - lat['m']) * 60 + eps)
local lon = {}
lon['abs'] = math.abs(value['longitude'])
МогӀа 415 ⟶ 508 :
lon['d'] = math.floor(lon['abs'] + eps)
lon['m'] = math.floor((lon['abs'] - lon['d']) * 60 + eps)
lon['s'] = math.max(0, ((lon['abs'] - lon['d']) * 60 - lon['m']) * 60 + eps)
-- TODO: round seconds with precision
local coord = '{{coord'
if (value['precision'] == nil) or (value['precision'] < 1/60) then -- по умолчанию с точностью до секунды
МогӀа 428 ⟶ 522 :
end
coord = coord .. '|globe:' .. globe
if options['displaytype'] and options['type'] ~= '' then
coord = coord .. '|type=' .. options.type
end
if options['display'] and options['display'] ~= '' then
coord = coord .. '|display=' .. options.display
else
МогӀа 439 ⟶ 536 :
end
 
--[[
local function getDefaultValueFunction( datavalue )
Функция для оформления объектов-значений с файлами с Викисклада
 
Принимает: объект-значение и таблицу параметров,
Возвращает: строку оформленного текста
]]
function formatCommonsMedia( value, options )
local image = '[[File:' .. value
if options['border'] and options['border'] ~= '' then
image = image .. '|border'
end
 
local size = options['size']
if size and size ~= '' then
if not string.match( size, 'px$' )
and not string.match( size, 'пкс$' ) -- TODO: использовать перевод для языка вики
then
size = size .. 'px'
end
else
size = fileDefaultSize;
end
image = image .. '|' .. size
 
if options['alt'] and options['alt'] ~= '' then
image = image .. '|' .. options['alt']
end
image = image .. ']]'
if options['description'] and options['description'] ~= '' then
image = image .. '<br>' .. options['description']
end
return image
end
 
--[[
Функция для оформления внешних идентификаторов
 
Принимает: объект-значение и таблицу параметров,
Возвращает: строку оформленного текста
]]
local function formatExternalId( value, options )
local formatter = options.formatter
if not formatter or formatter == '' then
local entity = mw.wikibase.getEntity( options.property:upper() )
if entity then
local statements = entity:getBestStatements( 'P1630' )
for _, statement in pairs( statements ) do
if statement.mainsnak.snaktype == 'value' then
formatter = statement.mainsnak.datavalue.value
break
end
end
end
end
 
if formatter and formatter ~= '' then
local link = mw.ustring.gsub( formatter, '$1', value )
 
local title = options.title
if not title or title == '' then
title = value
end
 
return '[' .. link .. ' ' .. title .. ']'
end
 
return value
end
 
--[[
Функция для оформления числовых значений
 
Принимает: объект-значение и таблицу параметров,
Возвращает: строку оформленного текста
]]
local function formatQuantity( value, options )
-- диапазон значений
local amount = string.gsub( value['amount'], '^%+', '' );
local lang = mw.language.getContentLanguage();
local langCode = lang:getCode();
local function formatNum( number )
-- округление до 13 знаков после запятой, на 14-м возникает ошибка в точности
local mult = 10^13
number = math.floor( number * mult + 0.5 ) / mult
 
return lang:formatNum( number )
end
local out = formatNum( tonumber( amount ) );
if value.upperBound then
local diff = tonumber( value.upperBound ) - tonumber( amount )
if diff > 0 then -- временная провека, пока у большинства значений не будет убрано ±0
out = out .. '±' .. formatNum( diff )
end
end
 
if value.unit and string.match( value.unit, 'http://www.wikidata.org/entity/' ) then
local unitEntityId = string.gsub( value.unit, 'http://www.wikidata.org/entity/', '' );
local unitEntity = mw.wikibase.getEntity( unitEntityId );
if unitEntity then
-- name from label
-- TODO: lang:getFallbackLanguages()
local label = nil;
if unitEntity.labels then
if unitEntity.labels[langCode] and unitEntity.labels[langCode].value then
label = unitEntity.labels[langCode].value;
elseif unitEntity.labels.en and unitEntity.labels.en.value then
label = unitEntity.labels.en.value;
end
end
-- name from properties
if unitEntity.claims and unitEntity.claims.P558 then
local writingSystemElementId = 'Q8209';
local langElementId = 'Q7737';
local labelFilter = 'P558[P282:' .. writingSystemElementId .. ', P407:' .. langElementId .. ']';
local WDS = require( 'Module:WikidataSelectors' );
local labelClaims = WDS.filter( unitEntity.claims, labelFilter );
for r, claim in pairs( labelClaims ) do
if claim.mainsnak
and claim.mainsnak.datavalue
and claim.mainsnak.datavalue.type == 'string'
and claim.mainsnak.datavalue.value ~= '' then
label = claim.mainsnak.datavalue.value;
break;
end
end
end
out = out .. ' ' .. label;
end
end
 
return out;
end
 
--[[
Get property datatype by ID.
@param string Property ID, e.g. 'P123'.
@return string Property datatype, e.g. 'commonsMedia', 'time' or 'url'.
]]
local function getPropertyDatatype( propertyId )
if not propertyId or not string.match( propertyId, '^P%d+$' ) then
return nil;
end
local propertyEntity = mw.wikibase.getEntity( propertyId );
if not propertyEntity then
return nil;
end
 
return propertyEntity.datatype;
end
 
local function getDefaultValueFunction( datavalue, datatype )
-- вызов обработчиков по умолчанию для известных типов значений
if datavalue.type == 'wikibase-entityid' then
-- Entity ID
-- идентификатор сущности
return function( context, options, value ) return formatEntityId( getEntityIdFromValue( value ), options ) end;
elseif datavalue.type == 'string' then
-- строкаString
if datatype and datatype == 'commonsMedia' then
-- Media
return function( context, options, value )
if ( not options.description or options.description == '' )
and options.qualifiers and options.qualifiers.P2096 then
for i, qualifier in pairs( options.qualifiers.P2096 ) do
if ( qualifier
and qualifier.datavalue
and qualifier.datavalue.type == 'monolingualtext'
and qualifier.datavalue.value
and qualifier.datavalue.value.language == contentLanguageCode ) then
options.description = qualifier.datavalue.value.text
break
end
end
end
return formatCommonsMedia( value, options )
end;
elseif datatype and datatype == 'external-id' then
-- External ID
return function( context, options, value )
return formatExternalId( value, options )
end
elseif datatype and datatype == 'url' then
-- URL
return function( context, options, value )
local moduleUrl = require( 'Module:URL' )
if not options.length or options.length == '' then
options.length = 25
end
return moduleUrl.formatUrlSingle( context, options, value );
end
end
return function( context, options, value ) return value end;
elseif datavalue.type == 'monolingualtext' then
МогӀа 462 ⟶ 751 :
return function( context, options, value ) return formatGlobeCoordinate( value, options ) end;
elseif datavalue.type == 'quantity' then
return function( context, options, value ) return formatQuantity( value, options ) end;
-- диапазон значений
local amount = string.gsub(value['amount'], '^%+', '')
local lang = mw.language.new( 'ru' )
return lang:formatNum( tonumber( amount ) )
end;
elseif datavalue.type == 'time' then
return function( context, options, value )
local moduleDate = require( 'Module:Wikidata/date' )
return moduleDate.formatDate( context, options, value );
end;
МогӀа 486 ⟶ 770 :
Возвращает: строку оформленного текста
]]
function formatDatavalue( context, options, datavalue, datatype )
if ( not context ) then error( 'context not specified' ); end;
if ( not options ) then error( 'options not specified' ); end;
МогӀа 494 ⟶ 778 :
-- проверка на указание специализированных обработчиков в параметрах,
-- переданных при вызове
context.formatValueDefault = getDefaultValueFunction( datavalue, datatype );
local functionToCall = getUserFunction( options, 'value', context.formatValueDefault );
return functionToCall( context, options, datavalue.value );
МогӀа 500 ⟶ 784 :
 
-- Небольшой словарь упрощенного отображения (TODO: надо сделать расширенный с учётом даты)
local simpleReplaces = {}
Q30 = '[[Соединённые Штаты Америки|США]]',
Q148 = '[[Китайская Народная Республика|КНР]]',
Q183 = '[[Германия]]',
Q258 = '[[Южно-Африканская Республика|ЮАР]]',
Q423 = '[[Корейская Народно-Демократическая Республика|КНДР]]',
Q2184 = '[[Российская Советская Федеративная Социалистическая Республика|РСФСР]]',
Q2895 = '[[Белорусская Советская Социалистическая Республика|Белорусская ССР]]',
Q15180 = '[[Союз Советских Социалистических Республик|СССР]]',
Q16957 = '[[Германская Демократическая Республика|ГДР]]',
Q130229 = '[[Грузинская Советская Социалистическая Республика|Грузинская ССР]]',
Q130280 = '[[Эстонская Советская Социалистическая Республика|Эстонская ССР]]',
Q131337 = '[[Азербайджанская Советская Социалистическая Республика|Азербайджанская ССР]]',
Q132856 = '[[Армянская Советская Социалистическая Республика|Армянская ССР]]',
Q133356 = '[[Украинская Советская Социалистическая Республика|Украинская ССР]]',
Q168811 = '[[Казахская Советская Социалистическая Республика|Казахская ССР]]',
Q170895 = '[[Молдавская Советская Социалистическая Республика|Молдавская ССР]]',
Q173761 = '[[Литовская Советская Социалистическая Республика|Литовская ССР]]',
Q192180 = '[[Латвийская Советская Социалистическая Республика|Латвийская ССР]]',
Q199707 = '[[Туркменская Советская Социалистическая Республика|Туркменская ССР]]',
Q199711 = '[[Таджикская Советская Социалистическая Республика|Таджикская ССР]]',
Q484578 = '[[Узбекская Советская Социалистическая Республика|Узбекская ССР]]',
Q809806 = '[[Башкирская Автономная Советская Социалистическая Республика|Башкирская АССР]]',
Q1157215 = '[[Дагестанская Автономная Советская Социалистическая Республика|Дагестанская АССР]]',
}
 
--[[
МогӀа 535 ⟶ 795 :
-- получение локализованного названия
local label = nil;
local labelLanguageCode = contentLanguageCode;
if ( options.text and options.text ~= '' ) then
label = options.text
МогӀа 541 ⟶ 802 :
return simpleReplaces[entityId];
end
label, lang = mw.wikibase.labelgetLabelWithLang( entityId );
end
 
-- получение ссылки по идентификатору
МогӀа 548 ⟶ 809 :
if link then
if label then
if ( contentLanguageCode ~= labelLanguageCode ) then
return '[[' .. link .. '|' .. label .. ']]'
return '[[' .. link .. '|' .. label .. ']]' .. categoryLinksToEntitiesWithMissingLocalLanguageLabel;
else
return '[[' .. link .. '|' .. label .. ']]';
end
else
return '[[' .. link .. ']]';
end
end
 
if label then
return-- labelкрасная ссылка
-- TODO: разобраться, почему не всегда есть options.frame
if not mw.title.new( label ).exists and options.frame then
return '[[' .. label .. ']]<sup>[[:d:' .. entityId .. '|[d]]]</sup>';
end
 
-- TODO: перенести до проверки на существование статьи
local sup = '';
if ( not options.format or options.format ~= 'text' )
and entityId ~= 'Q6581072' and entityId ~= 'Q6581097' -- TODO: переписать на format=text
then
sup = '<sup class="plainlinks noprint">[//www.wikidata.org/wiki/' .. entityId .. '?uselang=' .. contentLanguageCode .. ' [d&#x5d;]</sup>'
end
 
-- одноимённая статья уже существует - выводится текст и ссылка на ВД
return '<span class="iw" data-title="' .. label .. '">' .. label
.. sup
.. '</span>'
end
-- сообщение об отсутвии локализованного названия
-- not good, but better than nothing
return '[[:d:' .. entityId .. '|' .. entityId .. ']]<span style="border-bottom: 1px dotted; cursor: help; white-space: nowrap" title="В Викиданных нет русской подписи к элементу. Вы можете помочь, указав русский вариант подписи.">?</span>' .. categoryLinksToEntitiesWithMissingLabel;
end
 
МогӀа 572 ⟶ 854 :
function p.formatStatements( frame )
return p.formatProperty( frame );
end
 
--[[
Получение параметров, которые обычно используются для вывода свойства.
]]
function getPropertyParams( propertyId, datatype, params )
local config = require( 'Module:Wikidata/config' );
if not config then
return {};
end
 
-- Различные уровни настройки параметров, по убыванию приоритета
 
-- 1. Параметры, указанные явно при вызове
local propertyParams = params;
if not propertyParams then
propertyParams = {};
end
 
-- 2. Настройки конкретного параметра
if config['properties'] and config['properties'][propertyId] then
local selfParams = mw.clone( config['properties'][propertyId] );
for key, value in pairs( selfParams ) do
if propertyParams[key] == nil then
propertyParams[key] = value;
end
end
end
 
-- 3. Указанный пресет настроек
if propertyParams['preset'] and config['presets']
and config['presets'][propertyParams['preset']] then
local presetParams = mw.clone( config['presets'][propertyParams['preset']] );
for key, value in pairs( presetParams ) do
if propertyParams[key] == nil then
propertyParams[key] = value;
end
end
end
 
-- 4. Настройки для типа данных
if datatype and config['datatypes'] and config['datatypes'][datatype] then
local datatypeParams = mw.clone( config['datatypes'][datatype] );
for key, value in pairs( datatypeParams ) do
if propertyParams[key] == nil then
propertyParams[key] = value;
end
end
end
 
-- 5. Общие настройки для всех свойств
if config['global'] then
local globalParams = mw.clone( config['global'] );
for key, value in pairs( globalParams ) do
if propertyParams[key] == nil then
propertyParams[key] = value;
end
end
end
 
return propertyParams;
end
 
function p.formatProperty( frame )
local args = frame.args
local plain = toBoolean( frame.args.plain, false );
frame.local args.nocat = toBoolean( frame.args.nocat, false );
frame.args.references = toBoolean( frame.args.references, true );
 
-- проверка на отсутствие обязательного параметра property
if not frame.args.property then
throwError( 'property-param-not-provided' )
end
local propertyId = mw.language.getContentLanguage():ucfirst( string.gsub( args.property, '%[.*$', '' ) )
local datatype = getPropertyDatatype( propertyId );
args = getPropertyParams( propertyId, datatype, args );
 
args.nocat = toBoolean( args.nocat, false );
-- если значение передано в параметрах вызова то выводим только его
if frame.args.valuereferences and= toBoolean( frame.args.value ~=references, ''true then);
 
if plain or frame.args.nocat or frame:callParserFunction( '#property', frame.args.property )=='' then
-- если значение передано в параметрах вызова то выводим только его
-- опция, запрещающая оформление значения, поэтому никак не трогаем
if args.value and args.value ~= '' then
return frame.args.value
-- специальное значение для скрытия Викиданных
else
if args.value == '-' then
-- если трогать всё-таки можно, добавляем категорию-маркер
return args.value .. categoryLocalValuePresent;''
end
local value = args.value
 
-- опция, запрещающая оформление значения, поэтому никак не трогаем
if plain then
return value
end
 
-- обработчики по типу значения
if args['value-module'] and args['value-function'] and not string.find( value, '[%[%]%{%}]' ) then
local func = getUserFunction( args, 'value' );
value = func( {}, args, value );
elseif datatype == 'commonsMedia' and not string.find( value, '[%[%]%{%}]' ) then
value = formatCommonsMedia( value, args );
elseif datatype == 'external-id' and not string.find( value, '[%[%]%{%}]' ) then
value = formatExternalId( value, args );
elseif datatype == 'url' then
local moduleUrl = require( 'Module:URL' );
value = moduleUrl.formatUrlSingle( nil, args, value );
end
 
-- оборачиваем в тег для JS-функций
if string.match( propertyId, '^P%d+$' ) then
value = mw.text.trim( value )
 
-- временная штрафная категория для исправления табличных вставок
if ( propertyId ~= 'P166'
and string.match( value, '<t[dr][ >]' )
and not string.match( value, '<table >]' )
and not string.match( value, '^%{%|' ) ) then
value = value .. '[[Категори:Википеди:Статьи с табличной вставкой в карточке]]'
else
-- значений с блочными тегами остаются блоком, текст встраиваем в строку
if ( string.match( value, '\n' )
or string.match( value, '<t[dhr][ >]' )
or string.match( value, '<div[ >]' ) ) then
value = '<div class="no-wikidata" '
.. 'data-wikidata-property-id="' .. propertyId .. '">\n'
.. value .. '</div>'
else
value = '<span class="no-wikidata" '
.. 'data-wikidata-property-id="' .. propertyId .. '">'
.. value .. '</span>'
end
end
end
 
-- добавляем категорию-маркер
if not args.nocat then
value = value .. categoryLocalValuePresent;
end
 
return value
end
 
if ( plain ) then -- вызова стандартного обработчика без оформления, если передана опция plain
return frame:callParserFunction( '#property', frame.args.propertypropertyId );
end
 
g_frame = frame
-- после проверки всех аргументов -- вызов функции оформления для свойства (набора утверждений)
return formatProperty( frame.args )
end