Module:ConceptMapRenderer

From No Subject
Jump to navigation Jump to search

Documentation for this module may be created at Module:ConceptMapRenderer/doc

local p={}
local getArgs=require('Module:Arguments').getArgs

function p.main(frame)
 local args=getArgs(frame)
 local src=mw.title.getCurrentTitle().text
 local out={"<mermaid>","graph TD"}

 for i=1,50 do
  local t=args["relation_"..i.."_target"]
  if not t then break end
  local typ=args["relation_"..i.."_type"] or "related"
  local dir=args["relation_"..i.."_direction"]

  if dir=="bidirectional" then
    table.insert(out," "..src.."--> "..t)
    table.insert(out," "..t.."--> "..src)
  else
    table.insert(out," "..src.."--> "..t)
  end
 end

 table.insert(out,"</mermaid>")
 return table.concat(out,"\n")
end

return p