模块:Db:修订间差异
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
MJ Hamster(留言 | 贡献) 小无编辑摘要 |
||
| 第53行: | 第53行: | ||
return p.valueMappingMethod[fieldType](value) | return p.valueMappingMethod[fieldType](value) | ||
else | else | ||
return tostring(value) | return tostring(value) | ||
end | end | ||
| 第86行: | 第85行: | ||
-- **核心:难度样式应用 (仅用于表格,并处理可能存在的 'sc' 前缀)** | -- **核心:难度样式应用 (仅用于表格,并处理可能存在的 'sc' 前缀)** | ||
local function formatDifficultyStyles(valueString, mode) | local function formatDifficultyStyles(valueString, mode) | ||
-- 1. 特殊值检查:如果是 '-' 或 '无',直接返回 | -- 1. 特殊值检查:如果是 '-' 或 '无',直接返回 | ||
| 第93行: | 第91行: | ||
end | end | ||
local displayString = valueString | local displayString = valueString | ||
local numValue = tonumber(valueString) | local numValue = tonumber(valueString) | ||
if mode == 'sc' and numValue == nil then | if mode == 'sc' and numValue == nil then | ||
-- | -- 剥离 'sc'/'SC' 前缀进行转换 | ||
local stripped = valueString:match("^[Ss][Cc](%d+)$") | local stripped = valueString:match("^[Ss][Cc](%d+)$") | ||
if stripped then | if stripped then | ||
numValue = tonumber(stripped) | numValue = tonumber(stripped) | ||
displayString = stripped | displayString = stripped | ||
end | end | ||
end | end | ||
| 第140行: | 第138行: | ||
if style ~= '' then | if style ~= '' then | ||
return '<span style="' .. style .. '">' .. displayString .. '</span>' | return '<span style="' .. style .. '">' .. displayString .. '</span>' | ||
end | end | ||
return displayString | return displayString | ||
end | end | ||
| 第151行: | 第148行: | ||
local isSC = string.match(fieldType, '_sc$') | local isSC = string.match(fieldType, '_sc$') | ||
if isSC and valueString ~= i18n['none'] and valueString ~= '-' then | if isSC and valueString ~= i18n['none'] and valueString ~= '-' then | ||
if not valueString:lower():find('sc') then | if not valueString:lower():find('sc') then | ||
| 第214行: | 第210行: | ||
local value = ValueFromValuesByKey(songEntry, argType) | local value = ValueFromValuesByKey(songEntry, argType) | ||
local formattedValue = formatSingleValue(value, argType) | local formattedValue = formatSingleValue(value, argType) | ||
formattedValue = applySCPrefix(formattedValue, argType) | formattedValue = applySCPrefix(formattedValue, argType) | ||
table.insert(resultTable, formattedValue) | table.insert(resultTable, formattedValue) | ||
end | end | ||
| 第296行: | 第288行: | ||
local rawValue = ValueFromValuesByKey(songEntry, field) | local rawValue = ValueFromValuesByKey(songEntry, field) | ||
local formattedValue = formatSingleValue(rawValue, field) | local formattedValue = formatSingleValue(rawValue, field) | ||
if field == 'bpm' then | if field == 'bpm' then | ||
| 第307行: | 第296行: | ||
local _, mode = getDifficultyDetails(field) | local _, mode = getDifficultyDetails(field) | ||
if mode then | if mode then | ||
formattedValue = formatDifficultyStyles(formattedValue, mode) | formattedValue = formatDifficultyStyles(formattedValue, mode) | ||
end | end | ||
local cellContent = formattedValue | |||
-- **CRITICAL FIX:** 如果内容是单个 '-', 增加空格以避免被解析为行分隔符 '|-'. | |||
if cellContent == '-' then | |||
cellContent = ' -' -- 输出: | - | |||
end | |||
-- MediaWiki 表格单元格开始符 ' | ' | -- MediaWiki 表格单元格开始符 ' | ' | ||
table.insert(output, '|' .. | table.insert(output, '|' .. cellContent) | ||
end | end | ||
end | end | ||