Modul:Vorlage:Auflistung: Unterschied zwischen den Versionen
2021-02-05
(2020-11-03) |
(2021-02-05) |
||
| Zeile 1: | Zeile 1: | ||
local HorizontalList = { suite = "HorizontalList", | local HorizontalList = { suite = "HorizontalList", | ||
serial = " | serial = "2021-02-05", | ||
item = 100938243 } | item = 100938243 } | ||
--[=[ | --[=[ | ||
| Zeile 9: | Zeile 9: | ||
local CSS = { classesBlock = { }, | local CSS = { classesBlock = { }, | ||
classesNowrap = { }, | |||
classesPrefix = { }, | classesPrefix = { }, | ||
classesSep = { } } | classesSep = { } } | ||
local Failsafe = HorizontalList | local Failsafe = HorizontalList | ||
local fix = function ( at ) | |||
for k, v in pairs( CSS.classesNowrap ) do | |||
at:addClass( v ) | |||
end -- for k, v | |||
end -- fix() | |||
| Zeile 19: | Zeile 28: | ||
-- Generate horizontal list from wikitext | -- Generate horizontal list from wikitext | ||
-- Parameter: | -- Parameter: | ||
-- all | -- all -- string, with wikitext | ||
-- | -- each line starting with one of * or # | ||
-- ahead | -- ahead -- string, to prefix if desired | ||
-- altogether | -- altogether -- true, if nowrap around each regular item | ||
-- access | -- access -- string, with fragment, if desired | ||
-- alien | -- alien -- string, with language code, if desired | ||
-- apart | -- apart -- string, with separator, if desired | ||
-- frame | -- frame -- object, if available | ||
-- Returns string | -- Returns string | ||
local r | local r | ||
| Zeile 81: | Zeile 90: | ||
-- Generate horizontal list from item sequence | -- Generate horizontal list from item sequence | ||
-- Parameter: | -- Parameter: | ||
-- all | -- all -- table, with sequence of items | ||
-- | -- each item is a string or a mw.html object | ||
-- ahead | -- ahead -- string, to prefix if desired | ||
-- advance | -- advance -- true, if ordered list requested | ||
-- altogether | -- altogether -- true, if nowrap around each item | ||
-- access | -- access -- string, with fragment, if desired | ||
-- alien | -- alien -- string, with language code, if desired | ||
-- apart | -- apart -- string, with separator, if desired | ||
-- frame | -- frame -- object, if available | ||
-- Returns string | -- Returns string | ||
local r | local r | ||
| Zeile 148: | Zeile 157: | ||
else | else | ||
e:wikitext( tostring( s ) ) | e:wikitext( tostring( s ) ) | ||
end | |||
if CSS.styleItem then | |||
e:cssText( CSS.styleItem ) | |||
end | end | ||
if es and i < #all then | if es and i < #all then | ||
| Zeile 153: | Zeile 165: | ||
end | end | ||
if altogether then | if altogether then | ||
e | fix( e ) | ||
end | end | ||
ou:newline() | ou:newline() | ||
| Zeile 172: | Zeile 184: | ||
r = all[ 1 ] | r = all[ 1 ] | ||
if altogether then | if altogether then | ||
if type( r ) | if type( r ) ~= "table" then | ||
r = mw.html.create( "span" ) | r = mw.html.create( "span" ) | ||
:wikitext( tostring( r ) ) | :wikitext( tostring( r ) ) | ||
end | end | ||
fix( r ) | |||
end | end | ||
r = tostring( r ) | r = tostring( r ) | ||
| Zeile 192: | Zeile 203: | ||
-- Parameter: | -- Parameter: | ||
-- arglist -- table, with optional components | -- arglist -- table, with optional components | ||
-- styleItem -- style per item | |||
-- -- string | |||
-- styles -- templatestyles page | -- styles -- templatestyles page | ||
-- -- string, with name | -- -- string, with name | ||
| Zeile 198: | Zeile 211: | ||
-- -- string, with class(es) | -- -- string, with class(es) | ||
-- -- table, with particular mapping | -- -- table, with particular mapping | ||
-- classesPrefix | -- classesNowrap -- class(es) for nowrap element | ||
-- -- string, with class(es) | |||
-- -- table, with particular mapping | |||
-- classesPrefix -- class(es) for prefix element | |||
-- -- string, with class(es) | -- -- string, with class(es) | ||
-- -- table, with particular mapping | -- -- table, with particular mapping | ||
| Zeile 254: | Zeile 270: | ||
elseif s == "table" then | elseif s == "table" then | ||
CSS.css = val | CSS.css = val | ||
end | |||
val = arglist.styleItem | |||
if type( val ) == "string" then | |||
s = mw.text.trim( val ) | |||
if s ~= "" then | |||
CSS.styleItem = s | |||
end | |||
end | end | ||
end | end | ||
| Zeile 325: | Zeile 348: | ||
HorizontalList.first( { styles = frame.args.styles, | HorizontalList.first( { styles = frame.args.styles, | ||
classesBlock = frame.args.classesBlock, | classesBlock = frame.args.classesBlock, | ||
classesNowrap = frame.args.classesNowrap, | |||
classesPrefix = frame.args.classesPrefix, | classesPrefix = frame.args.classesPrefix, | ||
classesSep = frame.args.classesSep, | classesSep = frame.args.classesSep, | ||
style = frame.args.style } ) | style = frame.args.style, | ||
styleItem = frame.args.styleItem } ) | |||
return HorizontalList.f( frame.args[ 1 ], | return HorizontalList.f( frame.args[ 1 ], | ||
frame.args.prefix, | frame.args.prefix, | ||