<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikiyouth.eu/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ATagQS</id>
	<title>Module:TagQS - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikiyouth.eu/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ATagQS"/>
	<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:TagQS&amp;action=history"/>
	<updated>2026-04-15T04:17:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wikiyouth.eu/w/index.php?title=Module:TagQS&amp;diff=35588&amp;oldid=prev</id>
		<title>Admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:TagQS&amp;diff=35588&amp;oldid=prev"/>
		<updated>2025-04-09T08:42:58Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:42, 9 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wiki_wikiyouth:diff:1.41:old-35587:rev-35588 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://wikiyouth.eu/w/index.php?title=Module:TagQS&amp;diff=35587&amp;oldid=prev</id>
		<title>en&gt;Jarekt at 14:05, 15 July 2024</title>
		<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:TagQS&amp;diff=35587&amp;oldid=prev"/>
		<updated>2024-07-15T14:05:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
   _____             .___    .__              ___________              ________    _________&lt;br /&gt;
  /     \   ____   __| _/_ __|  |   ____   /\ \__    ___/____     ____ \_____  \  /   _____/&lt;br /&gt;
 /  \ /  \ /  _ \ / __ |  |  \  | _/ __ \  \/   |    |  \__  \   / ___\ /  / \  \ \_____  \ &lt;br /&gt;
/    Y    (  &amp;lt;_&amp;gt; ) /_/ |  |  /  |_\  ___/  /\   |    |   / __ \_/ /_/  &amp;gt;   \_/.  \/        \&lt;br /&gt;
\____|__  /\____/\____ |____/|____/\___  &amp;gt; \/   |____|  (____  /\___  /\_____\ \_/_______  /&lt;br /&gt;
        \/            \/               \/                    \//_____/        \__&amp;gt;       \/ &lt;br /&gt;
&lt;br /&gt;
                                                                             &lt;br /&gt;
This module is intended for creating invisible tags which can be used to pass &lt;br /&gt;
language independent data from some templates to infoboxes. Those tags are often &lt;br /&gt;
used by templates like [Template:Artwork]  to pass data to Wikidata&lt;br /&gt;
&lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:Jarekt - original version &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
require(&amp;#039;strict&amp;#039;) -- used for debugging purposes as it detects cases of unintended global variables&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === External functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.replaceUnlessQuoted(str, oldChar, newChar)&lt;br /&gt;
	-- String &amp;quot;str&amp;quot; has some sections that are in quotes and some that are not. &lt;br /&gt;
	-- Do replacements only in the text sections which are not in &amp;quot;&amp;quot; quotes.&lt;br /&gt;
	local quote = string.byte(&amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
	local comma = string.byte(oldChar)&lt;br /&gt;
	local quoted = false&lt;br /&gt;
	for pos = 1, #str do&lt;br /&gt;
	   if str:byte(pos) == quote then&lt;br /&gt;
		  quoted = not quoted&lt;br /&gt;
	   end&lt;br /&gt;
	   if str:byte(pos) == comma and not quoted then&lt;br /&gt;
		  str = str:sub(1,pos-1) .. newChar .. str:sub(pos+1, str:len())&lt;br /&gt;
	   end&lt;br /&gt;
	end&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
-- === Version of the function to be called from other LUA codes&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
function p.createTag(field, property, value)&lt;br /&gt;
	-- create tags to insert using &amp;quot;field&amp;quot; &amp;quot;property&amp;quot; and &amp;quot;value&amp;quot; strings.&lt;br /&gt;
	-- &amp;quot;field&amp;quot; is an unique label to distinguish it from other tags. &lt;br /&gt;
	-- &amp;quot;property&amp;quot; and &amp;quot;value&amp;quot; are actually in a format similar to the one expected by QuickStatements&lt;br /&gt;
	return mw.ustring.format(&amp;#039;&amp;lt;div style=&amp;quot;display: none;&amp;quot;&amp;gt;%s QS:%s,%s&amp;lt;/div&amp;gt;&amp;#039;, field, property or &amp;#039;P&amp;#039;, value)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.changeField(text, old, new)&lt;br /&gt;
	-- replace &amp;quot;field&amp;quot; part of the tag. It is needed as sometimes template adding those tags does not &lt;br /&gt;
	-- know the meaning, which is known the the outside template. For example in &lt;br /&gt;
	-- &amp;quot;{{Book|translator={{Creator|wikidata=Q12345}}&amp;quot; the Creator template will create initial &lt;br /&gt;
	-- tag with the wikidata item and {{Book}} template will add label and property for &amp;quot;transaltor&amp;quot;.&lt;br /&gt;
	local patrn = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039;.. old ..&amp;#039; QS:([^%&amp;lt;]+)%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	local repl  =  &amp;#039;&amp;lt;div style=&amp;quot;display: none;&amp;quot;&amp;gt;&amp;#039;.. new ..&amp;#039; QS:%1&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	return mw.ustring.gsub(text, patrn, repl)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.changeProperty(text, field, old, new)&lt;br /&gt;
	-- replace &amp;quot;property&amp;quot; part of the tag. It is needed as sometimes template adding those tags does not &lt;br /&gt;
	-- know the meaning, which is known the the outside template. For example in &lt;br /&gt;
	-- &amp;quot;{{Book|translator={{Creator|wikidata=Q12345}}&amp;quot; the Creator template will create initial &lt;br /&gt;
	-- tag with the wikidata item and {{Book}} template will add label and property for &amp;quot;transaltor&amp;quot;.&lt;br /&gt;
	if not old then -- string &amp;quot;old&amp;quot; is optional if nil than any property will be replaced&lt;br /&gt;
		old = &amp;#039;[^%,]+&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local patrn = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039; .. field .. &amp;#039; QS:&amp;#039; .. old .. &amp;#039;,([^%&amp;lt;]+)%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	local repl  =   &amp;#039;&amp;lt;div style=&amp;quot;display: none;&amp;quot;&amp;gt;&amp;#039; .. field .. &amp;#039; QS:&amp;#039; .. new .. &amp;#039;,%1&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	return mw.ustring.gsub(text, patrn, repl)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.append2value(text, field, text2append)&lt;br /&gt;
	-- append &amp;quot;text&amp;quot; to the &amp;quot;value&amp;quot; part of the tag&lt;br /&gt;
	local patrn = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039;.. field ..&amp;#039; QS:([^%&amp;lt;]+)%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	local repl  =  &amp;#039;&amp;lt;div style=&amp;quot;display: none;&amp;quot;&amp;gt;&amp;#039; .. field ..&amp;#039; QS:%1,&amp;#039; .. text2append .. &amp;#039;&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	return mw.ustring.gsub(text, patrn, repl)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.readTag(text, field)&lt;br /&gt;
	-- read a single tag&lt;br /&gt;
	local pat = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039;..field..&amp;#039; QS:([^%&amp;lt;]+)%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	local qs  = string.match(text, pat) -- find hidden tag with QS code&lt;br /&gt;
	local _, nMatch = string.gsub(text, pat, &amp;quot;&amp;quot;) -- count matches&lt;br /&gt;
	if qs and nMatch==1 then -- allow only single matches&lt;br /&gt;
		return p.replaceUnlessQuoted(qs, &amp;#039;,&amp;#039;, &amp;#039;|&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.readTags(text, field)&lt;br /&gt;
	-- read multiple tags and return array of them&lt;br /&gt;
	local pat = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039;..field..&amp;#039; QS:([^%&amp;lt;]+)%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for qs in mw.ustring.gmatch(text, pat) do&lt;br /&gt;
		table.insert(ret, p.replaceUnlessQuoted(qs, &amp;#039;,&amp;#039;, &amp;#039;|&amp;#039;) )&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.hasTag(text, field)&lt;br /&gt;
	-- does the &amp;quot;text&amp;quot; has a tag with field &amp;quot;field&amp;quot;, or if field=nil does it have any tags?&lt;br /&gt;
	return text~= p.removeTag(text, field)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.removeTag(text, field)&lt;br /&gt;
	-- remove tags with field &amp;quot;field&amp;quot; from the string. Field =nil will replace all tags&lt;br /&gt;
	if not field then&lt;br /&gt;
		field = &amp;#039;[^ ]+&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local patrn = &amp;#039;%&amp;lt;div style=&amp;quot;display: none;&amp;quot;%&amp;gt;&amp;#039; .. field .. &amp;#039; QS:[^%&amp;lt;]+%&amp;lt;/div%&amp;gt;&amp;#039;&lt;br /&gt;
	return mw.ustring.gsub(text, patrn, &amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
-- === Versions of the function to be called from template namespace&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
function p.CreateTag(frame)&lt;br /&gt;
	return p.createTag(frame.args[1], frame.args[2], frame.args[3])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;Jarekt</name></author>
	</entry>
</feed>