Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Hodge diamond
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module implements {{hodge diamond}} local p = {} function p.diagram(frame) local args = (frame.args[3] ~= nil) and frame.args or frame:getParent().args local style = args['style'] or '' local width = args['width'] or '2.5em' local cstyle = args['cstyle'] or '' local caption = args['caption'] local note = args['note'] local entries = {} local argcount = 0 for k, v in pairs( args ) do if type( k ) == 'number' then entries[ k ] = mw.text.trim(v) argcount = argcount + 1 end end local side = math.floor(math.sqrt(argcount)) local rows = 2*side - 1 local root = mw.html.create('table') root :css('text-align', 'center') :cssText(style) if caption then root:tag('caption'):wikitext(caption) end local c = 1 for i = 1,side do row = root:tag('tr') for j = 1,(side-i) do row:tag('td') end for k = 1,i do local cell = row:tag('td') cell :css('width', width) :cssText(cstyle) :wikitext(entries[c]) if k < i then row:tag('td') else if i == side and note then row:tag('td'):wikitext(note) end end c = c + 1 end for j = 1,(side-i) do row:tag('td') end end for i = 1,(side-1) do row = root:tag('tr') for j = 1,i do row:tag('td') end for k = 1,(side-i) do cell = row:tag('td') cell :css('width', width) :cssText(cstyle) :wikitext(entries[c]) if k < (side-i) then row:tag('td') end c = c + 1 end for j = 1,i do row:tag('td') end end return tostring(root) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Tl
(
edit
)
Module:Hodge diamond/doc
(
edit
)