无编辑摘要
无编辑摘要
第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)
    -- valueString 预期是经过 formatSingleValue 处理的字符串 (例如 '15', ' - ', 或 '无')
      
      
     -- 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'/'SC' 前缀进行转换
         -- 剥离 '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
        -- 返回带样式的纯数字字符串 (例如 <span...>15</span>)
         return '<span style="' .. style .. '">' .. displayString .. '</span>'
         return '<span style="' .. style .. '">' .. displayString .. '</span>'
     end
     end
      
      
     return displayString -- 返回原始数字字符串(例如 8)
     return displayString  
end
end


第151行: 第148行:
     local isSC = string.match(fieldType, '_sc$')
     local isSC = string.match(fieldType, '_sc$')
      
      
    -- 仅当是 SC 字段,且值存在且不为 '-' 或 '无' 时,添加 "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)
          
          
        -- 步骤 1: 基础格式化
         local formattedValue = formatSingleValue(value, argType)  
         local formattedValue = formatSingleValue(value, argType)  
       
        -- 步骤 2: 应用 SC 前缀
         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)
              
              
            -- 步骤 1: 基础格式化
             local formattedValue = formatSingleValue(rawValue, field)
             local formattedValue = formatSingleValue(rawValue, field)
           
            -- 步骤 2: **仅在表格中**应用特殊样式
              
              
             if field == 'bpm' then
             if field == 'bpm' then
第307行: 第296行:
             local _, mode = getDifficultyDetails(field)
             local _, mode = getDifficultyDetails(field)
             if mode then
             if mode then
                -- 核心:formatDifficultyStyles 现在能正确处理 '-' 值
                 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, '|' .. formattedValue)
             table.insert(output, '|' .. cellContent)
         end
         end
     end
     end