Module:SemanticAnnotations: Difference between revisions

// via Wikitext Extension for VSCode
Tag: Reverted
// via Wikitext Extension for VSCode
Tag: Manual revert
Line 229: Line 229:
          
          
         if type(mapping) == "string" then
         if type(mapping) == "string" then
             -- Simple string mapping: treat mapping as parameter name or literal value
             -- Simple string mapping
            local rawValue = args[mapping]
            local val = (rawValue and rawValue ~= "") and rawValue or mapping
             propertyCount = propertyCount + addSimplePropertyToResult(result,  
             propertyCount = propertyCount + addSimplePropertyToResult(result,  
                 fullPropertyName, val, transform[property], default[property])
                 fullPropertyName, args[mapping], transform[property], default[property])
         elseif type(mapping) == "table" then
         elseif type(mapping) == "table" then
             if mapping.param then
             if mapping.param then
Line 298: Line 296:
]]
]]
function p.setSemanticProperties(args, mappings, options)
function p.setSemanticProperties(args, mappings, options)
     -- DEBUG: render semantic property values visibly for troubleshooting
     -- Fall back to parser functions if mw.smw unavailable
     do
     if not mw.smw then return p.generateEnhancedAnnotations(args, mappings, options) end
        local lines = {'<pre>DEBUG SEMANTIC PROPERTIES:'}
        for prop, val in pairs(mappings) do
            if type(val) == 'table' then
                for _, v in ipairs(val) do
                    table.insert(lines, prop .. ' = ' .. tostring(v))
                end
            else
                table.insert(lines, prop .. ' = ' .. tostring(val))
            end
        end
        table.insert(lines, '</pre>')
        return table.concat(lines, '\n')
    end
      
      
     options = options or {}
     options = options or {}