9,921
editsno edit summary
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
local useTemplateOnElements | local useTemplateOnElements | ||
local useTwoArgTemplateOnElements | local useTwoArgTemplateOnElements | ||
local | local textDelim | ||
local textLastDelim | |||
local function splitListString(listString) | local function splitListString(listString) | ||
local strings = {} | |||
for str in listString:gmatch("[^" .. listDelimiters .. "]+") do | |||
table.insert(strings, str:match("^%s*(.-)%s*$")) | |||
end | |||
return strings | |||
end | end | ||
Line 166: | Line 167: | ||
end | end | ||
-- These functions implement | -- These functions implement different output styles. The elements will have | ||
-- already gone through processElement() at this point, so they only need to be | -- already gone through processElement() at this point, so they only need to be | ||
-- glued together to produce the desired | -- glued together to produce the desired style of listing format. | ||
local converters = { | local converters = { | ||
text = function (elements) | |||
local result = "" | |||
local count = #elements | |||
for i, str in ipairs(elements) do | for i, str in ipairs(elements) do | ||
if i < count then | if i == 1 then | ||
result = result .. | result = str | ||
elseif i < count then | |||
result = result .. textDelim .. str | |||
else | else | ||
result = result .. | result = result .. textLastDelim .. str | ||
end | end | ||
end | |||
return result | |||
end, | end, | ||
htmlList = function (elements) | htmlList = function (elements) | ||
Line 233: | Line 229: | ||
useTemplateOnElements = args['useTemplate'] | useTemplateOnElements = args['useTemplate'] | ||
useTwoArgTemplateOnElements = args['useTemplate2'] | useTwoArgTemplateOnElements = args['useTemplate2'] | ||
textDelim = args['textDelim'] | |||
if textDelim then | |||
textLastDelim = args['textLastDelim'] or textDelim | |||
else | |||
textDelim = ', ' | |||
textLastDelim = args['textLastDelim'] or ' and ' | |||
end | |||
local | local style = args['style'] or args['type'] or 'text' | ||
local converter = converters[ | local converter = converters[style] | ||
local elements = {} | local elements = {} | ||
local listString = args[1] | local listString = args[1] |