Module:Dialogue indented
Appearance
![]() | This module depends on the following other modules: |
Implements {{dialogue indented}}.
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local TableTools = require('Module:TableTools')
local function _dialogue_indented(args)
local dialogue_lines = {}
for k, v in pairs(args) do
if type(k) == 'number' and k % 2 == 1 then
dialogue_lines[k] = {args[k], args[k + 1]}
elseif type(k) == 'number' then
dialogue_lines[k - 1] = {args[k - 1], args[k]}
end
end
dialogue_lines = TableTools.compressSparseArray(dialogue_lines)
local dialogue_table = mw.html.create('table'):addClass('wst-dialogue-indented')
for i, line in ipairs(dialogue_lines) do
dialogue_table:tag('tr')
:tag('td'):wikitext(line[1]):done()
:tag('td'):wikitext(line[2])
end
return dialogue_table
end
function p.dialogue_indented(frame)
return _dialogue_indented(getArgs(frame))
end
return p