Module:Lorebook/Debug: Difference between revisions
Add debug output to list all keys in row table to identify correct property key names |
Escape curly braces ({/}) in debug output to prevent template invocation |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 84: | Line 84: | ||
local function getAllConcepts(world) | local function getAllConcepts(world) | ||
local query = | local query = { | ||
'[[Category:Concept]][[Belongs to world::' .. world .. ']]', | |||
'?Plist=plist', | |||
'?AliChat=alichat', | |||
'?Primary keys=primary', | |||
'?Secondary keys=secondary', | |||
'?Logic=logic', | |||
'?Key mode=mode', | |||
'?Parent concept=parent', | |||
'?Non-recursable=nonrec', | |||
'?Placement=placement', | |||
limit = 999 | limit = 999 | ||
}) | } | ||
local res = mw.smw.ask(query) | |||
if not res then return {} end | if not res then return {} end | ||
| Line 119: | Line 121: | ||
normalized[i] = { | normalized[i] = { | ||
page = normalizeValue(row[1]), -- First element is the page title | page = normalizeValue(row[1]), -- First element is the page title | ||
plist = normalizeValue(row.plist), | plist = normalizeValue(row.plist), | ||
alichat = normalizeValue(row.alichat), | alichat = normalizeValue(row.alichat), | ||
| Line 202: | Line 204: | ||
end | end | ||
if #chatChunks > 0 then | if #chatChunks > 0 then | ||
if #plistChunks > 0 then | |||
text = text .. '\n' -- Add extra newline between plist and chat sections | |||
end | |||
text = text .. table.concat(chatChunks, '\n') | text = text .. table.concat(chatChunks, '\n') | ||
end | end | ||
| Line 286: | Line 291: | ||
end | end | ||
output = output .. result | -- Escape curly braces and use <pre> tag to preserve formatting | ||
if result and result ~= '' then | |||
result = result:gsub('{', '{'):gsub('}', '}') | |||
output = output .. "\n</pre>\n" | output = output .. result .. '\n</pre>\n' | ||
else | |||
output = output .. "(empty output)\n</pre>\n" | |||
end | end | ||