You can edit almost every page by Creating an account and confirming your email.

Module:ShowMath: Difference between revisions

From EverybodyWiki Bios & Wiki
WikiMaster (talk | contribs)
m 1 revision imported
 
WikiMasterBot2 (talk | contribs)
m Add new revision
 
Line 5: Line 5:
local propertyID = mw.text.trim(frame.args[1] or "")
local propertyID = mw.text.trim(frame.args[1] or "")
local entity = mw.wikibase.getEntityObject()
local entity = mw.wikibase.getEntityObject()
local claims
if entity and entity.claims then claims = entity.claims[propertyID] end
if claims then
return frame:preprocess( entity:formatStatements(propertyID).value )
else
return ""
end
end
p.named = function(frame)
local propertyID = "P2534"
local entityID = mw.wikibase.getEntityIdForTitle(frame.args[1] or "")
local entity = mw.wikibase.getEntityObject(entityID)
local claims
local claims
if entity and entity.claims then claims = entity.claims[propertyID] end
if entity and entity.claims then claims = entity.claims[propertyID] end

Latest revision as of 14:27, 14 March 2019

Usage

{{#invoke:ShowMath|render|propertyID}} renders math from a wikidata entry

Testing

Copy and paste the following into any article and preview it (please don't save!):

* - {{#invoke:ShowMath|render|P2534|}}

In Pythagorean theorem you should get:

  • - c2=a2+b2



-- vim: set noexpandtab ft=lua ts=4 sw=4:
local p = {}

p.render= function(frame)
	local propertyID = mw.text.trim(frame.args[1] or "")
	local entity = mw.wikibase.getEntityObject()
	local claims
	if entity and entity.claims then claims = entity.claims[propertyID] end
	if claims then
		return frame:preprocess( entity:formatStatements(propertyID).value )
	else
		return ""
	end
end

p.named = function(frame)
	local propertyID = "P2534"
	local entityID = mw.wikibase.getEntityIdForTitle(frame.args[1] or "")
	local entity = mw.wikibase.getEntityObject(entityID)
	local claims
	if entity and entity.claims then claims = entity.claims[propertyID] end
	if claims then
		return frame:preprocess( entity:formatStatements(propertyID).value )
	else
		return ""
	end
end

return p

This module "ShowMath" is from Wikipedia if otherwise notified