Module:Format TemplateData and Module:Format TemplateData/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
m Fixed error |
Synced; some simplifications |
||
Line 82: | Line 82: | ||
newlines = "*", |
newlines = "*", |
||
spaced = "inline" }, |
spaced = "inline" }, |
||
colors = { |
colors = { bg = "FFFFFF", |
||
⚫ | |||
⚫ | |||
required = "EAF3FF", |
required = "EAF3FF", |
||
suggested = "FFFFFF", |
suggested = "FFFFFF", |
||
Line 145: | Line 147: | ||
-- ask -- string, with name |
-- ask -- string, with name |
||
-- "/global" |
-- "/global" |
||
⚫ | |||
-- "Multilingual" |
-- "Multilingual" |
||
-- "Text" |
-- "Text" |
||
Line 651: | Line 654: | ||
if n > 0 then |
if n > 0 then |
||
local s |
local s |
||
-- The following could be made more efficient by iterating through Data.heirs *backwards*, |
|||
-- and breaking as soon as a match is found |
|||
for k, v in pairs( Data.heirs ) do |
for k, v in pairs( Data.heirs ) do |
||
if v then |
if v then |
||
if s then |
if s then |
||
s = string.format( "%s |
s = string.format( "%s | %s", s, k ) |
||
else |
else |
||
s = "Circular inherits: " .. k |
s = "Circular inherits: " .. k |
||
Line 681: | Line 686: | ||
Permit.boole = { [false] = { css = boole, |
Permit.boole = { [false] = { css = boole, |
||
lead = true, |
lead = true, |
||
show = " |
show = "☐" }, |
||
[true] = { css = boole, |
[true] = { css = boole, |
||
lead = true, |
lead = true, |
||
show = " |
show = "☑" } } |
||
Permit.css = { } |
Permit.css = { } |
||
for k, v in pairs( Permit.colors ) do |
for k, v in pairs( Permit.colors ) do |
||
Line 1,590: | Line 1,595: | ||
if r:find( "&", 1, true ) then |
if r:find( "&", 1, true ) then |
||
r = mw.text.decode( r ) |
r = mw.text.decode( r ) |
||
if r:find( " |
if r:find( "­", 1, true ) then |
||
r = r:gsub( " |
r = r:gsub( "­", "" ) |
||
end |
end |
||
end |
end |
||
Line 1,699: | Line 1,704: | ||
elseif scope:find( "nowiki", 1, true ) then |
elseif scope:find( "nowiki", 1, true ) then |
||
elem = mw.text.nowiki( v ) |
elem = mw.text.nowiki( v ) |
||
elem = elem:gsub( "\n", "<br>" ) |
elem = elem:gsub( " \n", "<br>" ) |
||
v = v:gsub( string.char( 13 ), "" ) |
v = v:gsub( string.char( 13 ), "" ) |
||
else |
else |
||
Line 1,713: | Line 1,718: | ||
end |
end |
||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
else |
else |
||
elem = v |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
if type( elem ) ~= "nil" then |
if type( elem ) ~= "nil" then |
||
Line 1,753: | Line 1,756: | ||
elem = false |
elem = false |
||
end |
end |
||
if |
if v ~= nil then |
||
if not tag then |
if not tag then |
||
if access then |
if access then |
||
Line 1,771: | Line 1,774: | ||
end |
end |
||
end |
end |
||
if |
if v ~= nil and |
||
k ~= "suggestedvalues" then |
k ~= "suggestedvalues" then |
||
tag[ k ] = v |
tag[ k ] = v |
||
Line 1,810: | Line 1,813: | ||
code = source:gsub( "\n", "N" ) |
code = source:gsub( "\n", "N" ) |
||
else |
else |
||
s = mw.text.nowiki( source ):gsub( "\n", " |
s = mw.text.nowiki( source ):gsub( "\n", "\n" ) |
||
s = tostring( mw.html.create( "code" ) |
s = tostring( mw.html.create( "code" ) |
||
:wikitext( s ) ) |
:wikitext( s ) ) |
||
Line 1,831: | Line 1,834: | ||
Permit.builder.align then |
Permit.builder.align then |
||
Permit.builder.align = tonumber( s ) |
Permit.builder.align = tonumber( s ) |
||
⚫ | |||
⚫ | |||
else |
else |
||
unknown = s |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
end -- i = 1, #words |
end -- i = 1, #words |
||
Line 1,950: | Line 1,951: | ||
if code then |
if code then |
||
source = code:gsub( "N", "\n" ) |
source = code:gsub( "N", "\n" ) |
||
code = mw.text.nowiki( code ):gsub( "N", " |
code = mw.text.nowiki( code ):gsub( "N", "\n" ) |
||
code = mw.html.create( "code" ) |
code = mw.html.create( "code" ) |
||
:css( "margin-left", "1em" ) |
:css( "margin-left", "1em" ) |
||
Line 2,084: | Line 2,085: | ||
end |
end |
||
focus() |
focus() |
||
if Data.tag then |
if Data.tag and type( Data.got.params ) == "table" then |
||
for k, v in pairs( Data.got.params ) do |
|||
focus( k ) |
|||
end -- for k, v |
|||
if Data.heirs then |
|||
fathers() |
|||
⚫ | |||
⚫ | |||
end |
end |
||
end |
end |
||
Line 2,291: | Line 2,290: | ||
-- Returns string, or not |
-- Returns string, or not |
||
if type( adapt ) == "string" then |
if type( adapt ) == "string" then |
||
local JSONutil = Fetch( "JSONutil", true ) |
|||
Data.source = adapt |
Data.source = adapt |
||
free() |
free() |
||
if JSONutil then |
|||
local Multilingual = Fetch( "Multilingual", true ) |
|||
⚫ | |||
if Multilingual then |
|||
f = Multilingual.i18n |
|||
⚫ | |||
Data.got = JSONutil.fetch( Data.source, true, f ) |
|||
else |
|||
local lucky |
|||
lucky, Data.got = pcall( mw.text.jsonDecode, Data.source ) |
|||
⚫ | |||
if type( Data.got ) == "table" then |
if type( Data.got ) == "table" then |
||
full() |
full() |