Modul:TemplateData: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2017-03-29
wp>PerfektesChaos (2017-03-28) |
wp>PerfektesChaos (2017-03-29) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { serial = "2017-03- | local TemplateData = { serial = "2017-03-29", | ||
suite = "TemplateData" } | suite = "TemplateData" } | ||
--[=[ | --[=[ | ||
Zeile 45: | Zeile 45: | ||
params = { aliases = "table", | params = { aliases = "table", | ||
autovalue = "string", | autovalue = "string", | ||
default = "string table I18N", | default = "string table I18N nowiki", | ||
deprecated = "boolean string", | deprecated = "boolean string", | ||
description = "string table I18N", | description = "string table I18N", | ||
example = "string table I18N", | example = "string table I18N nowiki", | ||
label = "string table I18N", | label = "string table I18N", | ||
inherits = "string", | inherits = "string", | ||
Zeile 144: | Zeile 144: | ||
:wikitext( k ) ) | :wikitext( k ) ) | ||
:tag( "br" ) | :tag( "br" ) | ||
:wikitext( v | :wikitext( fair( v ) ) ) | ||
end -- for k, v | end -- for k, v | ||
end | end | ||
Zeile 217: | Zeile 216: | ||
return r | return r | ||
end -- failures() | end -- failures() | ||
local function fair( adjust ) | |||
-- Reduce text to one line of plain text, or noexport wikitext blocks | |||
-- adjust -- string | |||
-- Returns string, with adjusted text | |||
local f = function ( a ) | |||
return a:gsub( "%s*\n%s*", " " ) | |||
:gsub( "%s%s+", " " ) | |||
end | |||
local r | |||
if adjust:find( "<noexport>", 1, true ) then | |||
local i = 1 | |||
local j, k = adjust:find( "<noexport>", i, true ) | |||
r = "" | |||
while j do | |||
if j > 1 then | |||
r = r .. f( adjust:sub( i, j - 1 ) ) | |||
end | |||
i = j + 10 | |||
j, k = adjust:find( "</noexport>", i, true ) | |||
if j then | |||
r = r .. adjust:sub( i, j - 1 ) | |||
i = j + 11 | |||
end | |||
end -- while j | |||
else | |||
r = f( adjust ) | |||
end | |||
return r | |||
end -- fair() | |||
Zeile 501: | Zeile 532: | ||
:wikitext( section ) ) | :wikitext( section ) ) | ||
:node( mw.html.create( "dd" ) | :node( mw.html.create( "dd" ) | ||
:wikitext | :wikitext( show ) ) | ||
end | end | ||
end -- i = 1, #details | end -- i = 1, #details | ||
Zeile 693: | Zeile 724: | ||
r = r:gsub( "<noexport>(.*)</noexport>", "" ) | r = r:gsub( "<noexport>(.*)</noexport>", "" ) | ||
end | end | ||
if r:find( "''", 1, true ) | if r:find( "''", 1, true ) then | ||
r = r:gsub( "'''", "" ):gsub( "''", "" ) | |||
end | |||
if r:find( "<", 1, true ) then | |||
local Text = fetch( "Text" ) | local Text = fetch( "Text" ) | ||
r = Text.getPlain( r ) | r = Text.getPlain( r ) | ||
Zeile 786: | Zeile 820: | ||
if scope:find( "I18N", 1, true ) then | if scope:find( "I18N", 1, true ) then | ||
if s == "string" then | if s == "string" then | ||
elem = | elem = fair( v ) | ||
else | else | ||
local translated | local translated | ||
v, translated = faraway( v ) | v, translated = faraway( v ) | ||
if translated and k == "description" then | if translated and k == "description" then | ||
elem = { [ 1 ] = v | elem = { [ 1 ] = fair( v ), | ||
[ 2 ] = translated } | [ 2 ] = translated } | ||
else | else | ||
elem = v | elem = fair( v ) | ||
end | end | ||
end | |||
if scope:find( "nowiki", 1, true ) then | |||
elem = mw.text.nowiki( v ) | |||
else | |||
v = flat( v ) | v = flat( v ) | ||
end | end | ||
else | else | ||
if k == "params" and not access then | if k == "params" and not access then | ||
v = nil | v = nil | ||
elem = nil | elem = nil | ||
elseif s == "string" then | |||
v = mw.text.nowiki( v ) | |||
elem = v | |||
elseif k == "inherits" then | elseif k == "inherits" then | ||
elem = v | |||
if not Data.heirs then | if not Data.heirs then | ||
Data.heirs = { } | Data.heirs = { } | ||
end | end | ||
Data.heirs[ slot ] = v | Data.heirs[ slot ] = v | ||
v = nil | v = nil | ||
else | |||
elem = v | |||
end | end | ||
end | end | ||
Zeile 922: | Zeile 963: | ||
tdata ) | tdata ) | ||
div:wikitext( Data.strip ) | div:wikitext( Data.strip ) | ||
if | if Config.loudly then | ||
Data.div:node( mw.html.create( "hr" ) ) | |||
else | |||
div:css( "display", "none" ) | div:css( "display", "none" ) | ||
end | end |