Modul:TemplateData: Unterschied zwischen den Versionen

K
73 Versionen von wikivoyage:Modul:TemplateData importiert
w>PerfektesChaos
(2018-04-21)
K (73 Versionen von wikivoyage:Modul:TemplateData importiert)
 
(24 dazwischenliegende Versionen von 5 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local TemplateData = { suite  = "TemplateData",
local TemplateData = { suite  = "TemplateData",
                       serial = "2018-04-21",
                       serial = "2021-07-05",
                       item  = 46997995 }
                       item  = 46997995 }
--[=[
--[==[
improve template:TemplateData
improve template:TemplateData
]=]
]==]
local Failsafe = TemplateData




Zeile 12: Zeile 13:
     basicCnf = { catProblem    = "strange",
     basicCnf = { catProblem    = "strange",
                 classNoNumTOC = "suppressTOCnum",
                 classNoNumTOC = "suppressTOCnum",
                classTable    = "classTable",
                 cssParWrap    = "cssTabWrap",
                 cssParWrap    = "cssTabWrap",
                 cssParams    = "cssTable",
                 cssParams    = "cssTable",
Zeile 28: Zeile 30:
                 helpURL      = "support4url",
                 helpURL      = "support4url",
                 helpUser      = "support4wiki-user-name",
                 helpUser      = "support4wiki-user-name",
                 msgDescMiss  = "solo" },
                 msgDescMiss  = "solo",
--  classParams    = "classTable",
                tStylesTOCnum = "stylesTOCnum" },
--  classTable    = false,    -- class for params table
    classTable    = { "wikitable" },    -- classes for params table
     debugmultilang = "C0C0C0",
     debugmultilang = "C0C0C0",
     loudly        = false,    -- show exported element, etc.
     loudly        = false,    -- show exported element, etc.
Zeile 47: Zeile 49:
     got    = false,    -- table, initial templatedata object
     got    = false,    -- table, initial templatedata object
     heirs  = false,    -- table, params that are inherited
     heirs  = false,    -- table, params that are inherited
    jump    = false,    -- source position at end of "params"
     less    = false,    -- main description missing
     less    = false,    -- main description missing
     lasting = false,    -- old syntax encountered
     lasting = false,    -- old syntax encountered
Zeile 56: Zeile 59:
     scream  = false,    -- error messages
     scream  = false,    -- error messages
     sibling = false,    -- TOC juxtaposed
     sibling = false,    -- TOC juxtaposed
     slang  = false,   -- project language code
     slang  = nil,     -- project/user language code
     slim    = false,    -- JSON reduced to plain
     slim    = false,    -- JSON reduced to plain
     source  = false,    -- JSON input
     source  = false,    -- JSON input
Zeile 65: Zeile 68:
}
}
local Permit = {
local Permit = {
     builder = { after     = "block",
     builder = { after           = "block",
                 align     = "block",
                 align           = "block",
                 block     = "block",
                 block           = "block",
                 compressed = "block",
                 compressed     = "block",
                 dense     = "block",
                 dense           = "block",
                 grouped   = "inline",
                 grouped         = "inline",
                 half       = "inline",
                 half           = "inline",
                 indent     = "block",
                 indent         = "block",
                 inline     = "inline",
                 inline         = "inline",
                 last       = "block",
                 last           = "block",
                 lead       = "block",
                 lead           = "block",
                 newlines   = "*",
                 newlines       = "*",
                 spaced     = "inline" },
                 spaced         = "inline" },
     colors  = { tableheadbg = "B3B7FF",
     colors  = { tableheadbg = "B3B7FF",
                 required    = "EAF3FF",
                 required    = "EAF3FF",
Zeile 83: Zeile 86:
                 optional    = "EAECF0",
                 optional    = "EAECF0",
                 deprecated  = "FFCBCB" },
                 deprecated  = "FFCBCB" },
     params  = { aliases     = "table",
     params  = { aliases         = "table",
                 autovalue   = "string",
                 autovalue       = "string",
                 default     = "string table I18N nowiki",
                 default         = "string table I18N nowiki",
                 deprecated = "boolean string I18N",
                 deprecated     = "boolean string I18N",
                 description = "string table I18N",
                 description     = "string table I18N",
                 example     = "string table I18N nowiki",
                 example         = "string table I18N nowiki",
                 label       = "string table I18N",
                 label           = "string table I18N",
                 inherits   = "string",
                 inherits       = "string",
                 required   = "boolean",
                 required       = "boolean",
                 style       = "string table",
                 style           = "string table",
                 suggested   = "boolean",
                 suggested       = "boolean",
                 type       = "string" },
                suggestedvalues = "string table number",
                 type           = "string" },
     root    = { description = "string table I18N",
     root    = { description = "string table I18N",
                 format      = "string",
                 format      = "string",
Zeile 135: Zeile 139:




local function Fetch( ask )
local function Fetch( ask, allow )
     -- Fetch module
     -- Fetch module
     -- Parameter:
     -- Parameter:
     --    ask -- string, with name
     --    ask   -- string, with name
     --                     "/global"
     --                       "/global"
     --                     "Multilingual"
     --                       "JSONutil"
     --                     "Text"
    --                      "Multilingual"
     --                     "WLink"
     --                       "Text"
     --                       "WLink"
    --    allow  -- true: no error if unavailable
     -- Returns table of module
     -- Returns table of module
     -- error: Module not available
     -- error: Module not available
Zeile 167: Zeile 173:
             end
             end
             TemplateData.extern[ sign ] = r
             TemplateData.extern[ sign ] = r
         else
         elseif not allow then
             error( string.format( "Fetch(%s) %s", sign, g ) )
             error( string.format( "Fetch(%s) %s", sign, g ), 0 )
         end
         end
     end
     end
     return r
     return r
end -- Fetch()
end -- Fetch()
local function Foreign()
    -- Guess human language
    -- Returns slang, or not
    if type( Data.slang ) == "nil" then
        local Multilingual = Fetch( "Multilingual", true )
        if Multilingual  and
          type( Multilingual.userLangCode ) == "function" then
            Data.slang = Multilingual.userLangCode()
        else
            Data.slang = mw.language.getContentLanguage():getCode()
                                                        :lower()
        end
    end
    if Data.slang  and
      mw.ustring.codepoint( Data.slang, 1, 1 ) > 122 then
        Data.slang = false
    end
    return Data.slang
end -- Foreign()




Zeile 186: Zeile 214:
                                   :gsub( "([%-.()+*?^$%[%]])",
                                   :gsub( "([%-.()+*?^$%[%]])",
                                           "%%%1" ) )
                                           "%%%1" ) )
     local i, k = Data.source:find( seek, at )
     local i, k, r, slice, source
     local r, slice, source
    if not Data.jump then
        Data.jump = Data.source:find( "params", 2 )
        if Data.jump then
            Data.jump = Data.jump + 7
        else
            Data.jump = 1
        end
    end
     i, k = Data.source:find( seek, at + Data.jump )
     while i  and  not r do
     while i  and  not r do
         source = Data.source:sub( k + 1 )
         source = Data.source:sub( k + 1 )
Zeile 198: Zeile 234:
             r = k
             r = k
         else
         else
             i, k = Data.source:find( seek, k )
             i, k = Data.source:find( seek, k )
         end
         end
     end    -- while i
     end    -- while i
Zeile 212: Zeile 248:
     -- Returns string, with localized text
     -- Returns string, with localized text
     local o = mw.message.new( "templatedata-" .. adapt )
     local o = mw.message.new( "templatedata-" .. adapt )
     if not Data.slang then
     if Foreign() then
        local Multilingual = Fetch( "Multilingual" )
        if type( Multilingual.userLangCode ) == "function" then
            Data.slang = Multilingual.userLangCode()
        end
    end
    if Data.slang then
         o:inLanguage( Data.slang )
         o:inLanguage( Data.slang )
     end
     end
Zeile 272: Zeile 302:
     --    adjust  -- string
     --    adjust  -- string
     -- Returns string, with adjusted text
     -- Returns string, with adjusted text
     local f = function ( a )
     local f   = function ( a )
                  return a:gsub( "%s*\n%s*", " " )
                    return a:gsub( "%s*\n%s*", " " )
                          :gsub( "%s%s+", " " )
                            :gsub( "%s%s+", " " )
              end
                end
     local r
     local tags = { { start = "<noexport>",
    if adjust:find( "<noexport>", 1, true ) then
                    stop  = "</noexport>" },
        local i    = 1
                  { start = "<exportonly>",
        local j, k = adjust:find( "<noexport>", i, true )
                    stop  = "</exportonly>",
        r = ""
                    l    = false }
        while j do
                }
            if j > 1 then
    local r = adjust
                r = r .. f( adjust:sub( i, j - 1 ) )
    local i, j, k, s, tag
             end
    for m = 1, 2 do
             i = k + 1
        tag = tags[ m ]
             j, k = adjust:find( "</noexport>", i, true )
        if r:find( tag.start, 1, true ) then
             if j then
            s    = r
                r   = r .. adjust:sub( i,  j - 1 )
             r    = ""
             i     = 1
            tag.l = true
             j, k = s:find( tag.start, i, true )
             while j do
                if j > 1 then
                    r = r .. f( s:sub( i,  j - 1 ) )
                end
                 i    = k + 1
                 i    = k + 1
                 j, k = adjust:find( "<noexport>", i, true )
                 j, k = s:find( tag.stop, i, true )
            else
                if j then
                Fault( "missing </noexport>" )
                    if m == 1 then
            end
                        r = r .. s:sub( i,  j - 1 )
        end    -- while j
                    end
        r = r .. adjust:sub( i )
                    i    = k + 1
     else
                    j, k = s:find( tag.start, i, true )
         r = f( adjust )
                else
                    Fault( "missing " .. tag.stop )
                end
            end    -- while j
            r = r .. s:sub( i )
        elseif m == 1 then
            r = f( r )
        end
    end -- for m
     if tags[ 2 ].l then
         r = r:gsub( "<exportonly>.*</exportonly>", "" )
     end
     end
     return r
     return r
end -- fair()
end -- fair()




Zeile 359: Zeile 405:
     local variants = { }
     local variants = { }
     local r1, r2
     local r1, r2
    if Data.slang  and
      mw.ustring.codepoint( Data.slang, 1, 1 ) > 122 then
        Data.slang = false
    end
     for k, v in pairs( alternatives ) do
     for k, v in pairs( alternatives ) do
         if type( v ) == "string" then
         if type( v ) == "string" then
             v = mw.text.trim( v )
             v = mw.text.trim( v )
             if v ~= "" then
             if v ~= ""  and  type( k ) == "string" then
                 k = k:lower()
                 k = k:lower()
                 variants[ k ] = v
                 variants[ k ] = v
Zeile 374: Zeile 416:
     end -- for k, v
     end -- for k, v
     if n > 0 then
     if n > 0 then
         local choices, Multilingual
         local Multilingual = Fetch( "Multilingual", true )
         if n > 1 then
         if Multilingual  and
             choices = { }
          type( Multilingual.i18n ) == "function" then
        end
             local show, slang = Multilingual.i18n( variants )
        for k, v in pairs( variants ) do
             if show then
             if n == 1 then
                 r1 = show
                 r1 = v
                 variants[ slang ] = nil
            elseif Data.slang == k then
                 variants[ k ] = nil
                r1 = v
                 r2 = variants
                 r2 = variants
            else
                table.insert( choices, k )
             end
             end
         end -- for k, v
         end
         if not r1 then
         if not r1 then
             Multilingual = Fetch( "Multilingual" )
             Foreign()
             if type( Multilingual.userLang ) == "function" then
             for k, v in pairs( variants ) do
                local sel = Multilingual.userLang( choices,
                if n == 1 then
                                                  TemplateData.frame )
                    r1 = v
                r1 = variants[ sel ]
                elseif Data.slang == k then
                variants[ sel ] = nil
                    variants[ k ] = nil
                r2 = variants
                    r1 = v
             end
                    r2 = variants
                end
             end -- for k, v
         end
         end
         if r2 then
         if r2 and Multilingual then
            Multilingual = Multilingual or Fetch( "Multilingual" )
             for k, v in pairs( r2 ) do
             for k, v in pairs( r2 ) do
                 if v  and  not Multilingual.isLang( k, true ) then
                 if v  and  not Multilingual.isLang( k, true ) then
                     Fault( string.format( "Invalid <code>lang=%s</code>",
                     Fault( string.format( "%s <code>lang=%s</code>",
                                          "Invalid",
                                           k ) )
                                           k ) )
                 end
                 end
Zeile 429: Zeile 468:
             para:wikitext( about.description[ 1 ] )
             para:wikitext( about.description[ 1 ] )
             plus = mw.html.create( "ul" )
             plus = mw.html.create( "ul" )
            plus:css( "text-align", "left" )
             for k, v in pairs( about.description[ 2 ] ) do
             for k, v in pairs( about.description[ 2 ] ) do
                 plus:node( mw.html.create( "li" )
                 plus:node( mw.html.create( "li" )
Zeile 636: Zeile 676:




local function feat()
local function feasible( about, at )
     -- Check and store parameter sequence
     -- Deal with suggestedvalues within parameter
     if Data.source then
    -- Parameter:
        local i = 0
    --    about  -- parameter details
        local s
    --              .suggestedvalues  -- table|string|number,
        for k, v in pairs( Data.tree.params ) do
    --                                    value and possibly description
            if i == 0 then
    --                                    .code  -- mandatory
                Data.order = { }
    --                                    .label  -- table|string
                i = 1
    --                                    .icon  -- string
                 s = k
    --                                    .class  -- table|string
            else
    --                                    .css    -- table
                 i = 2
    --                                    .style  -- string
                 break -- for k, v
    --                                    .less  -- true: suppress code
            end
    --              .type
        end -- for k, v
    --    at    -- string, with parameter name
        if i > 1 then
    -- Returns
            local pointers = { }
     --    1: mw.html object
            local points  = { }
    --    2: sequence table with values, or nil
            for k, v in pairs( Data.tree.params ) do
    local p = about.suggestedvalues
                i = facet( k, 1 )
    local s = type( p )
                if i then
    local e, r1, r2, v
                     table.insert( points, i )
    if s == "table" then
                     pointers[ i ] = k
        if #p > 0 then
                     i = facet( k, i )
            for i = 1, #p do
                     if i then
                 e = p[ i ]
                         s = "Parameter '%s' detected twice"
                 s = type( e )
                         Fault( string.format( s, k ) )
                 if s == "table" then
                    if type( e.code ) == "string" then
                        s = mw.text.trim( e.code )
                        if s == "" then
                            e = nil
                        else
                            e.code = s
                        end
                     else
                        e = nil
                        s = string.format( "params.%s.%s[%d] %s",
                                          at,
                                          "suggestedvalues",
                                          i,
                                          "MISSING 'code:'" )
                     end
                elseif s == "string" then
                     s = mw.text.trim( e )
                     if s == "" then
                        e = nil
                         s = string.format( "params.%s.%s[%d] EMPTY",
                                          at, "suggestedvalues", i )
                         Fault( s )
                    else
                        e = { code = s }
                     end
                     end
                elseif s == "number" then
                    e = { code = tostring( e ) }
                 else
                 else
                     s = "Parameter '%s' not detected"
                     s = string.format( "params.%s.%s[%d] INVALID",
                     Fault( string.format( s, k ) )
                                      at, "suggestedvalues", i )
                     Fault( s )
                    e = false
                end
                if e then
                    v = v  or  { }
                    table.insert( v, e )
                 end
                 end
             end -- for k, v
             end -- for i
             table.sort( points )
        else
            for i = 1, #points do
             Fault( string.format( "params.%s.suggestedvalues %s",
                table.insert( Data.order,  pointers[ points[ i ] ] )
                  at, "NOT AN ARRAY" ) )
            end -- i = 1, #points
        end
         elseif s then
    elseif s == "string" then
             table.insert( Data.order, s )
        s = mw.text.trim( p )
         if s ~= "" then
            v = { }
             table.insert( v,
                          { code = s } )
         end
         end
    elseif s == "number" then
        v = { }
        table.insert( v,
                      { code = tostring( p ) } )
     end
     end
end -- feat()
    if v then
 
        local d, less, story, swift, t, u
 
        r1 = mw.html.create( "ul" )
 
        r2 = { }
local function feature( access )
        for i = 1, #v do
    -- Create table row for parameter, check and display violations
            u = mw.html.create( "li" )
    -- Parameter:
            e = v[ i ]
    --    access -- string, with name
            table.insert( r2, e.code )
    -- Returns <tr>
            story = false
    local mode, s, status
            less = ( e.less == true )
    local fine    = function ( a )
            if not less then
                        s = mw.text.trim( a )
                swift = e.code
                         return a == s  and
                if e.support then
                              a ~= "" and
                    local scream, support
                              not a:find( "%|=\n" ) and
                    s = type( e.support )
                              not a:find( "%s%s" )
                    if s == "string" then
                         support = e.support
                    elseif s == "table" then
                        support = faraway( e.support )
                    else
                        scream = "INVALID"
                     end
                     end
    local begin  = mw.html.create( "td" )
                    if support then
    local code    = mw.html.create( "code" )
                        s = mw.text.trim( support )
    local desc    = mw.html.create( "td" )
                        if s == "" then
    local legal  = true
                            scream = "EMPTY"
    local param  = Data.tree.params[ access ]
                        elseif s:find( "[%[%]|%<%>]" ) then
    local ranking = { "required", "suggested", "optional", "deprecated" }
                            scream = "BAD PAGE"
    local r      = mw.html.create( "tr" )
                        else
    local sort, typed
                            support = s
 
                        end
    for k, v in pairs( param ) do
                    end
        if v == "" then
                    if scream then
             param[ k ] = false
                        s = string.format( "params.%s.%s[%d].support %s",
        end
                                          at,
    end -- for k, v
                                          "suggestedvalues",
 
                                          i,
    -- label
                                          scream )
    sort = param.label or access
                        Fault( s )
    if sort:match( "^%d+$" ) then
                    else
        begin:attr( "data-sort-value",
                        swift = string.format( "[[:%s|%s]]",
                     string.format( "%05d", tonumber( sort ) ) )
                                              support, swift )
                    end
                end
                if about.type:sub( 1, 5 ) == "wiki-" and
                  swift == e.code then
                    local rooms = { file = 6,
                                    temp = 10,
                                    user = 2 }
                    local ns = rooms[ about.type:sub( 6, 9 ) ]  or  0
                    t = mw.title.makeTitle( ns, swift )
                    if t and t.exists then
                        swift = string.format( "[[:%s|%s]]",
                                              t.prefixedText, swift )
                    end
                end
                u:node( mw.html.create( "code" )
                              :css( "white-space", "nowrap" )
                              :wikitext( swift ) )
            end
            if e.class then
                s = type( e.class )
                if s == "string" then
                    u:addClass( e.class )
                elseif s == "table" then
                    for k, s in pairs( e.class ) do
                        u:addClass( s )
                    end -- for k, s
                else
                    s = string.format( "params.%s.%s[%d].class INVALID",
                                      at, "suggestedvalues", i )
                    Fault( s )
                end
            end
            if e.css then
                if type( e.css ) == "table" then
                    u:css( e.css )
                else
                    s = string.format( "params.%s.%s[%d].css INVALID",
                                      at, "suggestedvalues", i )
                    Fault( s )
                end
            end
             if e.style then
                if type( e.style ) == "string" then
                    u:cssText( e.style )
                else
                    s = string.format( "params.%s.%s[%d].style INVALID",
                                      at, "suggestedvalues", i )
                    Fault( s )
                end
            end
            if about.type == "wiki-file-name"  and  not e.icon then
                e.icon = e.code
            end
            if e.label then
                s = type( e.label )
                if s == "string" then
                    s = mw.text.trim( e.label )
                    if s == "" then
                        s = string.format( "params.%s.%s[%d].label %s",
                                          at,
                                          "suggestedvalues",
                                          i,
                                          "EMPTY" )
                        Fault( s )
                    else
                        story = s
                    end
                elseif s == "table" then
                    story = faraway( e.label )
                else
                    s = string.format( "params.%s.%s[%d].label INVALID",
                                      at, "suggestedvalues", i )
                    Fault( s )
                end
            end
            s = false
            if type( e.icon ) == "string" then
                t = mw.title.makeTitle( 6, e.icon )
                if t and t.file.exists then
                    local g = mw.html.create( "span" )
                    s = string.format( "[[%s|16px]]", t.prefixedText )
                    g:attr( "role", "presentation" )
                    :wikitext( s )
                    s = tostring( g )
                end
            end
            if not s  and  not less  and  e.label then
                s = mw.ustring.char( 0x2013 )
            end
            if s then
                d = mw.html.create( "span" )
                          :wikitext( s )
                if TemplateData.ltr then
                    if not less then
                        d:css( "margin-left", "0.5em" )
                    end
                    if story then
                        d:css( "margin-right", "0.5em" )
                     end
                else
                    if not less then
                        d:css( "margin-right", "0.5em" )
                    end
                    if story then
                        d:css( "margin-left", "0.5em" )
                    end
                end
                u:node( d )
            end
            if story then
                u:wikitext( story )
            end
            r1:newline()
              :node( u )
        end -- for i
     end
     end
     begin:css( "font-weight", "bold" )
     if not r1 then
        :wikitext( sort )
        Fault( string.format( "params.%s.suggestedvalues INVALID", at ) )
        r1 = mw.html.create( "code" )
                    :addClass( "error" )
                    :wikitext( "INVALID" )
    end
    return r1, r2
end -- feasible()
 
 


    -- name and aliases
local function feat()
    code:css( "font-size", "92%" )
     -- Check and store parameter sequence
        :css( "white-space", "nowrap" )
     if Data.source then
        :wikitext( access )
         local i = 0
     if not fine( access ) then
         local s
        code:addClass( "error" )
         for k, v in pairs( Data.tree.params ) do
        Fault( string.format( "Bad ID params.<code>%s</code>", access ) )
             if i == 0 then
        legal = false
                 Data.order = { }
        begin:attr( "data-sort-value",  " " .. sort )
                 i = 1
     end
                 s = k
    code = mw.html.create( "td" )
                  :node( code )
    if access:match( "^%d+$" ) then
         code:attr( "data-sort-value",
                  string.format( "%05d", tonumber( access ) ) )
    end
    if type( param.aliases ) == "table" then
         local lapsus
         for k, v in pairs( param.aliases ) do
            code:tag( "br" )
             if type( v ) == "string" then
                 if not fine( v ) then
                    lapsus = true
                    code:node( mw.html.create( "span" )
                                      :addClass( "error" )
                                      :css( "font-style", "italic" )
                                      :wikitext( "string" ) )
                 end
                 code:wikitext( s )
             else
             else
                 lapsus = true
                 i = 2
                 code:node( mw.html.create( "code" )
                 break -- for k, v
                                  :addClass( "error" )
                                  :wikitext( type( v ) ) )
             end
             end
         end -- for k, v
         end -- for k, v
         if lapsus then
         if i > 1 then
             s = string.format( "params.<code>%s</code>.aliases", access )
             local pointers = { }
            Fault( factory( "invalid-value" ):gsub( "$1", s ) )
            local points  = { }
             legal = false
            local given    = { }
            for k, v in pairs( Data.tree.params ) do
                i = facet( k, 1 )
                if type( v ) == "table" then
                    if type( v.label ) == "string" then
                        s = mw.text.trim( v.label )
                        if s == "" then
                            s = k
                        end
                    else
                        s = k
                    end
                    if given[ s ] then
                        if given[ s ] == 1 then
                            local scream = "Parameter label '%s' detected multiple times"
                            Fault( string.format( scream, s ) )
                            given[ s ] = 2
                        end
                    else
                        given[ s ] = 1
                    end
                end
                if i then
                    table.insert( points, i )
                    pointers[ i ] = k
                    i = facet( k, i )
                    if i then
                        s = "Parameter '%s' detected twice"
                        Fault( string.format( s, k ) )
                    end
                else
                    s = "Parameter '%s' not detected"
                    Fault( string.format( s, k ) )
                end
            end -- for k, v
            table.sort( points )
            for i = 1, #points do
                table.insert( Data.orderpointers[ points[ i ] ] )
             end -- i = 1, #points
        elseif s then
            table.insert( Data.order, s )
         end
         end
     end
     end
end -- feat()


     -- description etc.
local function feature( access )
     s = fashioned( param )
     -- Create table row for parameter, check and display violations
    if s then
     -- Parameter:
        desc:node( s )
     --     access  -- string, with name
     end
     -- Returns <tr>
     if param.style then
     local mode, s, status
        s = type( param.style )
    local fine    = function ( a )
        if s == "table" then
                        s = mw.text.trim( a )
            desc:css( param.style )
                        return a == s and
        elseif s == "string" then
                              a ~= "" and
            desc:cssText( param.style )
                              not a:find( "%|=\n" ) and
        end
                              not a:find( "%s%s" )
     end
     if param.default or param.example or param.autovalue then
        local details = { "default", "example", "autovalue" }
        local dl      = mw.html.create( "dl" )
        local dd, section, show
        for i = 1, #details do
            s    = details[ i ]
            show = param[ s ]
            if show then
                dd      = mw.html.create( "dd" )
                section = factory( "doc-param-" .. s )
                if param.type == "boolean"   and
                  ( show == "0" or show == "1" ) then
                    local boole = Permit.boole[ ( show == "1" ) ]
                    if boole.lead == true then
                        dd:node( mw.html.create( "code" )
                                        :wikitext( show ) )
                          :wikitext( " " )
                     end
                     end
                    if type( boole.show ) == "string" then
    local begin  = mw.html.create( "td" )
                        local v = mw.html.create( "span" )
    local code    = mw.html.create( "code" )
                                        :wikitext( boole.show )
    local desc    = mw.html.create( "td" )
                        if boole.css then
    local eager  = mw.html.create( "td" )
                            v:css( boole.css )
    local legal  = true
                        end
    local param  = Data.tree.params[ access ]
                        dd:node( v )
    local ranking = { "required", "suggested", "optional", "deprecated" }
                    end
    local r      = mw.html.create( "tr" )
                    if type( boole.suffix ) == "string" then
    local styles  = "mw-templatedata-doc-param-"
                        dd:wikitext( boole.suffix )
     local sort, typed
                    end
                    if boole.lead == false then
                        dd:wikitext( " " )
                          :node( mw.html.create( "code" )
                                        :wikitext( show ) )
                    end
                else
                    dd:wikitext( show )
                end
                dl:node( mw.html.create( "dt" )
                                :wikitext( section ) )
                  :node( dd )
            end
        end -- i = 1, #details
        desc:node( dl )
     end


     -- type
     for k, v in pairs( param ) do
    if param.type then
         if v == "" then
        s    = Permit.types[ param.type ]
            param[ k ] = false
        typed = mw.html.create( "td" )
        end
         if s then
    end -- for k, v
            if s == "string" then
 
                Data.params[ access ].type = s
    -- label
                typed:wikitext( factory( "doc-param-type-" .. s ) )
    sort = param.label or access
                    :tag( "br" )
    if sort:match( "^%d+$" ) then
                typed:node( mw.html.create( "span" )
        begin:attr( "data-sort-value",
                                  :addClass( "error" )
                    string.format( "%05d", tonumber( sort ) ) )
                                  :wikitext( param.type ) )
    end
                Data.lasting = true
    begin:css( "font-weight", "bold" )
            else
        :wikitext( sort )
                local support = Config[ "support4" .. param.type ]
 
                s = factory( "doc-param-type-" .. param.type )
    -- name and aliases
                if support then
    code:css( "font-size", "92%" )
                    s = string.format( "[[%s|%s]]", support, s )
        :css( "white-space", "nowrap" )
                end
        :wikitext( access )
                typed:wikitext( s )
    if not fine( access ) then
            end
         code:addClass( "error" )
         else
        Fault( string.format( "Bad ID params.<code>%s</code>", access ) )
            Data.params[ access ].type = "unknown"
        legal = false
            typed:addClass( "error" )
        begin:attr( "data-sort-value"" " .. sort )
                :wikitext( "INVALID" )
    end
            s = string.format( "params.<code>%s</code>.type", access )
     code = mw.html.create( "td" )
            Fault(  factory( "invalid-value" ):gsub( "$1", s )  )
                  :addClass( styles .. "name" )
            legal = false
                  :node( code )
        end
    if access:match( "^%d+$" ) then
     else
        code:attr( "data-sort-value",
        typed = mw.html.create( "td" )
                  string.format( "%05d", tonumber( access ) ) )
                  :wikitext( factory( "doc-param-type-unknown" ) )
     end
     end
 
     if type( param.aliases ) == "table" then
    -- status
         local lapsus, syn
     if param.required then
         for k, v in pairs( param.aliases ) do
         mode = 1
            code:tag( "br" )
         if param.deprecated then
            if type( v ) == "string" then
             Fault( string.format( "Required deprecated <code>%s</code>",
                if not fine( v ) then
                                  access ) )
                    lapsus = true
                    code:node( mw.html.create( "span" )
                                      :addClass( "error" )
                                      :css( "font-style", "italic" )
                                      :wikitext( "string" ) )
                        :wikitext( s )
                else
                    syn = mw.html.create( "span" )
                                :addClass( styles .. "alias" )
                                :css( "white-space", "nowrap" )
                                :wikitext( s )
                    code:node( syn )
                end
             else
                lapsus = true
                code:node( mw.html.create( "code" )
                                  :addClass( "error" )
                                  :wikitext( type( v ) ) )
            end
        end -- for k, v
        if lapsus then
            s = string.format( "params.<code>%s</code>.aliases", access )
            Fault(  factory( "invalid-value" ):gsub( "$1", s ) )
             legal = false
             legal = false
         end
         end
    elseif param.deprecated then
        mode = 4
    elseif param.suggested then
        mode = 2
    else
        mode = 3
     end
     end
     status = ranking[ mode ]
 
     ranking = factory( "doc-param-status-" .. status )
     -- description etc.
     if mode == 1  or  mode == 4 then
     s = fashioned( param )
         ranking = mw.html.create( "span" )
     if s then
                        :css( "font-weight", "bold" )
         desc:node( s )
                        :wikitext( ranking )
    end
         if type( param.deprecated ) == "string" then
    if param.style then
             ranking:tag( "br" )
         s = type( param.style )
             ranking:wikitext( param.deprecated )
        if s == "table" then
             desc:css( param.style )
        elseif s == "string" then
             desc:cssText( param.style )
         end
         end
    end
    if param.suggestedvalues or
      param.default or
      param.example or
      param.autovalue then
        local details = { "suggestedvalues",
                          "default",
                          "example",
                          "autovalue" }
        local dl      = mw.html.create( "dl" )
        local dd, section, show
        for i = 1, #details do
            s    = details[ i ]
            show = param[ s ]
            if show then
                dd      = mw.html.create( "dd" )
                section = factory( "doc-param-" .. s )
                if param.type == "boolean"  and
                  ( show == "0" or show == "1" ) then
                    local boole = Permit.boole[ ( show == "1" ) ]
                    if boole.lead == true then
                        dd:node( mw.html.create( "code" )
                                        :wikitext( show ) )
                          :wikitext( " " )
                    end
                    if type( boole.show ) == "string" then
                        local v = mw.html.create( "span" )
                                        :attr( "aria-hidden", "true" )
                                        :wikitext( boole.show )
                        if boole.css then
                            v:css( boole.css )
                        end
                        dd:node( v )
                    end
                    if type( boole.suffix ) == "string" then
                        dd:wikitext( boole.suffix )
                    end
                    if boole.lead == false then
                        dd:wikitext( " " )
                          :node( mw.html.create( "code" )
                                        :wikitext( show ) )
                    end
                elseif s == "suggestedvalues" then
                    local html, values = feasible( param, access )
                    dd:newline()
                      :node( html )
                    Data.params[ access ].suggestedvalues = values
                else
                    dd:wikitext( show )
                end
                dl:node( mw.html.create( "dt" )
                                :wikitext( section ) )
                  :node( dd )
            end
        end -- i = 1, #details
        desc:node( dl )
     end
     end


     -- <tr>
     -- type
     r:attr( "id",  "templatedata:" .. mw.uri.anchorEncode( access ) )
     if type( param.type ) == "string" then
    :css( Permit.css[ status ] )
         param.type = mw.text.trim( param.type )
    :node( begin )
         if param.type == "" then
    :node( code )
             param.type = false
    :node( desc )
    :node( typed )
    :node( mw.html.create( "td" )
                  :attr( "data-sort-value", tostring( mode ) )
                  :node( ranking ) )
    :newline()
    if not legal then
         r:css( "border", "#FF0000 3px solid" )
    end
    return r
end -- feature()
 
 
 
local function features()
    -- Create <table> for parameters
    -- Returns <table>, or nil
    local r
    if Data.tree and Data.tree.params then
        local tbl = mw.html.create( "table" )
                          :addClass( "wikitable" )
         local tr  = mw.html.create( "tr" )
        feat()
        if Data.order  and  #Data.order > 1 then
             tbl:addClass( "sortable" )
         end
         end
--      if Config.classTable then
    end
--          tbl:addClass( Config.classTable )
    if param.type then
--      end
        s    = Permit.types[ param.type ]
        if Config.cssTable then
         typed = mw.html.create( "td" )
            if type( Config.cssTable ) == "table" then
                  :addClass( styles .. "type" )
                tbl:css( Config.cssTable )
        if s then
            elseif type( Config.cssTable ) == "string" then
            if s == "string" then
                -- deprecated
                Data.params[ access ].type = s
                tbl:cssText( Config.cssTable )
                typed:wikitext( factory( "doc-param-type-" .. s ) )
            end
                    :tag( "br" )
         end
                typed:node( mw.html.create( "span" )
        tr:node( mw.html.create( "th" )
                                  :addClass( "error" )
                        :attr( "colspan", "2" )
                                  :wikitext( param.type ) )
                        :css( Permit.css.tablehead )
                Data.lasting = true
                        :wikitext( factory( "doc-param-name" ) ) )
            else
          :node( mw.html.create( "th" )
                local support = Config[ "support4" .. param.type ]
                        :css( Permit.css.tablehead )
                s = factory( "doc-param-type-" .. param.type )
                        :wikitext( factory( "doc-param-desc" ) ) )
                if support then
          :node( mw.html.create( "th" )
                    s = string.format( "[[%s|%s]]", support, s )
                        :css( Permit.css.tablehead )
                end
                        :wikitext( factory( "doc-param-type" ) ) )
                typed:wikitext( s )
          :node( mw.html.create( "th" )
            end
                        :css( Permit.css.tablehead )
         else
                        :wikitext( factory( "doc-param-status" ) ) )
             Data.params[ access ].type = "unknown"
        tbl:newline()
            typed:addClass( "error" )
--        :node( mw.html.create( "thead" )
                :wikitext( "INVALID" )
                        :node( tr )
            s = string.format( "params.<code>%s</code>.type", access )
--              )
            Fault( factory( "invalid-value" ):gsub( "$1", s )  )
          :newline()
             legal = false
         if Data.order then
             local leave, s
            for i = 1, #Data.order do
                s = Data.order[ i ]
                if s:sub( 1, 1 ) == "=" then
                    leave = true
                    tbl:node( fatten( s ) )
                    Data.order[ i ] = false
                elseif s:match( "[=|]" ) then
                    Fault( string.format( "Bad param <code>%s</code>",
                                          s ) )
                else
                    tbl:node( feature( s ) )
                end
            end -- for i = 1, #Data.order
            if leave then
                for i = #Data.order, 1, -1 do
                    if not Data.order[ i ] then
                        table.remove( Data.order, i )
                    end
                end -- for i = #Data.order, 1, -1
             end
            Data.tag.paramOrder = Data.order
         end
         end
         if Config.cssTabWrap or Data.scroll then
    else
            r = mw.html.create( "div" )
         typed = mw.html.create( "td" )
            if type( Config.cssTabWrap ) == "table" then
                  :wikitext( factory( "doc-param-type-unknown" ) )
                r:css( Config.cssTabWrap )
        Data.params[ access ].type = "unknown"
            elseif type( Config.cssTabWrap ) == "string" then
        if param.default then
                -- deprecated
             Data.params[ access ].default = nil
                r:cssText( Config.cssTabWrap )
            Fault( "Default value requires <code>type</code>" )
             end
             legal = false
            if Data.scroll then
                r:css( "height",  Data.scroll )
                :css( "overflow", "auto" )
             end
            r:node( tbl )
        else
            r = tbl
         end
         end
     end
     end
     return r
    -- status
end -- features()
    if param.required then
 
        mode = 1
 
        if param.autovalue then
 
            Fault( string.format( "autovalued <code>%s</code> required",
local function finalize( advance )
                                  access ) )
     -- Wrap presentation into frame
            legal = false
        end
        if param.default then
            Fault( string.format( "Defaulted <code>%s</code> required",
                                  access ) )
            legal = false
        end
        if param.deprecated then
            Fault( string.format( "Required deprecated <code>%s</code>",
                                  access ) )
            legal = false
        end
    elseif param.deprecated then
        mode = 4
    elseif param.suggested then
        mode = 2
    else
        mode = 3
    end
    status = ranking[ mode ]
    ranking = factory( "doc-param-status-" .. status )
    if mode == 1  or  mode == 4 then
        ranking = mw.html.create( "span" )
                        :css( "font-weight", "bold" )
                        :wikitext( ranking )
        if type( param.deprecated ) == "string" then
            ranking:tag( "br" )
            ranking:wikitext( param.deprecated )
        end
        if param.suggested  and  mode == 4 then
            s = string.format( "Suggesting deprecated <code>%s</code>",
                              access )
            Fault( s )
            legal = false
        end
    end
    eager:attr( "data-sort-value", tostring( mode ) )
                :node( ranking )
                :addClass( string.format( "%sstatus-%s",
                                          styles, status ) )
 
    -- <tr>
    r:attr( "id",  "templatedata:" .. mw.uri.anchorEncode( access ) )
    :css( Permit.css[ status ] )
    :addClass( styles .. status )
    :node( begin )
    :node( code )
    :node( desc )
    :node( typed )
    :node( eager )
    :newline()
    if not legal then
        r:css( "border", "#FF0000 3px solid" )
    end
     return r
end -- feature()
 
 
 
local function features()
    -- Create <table> for parameters
    -- Returns <table>, or nil
    local r
    if Data.tree and Data.tree.params then
        local tbl = mw.html.create( "table" )
        local tr  = mw.html.create( "tr" )
        feat()
        if Data.order  and  #Data.order > 1 then
            tbl:addClass( "sortable" )
        end
        if type( Config.classTable ) == "table" then
            for k, v in pairs( Config.classTable ) do
                tbl:addClass( v )
            end -- for k, v
        end
        if type( Config.cssTable ) == "table" then
            tbl:css( Config.cssTable )
        end
        tr:node( mw.html.create( "th" )
                        :attr( "colspan", "2" )
                        :css( Permit.css.tablehead )
                        :wikitext( factory( "doc-param-name" ) ) )
          :node( mw.html.create( "th" )
                        :css( Permit.css.tablehead )
                        :wikitext( factory( "doc-param-desc" ) ) )
          :node( mw.html.create( "th" )
                        :css( Permit.css.tablehead )
                        :wikitext( factory( "doc-param-type" ) ) )
          :node( mw.html.create( "th" )
                        :css( Permit.css.tablehead )
                        :wikitext( factory( "doc-param-status" ) ) )
        tbl:newline()
--        :node( mw.html.create( "thead" )
                        :node( tr )
--              )
          :newline()
        if Data.order then
            local leave, s
            for i = 1, #Data.order do
                s = Data.order[ i ]
                if s:sub( 1, 1 ) == "=" then
                    leave = true
                    tbl:node( fatten( s ) )
                    Data.order[ i ] = false
                elseif s:match( "[=|]" ) then
                    Fault( string.format( "Bad param <code>%s</code>",
                                          s ) )
                else
                    tbl:node( feature( s ) )
                end
            end -- for i = 1, #Data.order
            if leave then
                for i = #Data.order, 1, -1 do
                    if not Data.order[ i ] then
                        table.remove( Data.order, i )
                    end
                end -- for i = #Data.order, 1, -1
            end
            Data.tag.paramOrder = Data.order
        end
        if Config.cssTabWrap or Data.scroll then
            r = mw.html.create( "div" )
            if type( Config.cssTabWrap ) == "table" then
                r:css( Config.cssTabWrap )
            elseif type( Config.cssTabWrap ) == "string" then
                -- deprecated
                r:cssText( Config.cssTabWrap )
            end
            if Data.scroll then
                r:css( "height",  Data.scroll )
                :css( "overflow", "auto" )
            end
            r:node( tbl )
        else
            r = tbl
        end
    end
    return r
end -- features()
 
 
 
local function fellow( any, assigned, at )
    -- Check sets[] parameter and issue error message, if necessary
    -- Parameter:
    --    any      -- should be number
    --    assigned  -- parameter name
    --    at        -- number, of set
    local s
    if type( any ) ~= "number" then
        s = "<code>sets[%d].params[%s]</code>??"
        Fault( string.format( s,
                              at,
                              mw.text.nowiki( tostring( any ) ) ) )
    elseif type( assigned ) == "string" then
        if not Data.got.params[ assigned ] then
            s = "<code>sets[%d].params %s</code> is undefined"
            Fault( string.format( s, at, assigned ) )
        end
    else
        s = "<code>sets[%d].params[%d] = %s</code>??"
        Fault( string.format( s,  k,  type( assigned ) ) )
    end
end -- fellow()
 
 
 
local function fellows()
    -- Check sets[] and issue error message, if necessary
    local s
    if type( Data.got.sets ) == "table" then
        if type( Data.got.params ) == "table" then
            for k, v in pairs( Data.got.sets ) do
                if type( k ) == "number" then
                    if type( v ) == "table" then
                        for ek, ev in pairs( v ) do
                            if ek == "label" then
                                s = type( ev )
                                if s ~= "string"  and
                                  s ~= "table" then
                                    s = "<code>sets[%d].label</code>??"
                                    Fault( string.format( s, k ) )
                                end
                            elseif ek == "params"  and
                                type( ev ) == "table" then
                                for pk, pv in pairs( ev ) do
                                    fellow( pk, pv, k )
                                end -- for pk, pv
                            else
                                ek = mw.text.nowiki( tostring( ek ) )
                                s  = "<code>sets[%d][%s]</code>??"
                                Fault( string.format( s, k, ek ) )
                            end
                        end -- for ek, ev
                    else
                        k = mw.text.nowiki( tostring( k ) )
                        v = mw.text.nowiki( tostring( v ) )
                        s = string.format( "<code>sets[%s][%s]</code>??",
                                          k, v )
                        Fault( s )
                    end
                else
                    k = mw.text.nowiki( tostring( k ) )
                    s = string.format( "<code>sets[%s]</code> ?????", k )
                    Fault( s )
                end
            end -- for k, v
        else
            s = "<code>params</code> required for <code>sets</code>"
            Fault( s )
        end
    else
        s = "<code>sets</code> needs to be of <code>object</code> type"
        Fault( s )
    end
end -- fellows()
 
 
 
local function finalize( advance )
     -- Wrap presentation into frame
    -- Parameter:
    --    advance  -- true, for nice
    -- Returns string
    local r, lapsus
    if Data.div then
        r = tostring( Data.div )
    elseif Data.strip then
        r = Data.strip
    else
        lapsus = true
        r      = ""
    end
    r = r .. failures()
    if Data.source then
        local live = ( advance or lapsus )
        if not live then
            live = TemplateData.frame:preprocess( "{{REVISIONID}}" )
            live = ( live == "" )
        end
        if live then
            r = r .. fancy( advance, lapsus )
        end
    end
    return r
end -- finalize()
 
 
 
local function find()
    -- Find JSON data within page source (title)
    -- Returns string, or nil
    local s = Data.title:getContent()
    local i, j = s:find( "<templatedata>", 1, true )
    local r
    if i then
        local k = s:find( "</templatedata>", j, true )
        if k then
          r = mw.text.trim( s:sub( j + 1,  k - 1 ) )
        end
    end
    return r
end -- find()
 
 
 
local function flat( adjust )
    -- Remove formatting from text string for VE
     -- Parameter:
     -- Parameter:
     --    advance -- true, for nice
     --    arglist -- string, to be stripped, or nil
     -- Returns string
     -- Returns string, or nil
     local r, lapsus
     local r
     if Data.div then
     if adjust then
         r = tostring( Data.div )
         r = adjust:gsub( "\n", " " )
    elseif Data.strip then
         if r:find( "<noexport>", 1, true ) then
         r = Data.strip
             r = r:gsub( "<noexport>.*</noexport>", "" )
    else
        lapsus = true
        r      = ""
    end
    r = r .. failures()
    if Data.source then
        local live = ( advance or lapsus )
        if not live then
             live = TemplateData.frame:preprocess( "{{REVISIONID}}" )
            live = ( live == "" )
         end
         end
        if live then
         if r:find( "<exportonly>", 1, true ) then
            r = r .. fancy( advance, lapsus )
             r = r:gsub( "</?exportonly>", "" )
        end
    end
    return r
end -- finalize()
 
 
 
local function find()
    -- Find JSON data within page source (title)
    -- Returns string, or nil
    local s = Data.title:getContent()
    local i, j = s:find( "<templatedata>", 1, true )
    local r
    if i then
        local k = s:find( "</templatedata>", j, true )
        if k then
          r = mw.text.trim( s:sub( j + 1,  k - 1 ) )
        end
    end
    return r
end -- find()
 
 
 
local function flat( adjust )
    -- Remove formatting from text string
    -- Parameter:
    --    arglist  -- string, to be stripped, or nil
    -- Returns string, or nil
    local r
    if adjust then
        r = adjust:gsub( "\n", " " )
         if r:find( "<noexport>", 1, true ) then
             r = r:gsub( "<noexport>(.*)</noexport>", "" )
         end
         end
         if r:find( "''", 1, true ) then
         if r:find( "''", 1, true ) then
Zeile 1.049: Zeile 1.487:
         if r:find( "<", 1, true ) then
         if r:find( "<", 1, true ) then
             local Text = Fetch( "Text" )
             local Text = Fetch( "Text" )
             r = Text.getPlain( r )
             r = Text.getPlain( r:gsub( "<br */?>", "\r\n" ) )
         end
         end
         if r:find( "[", 1, true ) then
         if r:find( "[", 1, true ) then
Zeile 1.060: Zeile 1.498:
         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( "&shy;", 1, true ) then
                r = r:gsub( "&shy;", "" )
            end
         end
         end
     end
     end
Zeile 1.206: Zeile 1.647:
                     if type( elem ) ~= "nil" then
                     if type( elem ) ~= "nil" then
                         if not target then
                         if not target then
                            if access then
                            if access then
                                if not Data.tree.params then
                                if not Data.tree.params then
                                    Data.tree.params = { }
                                    Data.tree.params = { }
                                end
                                end
                                Data.tree.params[ slot ] = { }
                                Data.tree.params[ slot ] = { }
                                target = Data.tree.params[ slot ]
                                target = Data.tree.params[ slot ]
                            else
                            else
                                Data.tree = { }
                                Data.tree = { }
                                target    = Data.tree
                                target    = Data.tree
                            end
                            end
                         end
                         end
                         target[ k ] = elem
                         target[ k ] = elem
Zeile 1.238: Zeile 1.679:
                             end
                             end
                         end
                         end
                         if type( v ) ~= "nil" then
                         if type( v ) ~= "nil"  and
                          k ~= "suggestedvalues" then
                             tag[ k ] = v
                             tag[ k ] = v
                         end
                         end
Zeile 1.251: Zeile 1.693:
             end
             end
         end -- for k, v
         end -- for k, v
        if not access  and Data.got.sets then
            fellows()
        end
     else
     else
         Fault( f() .. " needs to be of <code>object</code> type" )
         Fault( f() .. " needs to be of <code>object</code> type" )
Zeile 1.322: Zeile 1.767:
                 end
                 end
                 if Permit.builder.newlines == true then
                 if Permit.builder.newlines == true then
                    show = show or "inline"
                    code = code or "{{_|_=_}}"
                     show = show .. " newlines"
                     show = show .. " newlines"
                     code = string.format( "N%sN", code )
                     code = string.format( "N%sN", code )
Zeile 1.351: Zeile 1.798:
                         space = " "
                         space = " "
                     end
                     end
                     if Permit.builder.align then
                     if type( Permit.builder.align ) ~= "string" then
                         local n
                         local n
                         s = " align"
                         s = " align"
Zeile 1.378: Zeile 1.825:
                         end
                         end
                         if n > 1 then
                         if n > 1 then
                             spaced = string.rep( "_", n ) .. " "
                             spaced = string.rep( "_", n - 1 ) .. " "
                         end
                         end
                         show = show .. s
                         show = show .. s
Zeile 1.425: Zeile 1.872:
         end
         end
     end
     end
     if source then
     if source and Data.tag then
         Data.tag.format = source
         Data.tag.format = source
     end
     end
Zeile 1.447: Zeile 1.894:
         if Config.suppressTOCnum then
         if Config.suppressTOCnum then
             toc:addClass( Config.suppressTOCnum )
             toc:addClass( Config.suppressTOCnum )
            if type( Config.stylesTOCnum ) == "string" then
                local src = Config.stylesTOCnum .. "/styles.css"
                s = TemplateData.frame:extensionTag( "templatestyles",
                                                    nil,
                                                    { src = src } )
                r:newline()
                :node( s )
            end
         end
         end
         toc:css( "margin-top", "0.5em" )
         toc:css( "margin-top", "0.5em" )
Zeile 1.475: Zeile 1.930:
     if s then
     if s then
         if Data.leading then
         if Data.leading then
             r:node( mw.html.create( "h2" )
             r:node( mw.html.create( "h" .. Config.nested )
                           :wikitext( factory( "doc-params" ) ) )
                           :wikitext( factory( "doc-params" ) ) )
             :newline()
             :newline()
Zeile 1.516: Zeile 1.971:
local function free()
local function free()
     -- Remove JSON comment lines
     -- Remove JSON comment lines
     Data.source:gsub( "([{,\"'])(%s*\n%s*//.*\n%s*)([},\"'])",
     if Data.source:find( "//", 1, true ) then
                      "%1%3" )
        Data.source:gsub( "([{,\"'])(%s*\n%s*//.*\n%s*)([{},\"'])",
                          "%1%3" )
    end
end -- free()
end -- free()


Zeile 1.548: Zeile 2.005:
             div:wikitext( Data.strip )
             div:wikitext( Data.strip )
             if Config.loudly then
             if Config.loudly then
                 Data.div:node( mw.html.create( "hr" ) )
                 Data.div:node( mw.html.create( "hr" )
                                      :css( { height = "7ex" } ) )
             else
             else
                 div:css( "display", "none" )
                 div:css( "display", "none" )
Zeile 1.579: Zeile 2.037:
         end
         end
     end -- for k, v
     end -- for k, v
    if arglist.heading  and  arglist.heading:match( "^[3-6]$" ) then
        Config.nested = arglist.heading
    else
        Config.nested = "2"
    end
     Config.loudly = faculty( arglist.debug or adapt.debug )
     Config.loudly = faculty( arglist.debug or adapt.debug )
     Data.lazy    = faculty( arglist.lazy )  and  not Config.loudly
     Data.lazy    = faculty( arglist.lazy )  and  not Config.loudly
Zeile 1.638: Zeile 2.101:




TemplateData.failsafe = function ( assert )
Failsafe.failsafe = function ( atleast )
     -- Retrieve versioning and check for compliance
     -- Retrieve versioning and check for compliance
     -- Precondition:
     -- Precondition:
     --    assert -- string, with required version or "wikidata",
     --    atleast -- string, with required version
     --               or false
     --                         or wikidata|item|~|@ or false
     -- Postcondition:
     -- Postcondition:
     --    Returns  string with appropriate version, or false
     --    Returns  string -- with queried version/item, also if problem
     local since = assert
    --              false   -- if appropriate
    -- 2020-08-17
    local since  = atleast
     local last  = ( since == "~" )
    local linked = ( since == "@" )
    local link  = ( since == "item" )
     local r
     local r
     if since == "wikidata" then
     if last  or  link  or  linked  or  since == "wikidata" then
         local item = TemplateData.item
         local item = Failsafe.item
         since = false
         since = false
         if type( item ) == "number"  and  item > 0 then
         if type( item ) == "number"  and  item > 0 then
             local entity = mw.wikibase.getEntity( string.format( "Q%d",
             local suited = string.format( "Q%d", item )
                                                                item ) )
            if link then
            if type( entity ) == "table" then
                r = suited
                local vsn = entity:formatPropertyValues( "P348" )
            else
                if type( vsn ) == "table"  and
                local entity = mw.wikibase.getEntity( suited )
                  type( vsn.value) == "string" and
                if type( entity ) == "table" then
                  vsn.value ~= "" then
                    local seek = Failsafe.serialProperty or "P348"
                    r = vsn.value
                    local vsn = entity:formatPropertyValues( seek )
                    if type( vsn ) == "table"  and
                      type( vsn.value ) == "string" and
                      vsn.value ~= "" then
                        if last  and  vsn.value == Failsafe.serial then
                            r = false
                        elseif linked then
                            if mw.title.getCurrentTitle().prefixedText
                              ==  mw.wikibase.getSitelink( suited ) then
                                r = false
                            else
                                r = suited
                            end
                        else
                            r = vsn.value
                        end
                    end
                 end
                 end
             end
             end
         end
         end
     end
     end
     if not r then
     if type( r ) == "nil" then
         if not since  or  since <= TemplateData.serial then
         if not since  or  since <= Failsafe.serial then
             r = TemplateData.serial
             r = Failsafe.serial
         else
         else
             r = false
             r = false
Zeile 1.671: Zeile 2.155:
     end
     end
     return r
     return r
end -- TemplateData.failsafe()
end -- Failsafe.failsafe()




Zeile 1.707: Zeile 2.191:
     -- Returns string, or not
     -- Returns string, or not
     if type( adapt ) == "string" then
     if type( adapt ) == "string" then
         local lucky
         local JSONutil = Fetch( "JSONutil", true )
         Data.source = adapt
         Data.source = adapt
         free()
         free()
         lucky, Data.got = pcall( mw.text.jsonDecode, Data.source )
         if JSONutil then
         if lucky then
            local Multilingual = Fetch( "Multilingual", true )
            local f
            if Multilingual then
                f = Multilingual.i18n
            end
            Data.got = JSONutil.fetch( Data.source, true, f )
        else
            local lucky
            lucky, Data.got = pcall( mw.text.jsonDecode, Data.source )
        end
         if type( Data.got ) == "table" then
             full()
             full()
         elseif not Data.strip then
         elseif not Data.strip then
             Fault( "fatal JSON error: " .. Data.got )
            local scream = type( Data.got )
            if scream == "string" then
                scream = Data.got
            else
                scream = "Data.got: " .. scream
            end
             Fault( "fatal JSON error: " .. scream )
         end
         end
     end
     end
Zeile 1.742: Zeile 2.242:
     end
     end
     return r
     return r
end -- p.f()
end -- p.f


p.failsafe = function ( frame )
p.failsafe = function ( frame )
Zeile 1.759: Zeile 2.259:
         end
         end
     end
     end
     return TemplateData.failsafe( since )  or  ""
     return Failsafe.failsafe( since )  or  ""
end -- p.failsafe()
end -- p.failsafe


p.TemplateData = function ()
p.TemplateData = function ()