模块:Db:修订间差异
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
||
| 第222行: | 第222行: | ||
end | end | ||
-- | -- 恢复分隔符为 ' / ' | ||
return table.concat(resultTable, ' / ') | return table.concat(resultTable, ' / ') | ||
end | end | ||
| 第311行: | 第311行: | ||
-- 表格样式: 宽度 90%, 居中, 内容居中 | -- 表格样式: 宽度 90%, 居中, 内容居中 | ||
table.insert(output, '{| class="wikitable sortable" style="width: 90%; margin: 0 auto; text-align: center;"') | table.insert(output, '{| class="wikitable sortable" style="width: 90%; margin: 0 auto; text-align: center;"') | ||
-- 构造表格头部 (不包含 ID) | -- 构造表格头部 (不包含 ID) | ||
table.insert(output, '|-') | |||
for _, field in ipairs(displayFields) do | for _, field in ipairs(displayFields) do | ||
field = mw.text.trim(field) | field = mw.text.trim(field) | ||
| 第319行: | 第319行: | ||
end | end | ||
-- 构造表格行 | -- 构造表格行 (使用最稳健的多行结构) | ||
for _, songId in ipairs(matchingKeys) do | for _, songId in ipairs(matchingKeys) do | ||
local songEntry = songData[songId] | local songEntry = songData[songId] | ||
table.insert(output, ' | table.insert(output, '|-') -- 新行开始 | ||
-- 数据字段 | -- 数据字段 | ||
for | for _, field in ipairs(displayFields) do | ||
field = mw.text.trim(field) | field = mw.text.trim(field) | ||
local rawValue = ValueFromValuesByKey(songEntry, field) | local rawValue = ValueFromValuesByKey(songEntry, field) | ||
| 第343行: | 第341行: | ||
end | end | ||
-- | -- FIX: 确保每个单元格都在自己的行上,这是最可靠的 wikitext 结构 | ||
table.insert(output, '|' .. formattedValue) | |||
end | end | ||
end | end | ||
table.insert(output, ' | table.insert(output, '|}') | ||
return table.concat(output, '') | -- FIX: 使用 \n 连接所有行,确保 MediaWiki 解析器能识别所有表格元素 | ||
return table.concat(output, '\n') | |||
end | end | ||
return p | return p | ||