Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

Modul:Vorlage:Literatur: Unterschied zwischen den Versionen

Aus imedwiki
Zur Navigation springen Zur Suche springen
(2016-05-20)
K (Änderungen von Otherwikibot (Diskussion) wurden auf die letzte Version von Christoph Holtermann zurückgesetzt)
Markierung: Zurücksetzung
 
(22 dazwischenliegende Versionen von 5 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local Serial = "2016-05-20"
+
local Serial = "2019-06-11"
 
--[=[
 
--[=[
 
Unterstützung für {{Literatur}}
 
Unterstützung für {{Literatur}}
Zeile 10: Zeile 10:
 
local KategorieBeginn  =  "Wikipedia:Vorlagenfehler"
 
local KategorieBeginn  =  "Wikipedia:Vorlagenfehler"
 
local Kategorien      =
 
local Kategorien      =
    { Intern              = { s = "/Interner Fehler" },
+
                { Intern              = { s = "/Interner Fehler" },
      Parameter          = { s = "/Parameterfehler" },
+
                  Parameter          = { s = "/Parameterfehler" },
      ISBNistFormalFalsch = { s = "/Parameter ISBNistFormalFalsch" },
+
                  MonatTag            = { s = "/Parameter Monat, Tag" },
      TitelP              = { s = "/Parameter Titel-P" }
+
                  Temp1              = { s = "/Temp1" },
    }
+
                  Temp2               = { s = "/Temp2" },
local ParValid = {
+
                  Temp3               = { s = "/Temp3" },
    Autor              = { Autorin=true,
+
                  Temp4               = { s = "/Temp4" },
                            Autoren=true,
+
                }
                            Autorinnen=true },
 
    Hrsg                = { Herausgeber = { low=true },
 
                            Herausgeberin=true },
 
    Titel               = { ["Titel-P"] = { low=true } },
 
    TitelErg            = true,
 
    Sammelwerk          = true,
 
    WerkErg            = true,
 
    Reihe              = true,
 
    BandReihe          = true,
 
    HrsgReihe          = true,
 
    NummerReihe        = true,
 
    Band                = true,
 
    Nummer              = true,
 
    Auflage            = true,
 
    Verlag              = true,
 
    Ort                = true,
 
    Datum              = true,
 
    Jahr                = { Datum=true },
 
    Monat              = { Datum=true,
 
                            Woche=true },
 
    Woche              = { Datum=true },
 
    Tag                = { Datum=true,
 
                            Woche=true },
 
    Kapitel            = true,
 
    Seiten              = true,
 
    Spalten            = true,
 
    ArtikelNr          = true,
 
    Fundstelle          = true,
 
    ISBN                = true,
 
    ISBNformalFalsch    = { ISBNistFormalFalsch=true },
 
    ISBNistFormalFalsch = true,
 
    ISSN                = true,
 
    ISSNformalFalsch    = true,
 
    Umfang              = true,
 
    Sprache            = true,
 
    Kommentar          = true,
 
    Originaltitel      = true,
 
    Originalsprache    = true,
 
    Originalort        = true,
 
    Originaljahr        = true,
 
    ["Übersetzer"]      = { ["Übersetzerin"]=true },
 
    VerlagEA            = true,
 
    OrtEA              = true,
 
    JahrEA              = true,
 
    arXiv               = { Arxiv = { low=true },
 
                            arxiv = { low=true } },
 
    bibcode            = true,
 
    DOI                = true,
 
    DNB                = true,
 
    JSTOR              = true,
 
    LCCN                = true,
 
    Lizenznummer        = true,
 
    OCLC                = true,
 
    PMC                = true,
 
    PMID                = true,
 
    URN                = true,
 
    ZDB                = true,
 
    ID                  = true,
 
    Online              = true,
 
    Abruf              = { Zugriff = { low=true } },
 
    Format              = true,
 
    KBytes              = true,
 
    Zitat              = true,
 
    Typ                = true,
 
    Vorlage            = true }
 
local ParMap = {
 
    Autor            = { "bas",      "Autor" },
 
    Hrsg            = { "bas",      "Hrsg" },
 
    Titel            = { "bas",      "Titel" },
 
    TitelErg        = { "bas",      "TitelErg" },
 
    Sammelwerk      = { "bas",      "Werk" },
 
    WerkErg          = { "bas",      "WerkErg" },
 
    Reihe            = { "serie",    "Reihe" },
 
    BandReihe        = { "serie",    "Band" },
 
    HrsgReihe        = { "serie",    "Hrsg" },
 
    NummerReihe      = { "serie",    "Nummer" },
 
    Band            = { "print",    "Band" },
 
    Nummer          = { "print",    "Nummer" },
 
    Auflage          = { "print",    "Auflage" },
 
    Verlag          = { "bas",      "Verlag" },
 
    Ort              = { "print",    "Ort" },
 
    Datum            = { "bas",      "Datum" },
 
    Kapitel          = { "fragment", "Kapitel" },
 
    Seiten          = { "fragment", "Seiten" },
 
    Spalten          = { "fragment", "Spalten" },
 
    ArtikelNr        = { "fragment", "ArtikelNr" },
 
    Fundstelle      = { "fragment", "Fundstelle" },
 
    ISBN            = { "id",      "ISBN" },
 
    ISBNformalFalsch = { "id",      "ISBNfalsch" },
 
    ISSN            = { "id",      "ISSN" },
 
    ISSNformalFalsch = { "id",      "ISSNfalsch" },
 
    Umfang          = { "print",    "Umfang" },
 
    Sprache          = { "bas",      "Sprache" },
 
    Kommentar        = { "bas",      "Kommentar" },
 
    Zitat            = { "bas",      "Zitat" },
 
    Originaltitel    = { "orig",    "Titel" },
 
    Originalsprache  = { "orig",    "Sprache" },
 
    ["Übersetzer"]  = { "orig",    "Translator" },
 
    OrtEA            = { "ed1",      "Ort" },
 
    JahrEA          = { "ed1",      "Jahr" },
 
    VerlagEA        = { "ed1",      "Verlag" },
 
    Online          = { "www",      "Weblink" },
 
    Abruf            = { "www",      "Abruf" },
 
    Format          = { "www",      "Format" },
 
    KBytes          = { "www",      "KBytes" },
 
    arXiv            = { "id",      "arXiv" },
 
    bibcode          = { "id",      "bibcode" },
 
    DOI              = { "id",      "DOI" },
 
    DNB              = { "id",      "DNB" },
 
    JSTOR            = { "id",      "JSTOR" },
 
    LCCN            = { "id",      "LCCN" },
 
    Lizenznummer    = { "id",      "Lizenznummer" },
 
    OCLC            = { "id",      "OCLC" },
 
    PMC              = { "id",      "PMC" },
 
    PMID            = { "id",      "PMID" },
 
    URN              = { "id",      "URN" },
 
    ZDB              = { "id",      "ZDB" },
 
    ID               = { "id",      "ID" },
 
    Typ              = { "leise",    "Typ" },
 
    Vorlage          = { "leise",    "Vorlage" } }
 
 
local Fehler = false
 
local Fehler = false
local FunLit = { }
+
local Schrei
 
+
local Export = { }
--|Lizenznummer nicht genutzt und nicht länger unterstützt
 
 
 
 
 
 
 
local function fault( a )
 
    -- Formatiere Fehler mit class=error
 
    -- Parameter:
 
    --    a  -- string mit Text
 
    local r
 
    if type( Zitation ) == "table" then
 
        r = Zitation.fault( a )
 
    else
 
        r = string.format( "<span class=\"error\">%s</span>", a )
 
    end
 
    return r
 
end -- fault()
 
  
  
Zeile 170: Zeile 34:
 
                                 k = "Intern" },
 
                                 k = "Intern" },
 
                   Modul    = { s = "Modul-Seite fehlt",
 
                   Modul    = { s = "Modul-Seite fehlt",
                                k = "Intern" },
 
                  Vorlage  = { s = "Vorlagen-Seite fehlt",
 
 
                                 k = "Intern" },
 
                                 k = "Intern" },
 
                   Format    = { s = "Parameterformat" },
 
                   Format    = { s = "Parameterformat" },
Zeile 177: Zeile 39:
 
                                 k = "Parameter" },
 
                                 k = "Parameter" },
 
                   Parameter = { s = "Parameterfehler",
 
                   Parameter = { s = "Parameterfehler",
                                k = "Parameter" },
 
                  Pflicht  = { s = "Pflichtparameter fehlt",
 
 
                                 k = "Parameter" },
 
                                 k = "Parameter" },
 
                   Wert      = { s = "Werte ungültig",
 
                   Wert      = { s = "Werte ungültig",
 
                                 k = "Parameter" },
 
                                 k = "Parameter" },
                   Doppelt  = { s = "Mehrfache Angabe von Parametern",
+
                   MonatTag  = { k = "MonatTag" },
                                k = "Parameter" },
+
                  Temp1    = { k = "Temp1" },
                   ISBNistFormalFalsch = { k = "ISBNistFormalFalsch" },
+
                  Temp2    = { k = "Temp2" },
                   TitelP              = { k = "TitelP" }
+
                   Temp3    = { k = "Temp3" },
 +
                   Temp4    = { k = "Temp4" }
 
                 }
 
                 }
 
     end
 
     end
 
     t = Fehler[ art ]
 
     t = Fehler[ art ]
 
     if t then
 
     if t then
 +
        if t.s  and  not t.e then
 +
            t.e = ""
 +
        end
 
         if anzeige then
 
         if anzeige then
 
             local s = mw.text.nowiki( anzeige )
 
             local s = mw.text.nowiki( anzeige )
Zeile 223: Zeile 87:
 
     if Fehler then
 
     if Fehler then
 
         local sep = ""
 
         local sep = ""
 +
        local suffix
 
         for k, v in pairs( Fehler ) do
 
         for k, v in pairs( Fehler ) do
 
             if v.e then
 
             if v.e then
                 r = string.format( "%s%s*** %s: %s",
+
                 if v.e:sub( 1, 1 ) == ";" then
                                  r,  sep,  v.s or "", v.e )
+
                    suffix = v.s .. v.e
                 sep = " "
+
                elseif v.s then
 +
                    suffix = string.format( "%s: %s", v.s, v.e )
 +
                else
 +
                    suffix = v.e
 +
                end
 +
                Schrei = string.format( "%s%s*** %s",
 +
                                        Schrei or "",
 +
                                        sep,
 +
                                        suffix )
 +
                 sep   = " "
 
             end
 
             end
 
         end -- for k, v
 
         end -- for k, v
        r = "<br />" .. fault( r )
 
 
     end
 
     end
 
     for k, v in pairs( Kategorien ) do
 
     for k, v in pairs( Kategorien ) do
Zeile 245: Zeile 118:
 
     return r
 
     return r
 
end -- fehlerliste()
 
end -- fehlerliste()
 +
 +
 +
 +
local folder = function ()
 +
    -- Parameter-Konfiguration laden
 +
    local s = string.format( "Module:%s/params", Selbst )
 +
    local lucky, params = pcall( mw.loadData, s )
 +
    if type( params ) == "table" then
 +
        Export.params = Export.flat( params )
 +
    else
 +
        error( string.format( "[[%s]] fehlt", s ) )
 +
    end
 +
end -- folder()
  
  
Zeile 252: Zeile 138:
  
  
local Titel = function ( args )
+
Export.flat = function ( adapt )
     --   OBSOLET  nach Bereinigung im ANR
+
     -- Deep copy
     if args[ "Titel-P" ] then
+
    -- Parameter:
         fehler( "TitelP" )
+
    --    adapt  -- something
 +
    -- Returns atomic value, or deep copy of a table with no metatable
 +
    local r
 +
     if type( adapt ) == "table" then
 +
         r = { }
 +
        for k, v in pairs( adapt ) do
 +
            r[ k ] = Export.flat( v )
 +
        end -- for k, v
 +
    else
 +
        r = adapt
 
     end
 
     end
end -- Titel()
+
    return r
 +
end -- Export.flat()
  
  
  
FunLit.Datum = function ( args )
+
Export.Datum = function ( args )
 
     local r = args.Jahr
 
     local r = args.Jahr
 +
    local shit
 
     if r then
 
     if r then
 
         if r:match( "^%d+$" ) then
 
         if r:match( "^%d+$" ) then
Zeile 280: Zeile 177:
 
                         o.month = dm.month
 
                         o.month = dm.month
 
                     else
 
                     else
                         fehler( "Wert",  "'Monat'=" .. args.Monat )
+
                         shit = "'Monat'=" .. args.Monat
 +
                        if args.Nummer then
 +
                            args.Nummer = string.format( "%s, %s",
 +
                                                        args.Nummer,
 +
                                                        args.Monat )
 +
                        else
 +
                            args.Nummer = args.Monat
 +
                        end
 +
                        if not args.Datum then
 +
                            args.Datum = r
 +
                        end
 
                         r = false
 
                         r = false
 
                     end
 
                     end
Zeile 289: Zeile 196:
 
                     end
 
                     end
 
                     if o and tostring( o.month ) ~= s then
 
                     if o and tostring( o.month ) ~= s then
                         fehler( "Wert", "'Monat'=" .. args.Monat )
+
                         fehler( "MonatTag", "'Monat'=" .. args.Monat )
 
                         r = false
 
                         r = false
                     elseif s ~= args.Monat then
+
                     elseif s ~= args.Monat  and
                         fehler( "Format",  "'Monat'=" .. args.Monat )
+
                          "0" .. s ~= args.Monat then
 +
                         fehler( "MonatTag",  "'Monat'=" .. args.Monat )
 
                     end
 
                     end
 
                 end
 
                 end
Zeile 301: Zeile 209:
 
                     end
 
                     end
 
                     if tostring( o.dom ) ~= s then
 
                     if tostring( o.dom ) ~= s then
                         fehler( "Wert",  "'Tag'=" .. args.Tag )
+
                         shit = "'Tag'=" .. args.Tag
 
                         r = false
 
                         r = false
                     elseif s ~= args.Tag then
+
                     elseif s ~= args.Tag  and
                         fehler( "Format",  "'Tag'=" .. args.Tag )
+
                          "0" .. s ~= args.Tag  and
 +
                          s .. "." ~= args.Tag then
 +
                         fehler( "MonatTag",  "'Tag'=" .. args.Tag )
 
                     end
 
                     end
 
                 end
 
                 end
 
             elseif args.Tag then
 
             elseif args.Tag then
                 fehler( "Konflikt", "'Tag' ohne 'Monat'" )
+
                 shit = "'Tag' ohne 'Monat'"
 
                 r = false
 
                 r = false
 
             end
 
             end
Zeile 315: Zeile 225:
 
                 args.Datum = o
 
                 args.Datum = o
 
             end
 
             end
 +
        elseif r:match( "^%[%d%d%d%d%]$" ) then
 +
            args.Datum = r:match( "^%[(%d+)%]$" )
 +
            if args.Kommentar then
 +
                args.Kommentar = ", " .. args.Kommentar
 +
            else
 +
                args.Kommentar = ""
 +
            end
 +
            args.Kommentar  = string.format( "o. J. %s%s",
 +
                                            args.Jahr, args.Kommentar )
 +
            fehler( "Wert", "'Datum'=o.J." )
 
         else
 
         else
             fehler( "Wert",  "'Jahr'=" .. args.Jahr )
+
             if args.Datum then
 +
                fehler( "Wert",  "'Jahr'=" .. args.Jahr )
 +
            else
 +
                args.Datum = args.Jahr
 +
            end
 
         end
 
         end
 
     elseif args.Monat or args.Woche or args.Tag then
 
     elseif args.Monat or args.Woche or args.Tag then
Zeile 322: Zeile 246:
 
     else
 
     else
 
         r = args.Datum
 
         r = args.Datum
 +
    end
 +
    if shit then
 +
      fehler( "MonatTag", shit )
 
     end
 
     end
 
     return r
 
     return r
end -- FunLit.Datum()
+
end -- Export.Datum()
  
  
  
 
local Band = function ( args )
 
local Band = function ( args )
     if args.Reihe and
+
    --    OBSOLET  nach Bereinigung in allen NR
      not args.BandReihe and
+
     if args.Band and not args.Sammelwerk then
      not args.Sammelwerk then
+
        if args.Reihe and not args.BandReihe then
        args.BandReihe = args.Band
+
            args.BandReihe = args.Band
        args.Band      = nil
+
            args.Band      = nil
 +
            fehler( "Temp4" )
 +
            fehler( "Parameter", "Band= meint BandReihe=" )
 +
        elseif args.Titel  and
 +
              args.Titel:find( " In: " ) then
 +
            fehler( "Parameter", "Band= ohne Sammelwerk=" )
 +
        end
 
     end
 
     end
 
end -- Band()
 
end -- Band()
Zeile 340: Zeile 273:
  
 
local Nummer = function ( args )
 
local Nummer = function ( args )
     if args.Reihe and
+
    --    OBSOLET  nach Bereinigung in allen NR
      not args.NummerReihe and
+
     if args.Nummer and not args.Sammelwerk then
      not args.Sammelwerk then
+
        if args.Reihe and not args.NummerReihe then
        args.NummerReihe = args.Nummer
+
            args.NummerReihe = args.Nummer
        args.Nummer      = nil
+
            args.Nummer      = nil
 +
            fehler( "Temp4" )
 +
            fehler( "Parameter", "Nummer= meint NummerReihe=" )
 +
        elseif args.Titel  and
 +
              args.Titel:find( " In: " ) then
 +
            fehler( "Parameter", "Nummer= ohne Sammelwerk=" )
 +
        end
 
     end
 
     end
 
end -- Nummer()
 
end -- Nummer()
Zeile 350: Zeile 289:
  
  
FunLit.ISBN = function ( args )
+
local Herausgeber = function ( args )
     --    OBSOLET  nach Bereinigung im ANR
+
    --    OBSOLET  nach Übernahme in Zentralmodul
     if args.ISBNistFormalFalsch then
+
    if args.Autor  and  args.Autor:find( "(Hrsg.)", 1, true ) then
         if args.ISBN then
+
        fehler( "Wert",
             args.ISBNformalFalsch = args.ISBN
+
                "Autor= mit Klammer (Hrsg.); dafür Hrsg= verwenden" )
             args.ISBN            = nil
+
    end
        elseif args.ISBNistFormalFalsch ~= "" then
+
end -- Herausgeber()
 +
 
 +
 
 +
 
 +
local Sprache = function ( args )
 +
     --    OBSOLET  nach Bereinigung im Benutzerbereich
 +
     if args.Originalsprache  and
 +
      not args.Originaltitel  and
 +
      not args["Übersetzer"]  and
 +
      not args.Sprache then
 +
        local t = mw.title.getCurrentTitle()
 +
         if t.namespace == 2  or  t.namespace == 3 then
 +
             args.Sprache        = args.Originalsprache
 +
             args.Originalsprache = nil
 
             fehler( "Parameter",
 
             fehler( "Parameter",
                     "Überflüssig: 'ISBNistFormalFalsch' ohne 'ISBN'" )
+
                     "Sprache= nutzen statt Originalsprache="
 +
                                                        .. args.Sprache )
 +
            fehler( "Temp1" )
 
         end
 
         end
        args.ISBNistFormalFalsch = nil
 
        fehler( "ISBNistFormalFalsch" )
 
 
     end
 
     end
end -- FunLit.ISBN()
+
end -- Sprache()
  
  
Zeile 372: Zeile 324:
 
     --    args    -- table mit Vorlagenparametern
 
     --    args    -- table mit Vorlagenparametern
 
     -- Rückgabewert: string mit formatierter Zitation
 
     -- Rückgabewert: string mit formatierter Zitation
     local pars = Zitation.filter( args, ParValid )
+
     local pars = Zitation.filter( args, Export.params.valid )
 
     local r, schrott
 
     local r, schrott
     Titel( pars )   -- OBSOLET
+
     Export.Datum( pars )
     FunLit.Datum( pars )
+
     Herausgeber( pars )
 
     Band( pars )
 
     Band( pars )
 
     Nummer( pars )
 
     Nummer( pars )
     FunLit.ISBN( pars )     -- OBSOLET
+
     Sprache( pars )
     Zitation.filler( pars, ParMap )
+
     Zitation.filler( pars, Export.params.map )
 
     if Zitation.o then
 
     if Zitation.o then
 
         Zitation.fill( "leise",  "leiser",  true )
 
         Zitation.fill( "leise",  "leiser",  true )
Zeile 387: Zeile 339:
 
     r, schrott = Zitation.format()
 
     r, schrott = Zitation.format()
 
     if schrott then
 
     if schrott then
         r = r .. Zitation.fault( schrott )
+
         if Schrei then
 +
            Schrei = string.format( "%s *** %s", Schrei, schrott )
 +
        else
 +
            Schrei = schrott
 +
        end
 
     end
 
     end
 
     return r
 
     return r
Zeile 405: Zeile 361:
 
         Zitation      = r.Zitation()
 
         Zitation      = r.Zitation()
 
         Zitation.frame = frame
 
         Zitation.frame = frame
         r             = format( arglist )
+
        folder()
 +
         r = string.format( "%s%s%s",
 +
                          format( arglist ),
 +
                          fehlerliste(),
 +
                          Zitation.failure( Schrei ) )
 
     else
 
     else
 
         fehler( "Modul", r )
 
         fehler( "Modul", r )
 +
        r = fehlerliste()
 
     end
 
     end
     return r .. fehlerliste()
+
     return r
 
end -- f()
 
end -- f()
  
Zeile 418: Zeile 379:
  
 
function p.export()
 
function p.export()
     return { f        = FunLit,
+
    folder()
            parMap  = ParMap,
+
     return Export
            parValid = ParValid }
 
 
end
 
end
  
Zeile 431: Zeile 391:
 
     local lucky, r = pcall( f, frame:getParent().args, frame )
 
     local lucky, r = pcall( f, frame:getParent().args, frame )
 
     if not lucky then
 
     if not lucky then
 +
        mw.log( r )
 
         fehler( "Intern", r )
 
         fehler( "Intern", r )
 
         r = fehlerliste()
 
         r = fehlerliste()

Aktuelle Version vom 8. Februar 2022, 02:49 Uhr

Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch

Modul: Dokumentation
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
Wikipedia-logo-v2.svg
Dieses Modul (und die Dokumentation) basieren (teilweise) auf Modul:Vorlage:Literatur aus der freien Enzyklopädie Wikipedia und steht unter der GNU Lizenz für freie Dokumentation und der Creative Commons Attribution/Share Alike. Auf Wikipedia ist eine Liste der Autoren verfügbar. Weiteres zum Import aus Wikipedia siehe Seite Imedwiki:Import aus Wikipedia.

local Serial = "2019-06-11"
--[=[
Unterstützung für {{Literatur}}
]=]


-- Global
local Zitation
local Selbst = "Vorlage:Literatur"
local KategorieBeginn  =  "Wikipedia:Vorlagenfehler"
local Kategorien       =
                 { Intern              = { s = "/Interner Fehler" },
                   Parameter           = { s = "/Parameterfehler" },
                   MonatTag            = { s = "/Parameter Monat, Tag" },
                   Temp1               = { s = "/Temp1" },
                   Temp2               = { s = "/Temp2" },
                   Temp3               = { s = "/Temp3" },
                   Temp4               = { s = "/Temp4" },
                 }
local Fehler = false
local Schrei
local Export = { }



local function fehler( art, anzeige )
    -- Ein Fehler ist aufgetreten
    -- Parameter:
    --     art      -- string mit Schlüsselwort zum Typ
    --     anzeige  -- string mit Einzelheiten, oder nil
    local t
    if not Fehler then
        Fehler = { Intern    = { s = "Interner Fehler",
                                 k = "Intern" },
                   Modul     = { s = "Modul-Seite fehlt",
                                 k = "Intern" },
                   Format    = { s = "Parameterformat" },
                   Konflikt  = { s = "Parameterkonflikt",
                                 k = "Parameter" },
                   Parameter = { s = "Parameterfehler",
                                 k = "Parameter" },
                   Wert      = { s = "Werte ungültig",
                                 k = "Parameter" },
                   MonatTag  = { k = "MonatTag" },
                   Temp1     = { k = "Temp1" },
                   Temp2     = { k = "Temp2" },
                   Temp3     = { k = "Temp3" },
                   Temp4     = { k = "Temp4" }
                 }
    end
    t = Fehler[ art ]
    if t then
        if t.s  and  not t.e then
            t.e = ""
        end
        if anzeige then
            local s = mw.text.nowiki( anzeige )
            if t.e then
                t.e = string.format( "%s; %s", t.e, s )
            else
                t.e = s
            end
        end
        if t.k then
            local wk = Kategorien[ t.k ]
            if wk then
                wk.e = true
            else
                Fehler.Intern.e     = "Wartungskat " .. wk
                Kategorien.Intern.e = true
            end
        end
    else
        Fehler.Intern.e     = string.format( "fehler(%s) %s",
                                             art, anzeige or "???" )
        Kategorien.Intern.e = true
    end
end -- fehler()



local function fehlerliste()
    -- Auflistung aller Fehlermeldungen und Kategorien
    -- Rückgabewert: string mit formatiertem Ergebnis
    local r = ""
    local s
    if Fehler then
        local sep = ""
        local suffix
        for k, v in pairs( Fehler ) do
             if v.e then
                if v.e:sub( 1, 1 ) == ";" then
                    suffix = v.s .. v.e
                elseif v.s then
                    suffix = string.format( "%s: %s", v.s, v.e )
                else
                    suffix = v.e
                end
                Schrei = string.format( "%s%s*** %s",
                                        Schrei or "",
                                        sep,
                                        suffix )
                sep    = " "
            end
        end -- for k, v
    end
    for k, v in pairs( Kategorien ) do
        if v.e then
            if v.s:sub( 1, 1 ) == "/" then
                s = Selbst
            else
                s = ""
            end
            r = string.format( "%s[[Kategorie:%s/%s%s]]",
                               r, KategorieBeginn, s, v.s )
        end
    end -- for k, v
    return r
end -- fehlerliste()



local folder = function ()
    -- Parameter-Konfiguration laden
    local s = string.format( "Module:%s/params", Selbst )
    local lucky, params = pcall( mw.loadData, s )
    if type( params ) == "table" then
        Export.params = Export.flat( params )
    else
        error( string.format( "[[%s]] fehlt", s ) )
    end
end -- folder()



-------------------------------------------------------------------------



Export.flat = function ( adapt )
    -- Deep copy
    -- Parameter:
    --     adapt  -- something
    -- Returns atomic value, or deep copy of a table with no metatable
    local r
    if type( adapt ) == "table" then
        r = { }
        for k, v in pairs( adapt ) do
            r[ k ] = Export.flat( v )
        end -- for k, v
    else
        r = adapt
    end
    return r
end -- Export.flat()



Export.Datum = function ( args )
    local r = args.Jahr
    local shit
    if r then
        if r:match( "^%d+$" ) then
            local DateTime = Zitation.fetch( "DateTime" )
            local o = DateTime( r )
            if args.Woche and o then
                o.week = tonumber( args.Woche )
                if tostring( o.week ) ~= args.Woche then
                    fehler( "Wert", "'Woche'=" .. args.Woche )
                    r = false
                end
            elseif args.Monat then
                local s
                if args.Monat:match( "%l" ) then
                    local dm = DateTime( args.Monat )
                    if dm and o and dm.month then
                        o.month = dm.month
                    else
                        shit = "'Monat'=" .. args.Monat
                        if args.Nummer then
                            args.Nummer = string.format( "%s, %s",
                                                         args.Nummer,
                                                         args.Monat )
                        else
                            args.Nummer = args.Monat
                        end
                        if not args.Datum then
                            args.Datum = r
                        end
                        r = false
                    end
                else
                    s = args.Monat:match( "^0?(1?%d)%.?$" )
                    if s and o then
                        o.month = tonumber( s )
                    end
                    if o and tostring( o.month ) ~= s then
                        fehler( "MonatTag",  "'Monat'=" .. args.Monat )
                        r = false
                    elseif s ~= args.Monat  and
                           "0" .. s ~= args.Monat then
                        fehler( "MonatTag",  "'Monat'=" .. args.Monat )
                    end
                end
                if o and o.month  and  args.Tag then
                    s = args.Tag:match( "^0?([123]?%d)%.?$" )
                    if s then
                        o.dom = tonumber( s )
                    end
                    if tostring( o.dom ) ~= s then
                        shit = "'Tag'=" .. args.Tag
                        r = false
                    elseif s ~= args.Tag  and
                           "0" .. s ~= args.Tag  and
                           s .. "." ~= args.Tag then
                        fehler( "MonatTag",  "'Tag'=" .. args.Tag )
                    end
                end
            elseif args.Tag then
                shit = "'Tag' ohne 'Monat'"
                r = false
            end
            if r and o then
                r = o
                args.Datum = o
            end
        elseif r:match( "^%[%d%d%d%d%]$" ) then
            args.Datum = r:match( "^%[(%d+)%]$" )
            if args.Kommentar then
                args.Kommentar = ", " .. args.Kommentar
            else
                args.Kommentar = ""
            end
            args.Kommentar  = string.format( "o. J. %s%s",
                                             args.Jahr, args.Kommentar )
            fehler( "Wert", "'Datum'=o.J." )
        else
            if args.Datum then
                fehler( "Wert",  "'Jahr'=" .. args.Jahr )
            else
                args.Datum = args.Jahr
            end
        end
    elseif args.Monat or args.Woche or args.Tag then
        fehler( "Konflikt", "'Jahr' fehlt bei spezifischem Datum" )
    else
        r = args.Datum
    end
    if shit then
       fehler( "MonatTag", shit )
    end
    return r
end -- Export.Datum()



local Band = function ( args )
    --    OBSOLET   nach Bereinigung in allen NR
    if args.Band  and  not args.Sammelwerk then
        if args.Reihe  and  not args.BandReihe then
            args.BandReihe = args.Band
            args.Band      = nil
            fehler( "Temp4" )
            fehler( "Parameter", "Band= meint BandReihe=" )
        elseif args.Titel  and
               args.Titel:find( " In: " ) then
            fehler( "Parameter", "Band= ohne Sammelwerk=" )
        end
    end
end -- Band()



local Nummer = function ( args )
    --    OBSOLET   nach Bereinigung in allen NR
    if args.Nummer  and  not args.Sammelwerk then
        if args.Reihe  and  not args.NummerReihe then
            args.NummerReihe = args.Nummer
            args.Nummer      = nil
            fehler( "Temp4" )
            fehler( "Parameter", "Nummer= meint NummerReihe=" )
        elseif args.Titel  and
               args.Titel:find( " In: " ) then
            fehler( "Parameter", "Nummer= ohne Sammelwerk=" )
        end
    end
end -- Nummer()



local Herausgeber = function ( args )
    --    OBSOLET   nach Übernahme in Zentralmodul
    if args.Autor  and  args.Autor:find( "(Hrsg.)", 1, true ) then
        fehler( "Wert",
                "Autor= mit Klammer (Hrsg.); dafür Hrsg= verwenden" )
    end
end -- Herausgeber()



local Sprache = function ( args )
    --    OBSOLET   nach Bereinigung im Benutzerbereich
    if args.Originalsprache  and
       not args.Originaltitel  and
       not args["Übersetzer"]  and
       not args.Sprache then
        local t = mw.title.getCurrentTitle()
        if t.namespace == 2  or  t.namespace == 3 then
            args.Sprache         = args.Originalsprache
            args.Originalsprache = nil
            fehler( "Parameter",
                    "Sprache= nutzen statt Originalsprache="
                                                        .. args.Sprache )
            fehler( "Temp1" )
        end
    end
end -- Sprache()



local format = function ( args )
    -- Analysiere Argumente und bilde formatierte Zitation
    -- Parameter:
    --     args    -- table mit Vorlagenparametern
    -- Rückgabewert: string mit formatierter Zitation
    local pars = Zitation.filter( args, Export.params.valid )
    local r, schrott
    Export.Datum( pars )
    Herausgeber( pars )
    Band( pars )
    Nummer( pars )
    Sprache( pars )
    Zitation.filler( pars, Export.params.map )
    if Zitation.o then
        Zitation.fill( "leise",  "leiser",   true )
        Zitation.fill( "leise",  "Vorlage",  pars.Vorlage or Selbst )
        Zitation.o.coins = true
    end
    r, schrott = Zitation.format()
    if schrott then
        if Schrei then
            Schrei = string.format( "%s *** %s", Schrei, schrott )
        else
            Schrei = schrott
        end
    end
    return r
end -- format()



local function f( arglist, frame )
    -- Hauptfunktion zur Steuerung des Gesamtablaufs
    -- Parameter:
    --     arglist  -- table, mit Vorlagenparametern
    --     frame    -- object, oder nil
    -- Rückgabewert: string mit formatiertem Gesamtergebnis
    --                      einschließlich Fehlerliste und Kategorien
    local lucky, r = pcall( require, "Modul:Zitation" )
    if type( r ) == "table" then
        Zitation       = r.Zitation()
        Zitation.frame = frame
        folder()
        r = string.format( "%s%s%s",
                           format( arglist ),
                           fehlerliste(),
                           Zitation.failure( Schrei ) )
    else
        fehler( "Modul", r )
        r = fehlerliste()
    end
    return r
end -- f()



-- Export
local p = {}

function p.export()
    folder()
    return Export
end

function p.test( a )
    local lucky, r = pcall( f, a )
    return r
end

function p.f( frame )
    local lucky, r = pcall( f, frame:getParent().args, frame )
    if not lucky then
        mw.log( r )
        fehler( "Intern", r )
        r = fehlerliste()
    end
    return r
end

function p.failsafe()
    return Serial
end

return p