Module:TagQS: Difference between revisions
From Neodyland Wiki
More actions
Fix Linter errors. When this template is preceded by indenting markup and wrapped in div tags, misnesting occurs |
add appendValue function |
||
| Line 56: | Line 56: | ||
-- tag with the wikidata item and {{Book}} template will add label and property for "transaltor". | -- tag with the wikidata item and {{Book}} template will add label and property for "transaltor". | ||
local patrn = '%<div style="display: none;"%>'.. old ..' QS:([^%<]+)%</div%>' | local patrn = '%<div style="display: none;"%>'.. old ..' QS:([^%<]+)%</div%>' | ||
local repl = '<div style="display: none;">'.. new ..' QS:%1</div>' | local repl = '<div style="display: none;">'.. new ..' QS:%1</div>' | ||
return mw.ustring.gsub(text, patrn, repl) | return mw.ustring.gsub(text, patrn, repl) | ||
end | end | ||
| Line 70: | Line 70: | ||
local patrn = '%<div style="display: none;"%>' .. field .. ' QS:' .. old .. ',([^%<]+)%</div%>' | local patrn = '%<div style="display: none;"%>' .. field .. ' QS:' .. old .. ',([^%<]+)%</div%>' | ||
local repl = '<div style="display: none;">' .. field .. ' QS:' .. new .. ',%1</div>' | local repl = '<div style="display: none;">' .. field .. ' QS:' .. new .. ',%1</div>' | ||
return mw.ustring.gsub(text, patrn, repl) | |||
end | |||
function p.appendValue(text, field, text) | |||
-- append "text" to the "value" part of the tag | |||
local patrn = '%<div style="display: none;"%>'.. field ..' QS:([^%<]+)%</div%>' | |||
local repl = '<div style="display: none;">' .. field ..' QS:%1,' .. text .. '</div>' | |||
return mw.ustring.gsub(text, patrn, repl) | return mw.ustring.gsub(text, patrn, repl) | ||
end | end | ||