Module:Stew

-- Module to format and add links to Stewart notation local p = {}

-- Used to call from #invoke function p.Stew(frame) local pframe = frame:getparent local args = pframe.args return p._Stew(args) end

p.links = { ["A5"] = "A5" , ["B4"] = "cuboctahedron" , ["B5"] = "icosidodecahedron" , ["C5"] = "truncated icosahedron" , ["D5"] = "dodecahedron" , ["E4"] = "rhombicuboctahedron" , ["E5"] = "rhombicosidodecahedron" , ["G3"] = "G3" , ["I5"] = "icosahedron" , ["J1"] = "square pyramid" , ["J2"] = "pentagonal pyramid" , ["J3"] = "triangular cupola" , ["J4"] = "square cupola" , ["J5"] = "pentagonal cupola" , ["J6"] = "pentagonal rotunda" , ["J7"] = "elongated triangular pyramid" , ["J8"] = "elongated square pyramid" , ["J9"] = "elongated pentagonal pyramid" , ["J10"] = "gyroelongated square pyramid" , ["J11"] = "gyroelongated pentagonal pyramid" , ["J12"] = "triangular bipyramid" , ["J13"] = "pentagonal bipyramid" , ["J14"] = "elongated triangular bipyramid" , ["J15"] = "elongated square bipyramid" , ["J16"] = "elongated pentagonal bipyramid" , ["J17"] = "gyroelongated square bipyramid" , ["J18"] = "elongated triangular cupola" , ["J19"] = "elongated square cupola" , ["J20"] = "elongated pentagonal cupola" , ["J21"] = "elongated pentagonal rotunda" , ["J22"] = "gyroelongated triangular cupola" , ["J23"] = "gyroelongated square cupola" , ["J24"] = "gyroelongated pentagonal cupola" , ["J25"] = "gyroelongated pentagonal rotunda" , ["J26"] = "gyrobifastigum" , ["J27"] = "triangular orthobicupola" , ["J28"] = "square orthobicupola" , ["J29"] = "square gyrobicupola" , ["J30"] = "pentagonal orthobicupola" , ["J31"] = "pentagonal gyrobicupola" , ["J32"] = "pentagonal orthocupolarotunda" , ["J33"] = "pentagonal gyrocupolarotunda" , ["J34"] = "pentagonal orthobirotunda" , ["J35"] = "elongated triangular orthobicupola" , ["J36"] = "elongated triangular gyrobicupola" , ["J37"] = "elongated square gyrobicupola" , ["J38"] = "elongated pentagonal orthobicupola" , ["J39"] = "elongated pentagonal gyrobicupola" , ["J40"] = "elongated pentagonal orthocupolarotunda" , ["J41"] = "elongated pentagonal gyrocupolarotunda" , ["J42"] = "elongated pentagonal orthobirotunda" , ["J43"] = "elongated pentagonal gyrobirotunda" , ["J44"] = "gyroelongated triangular bicupola" , ["J45"] = "gyroelongated square bicupola" , ["J46"] = "gyroelongated pentagonal bicupola" , ["J47"] = "gyroelongated pentagonal cupolarotunda" , ["J48"] = "gyroelongated pentagonal birotunda" , ["J49"] = "augmented triangular prism" , ["J50"] = "biaugmented triangular prism" , ["J51"] = "triaugmented triangular prism" , ["J52"] = "augmented pentagonal prism" , ["J53"] = "biaugmented pentagonal prism" , ["J54"] = "augmented hexagonal prism" , ["J55"] = "parabiaugmented hexagonal prism" , ["J56"] = "metabiaugmented hexagonal prism" , ["J57"] = "triaugmented hexagonal prism" , ["J58"] = "augmented dodecahedron" , ["J59"] = "parabiaugmented dodecahedron" , ["J60"] = "metabiaugmented dodecahedron" , ["J61"] = "triaugmented dodecahedron" , ["J62"] = "metabidiminished icosahedron" , ["J63"] = "tridiminished icosahedron" , ["J64"] = "augmented tridiminished icosahedron" , ["J65"] = "augmented truncated tetrahedron" , ["J66"] = "augmented truncated cube" , ["J67"] = "biaugmented truncated cube" , ["J68"] = "augmented truncated dodecahedron" , ["J69"] = "parabiaugmented truncated dodecahedron" , ["J70"] = "metabiaugmented truncated dodecahedron" , ["J71"] = "triaugmented truncated dodecahedron" , ["J72"] = "gyrate rhombicosidodecahedron" , ["J73"] = "parabigyrate rhombicosidodecahedron" , ["J74"] = "metabigyrate rhombicosidodecahedron" , ["J75"] = "trigyrate rhombicosidodecahedron" , ["J76"] = "diminished rhombicosidodecahedron" , ["J77"] = "paragyrate diminished rhombicosidodecahedron" , ["J78"] = "metagyrate diminished rhombicosidodecahedron" , ["J79"] = "bigyrate diminished rhombicosidodecahedron" , ["J80"] = "parabidiminished rhombicosidodecahedron" , ["J81"] = "metabidiminished rhombicosidodecahedron" , ["J82"] = "gyrate bidiminished rhombicosidodecahedron" , ["J83"] = "tridiminished rhombicosidodecahedron" , ["J84"] = "snub disphenoid" , ["J85"] = "snub square antiprism" , ["J86"] = "spenocorona" , ["J87"] = "augmented sphenocorona" , ["J88"] = "sphenomegacorona" , ["J89"] = "hebesphenomegacorona" , ["J90"] = "disphenocingulum" , ["J91"] = "bilunabirodunda" , ["J92"] = "triangular hebesphenorotunda" , ["K3"] = "truncated octahedron" , ["K4"] = "truncated cuboctahedron" , ["K5"] = "truncated icosidodecahedron" , ["M"] = "tortuous tunnel" , ["m"] = "m" , ["m*"] = "m*" , ["P3"] = "triangular prism" , ["P4"] = "cube" , ["P5"] = "pentagonal prism" , ["P6"] = "hexagonal prism" , ["P7"] = "heptagonal prism" , ["P*"] = "P*" , ["Q3"] = "triangular cupola" , ["Q4"] = "square cupola" , ["Q5"] = "pentagonal cupola" , ["R5"] = "pentagonal rotunda" , ["S3"] = "octahedron" , ["S4"] = "square antiprism" , ["S5"] = "pentagonal antiprism" , ["sB4"] = "snub cuboctahedron" , ["sB5"] = "snub icosidodecahedron" , ["T3"] = "truncated tetrahedron" , ["T4"] = "truncated cube" , ["T5"] = "truncated dodecahedron" , ["W'"] = "W'" , ["Y3"] = "tetrahedron" , ["Y4"] = "square pyramid" , ["Y5"] = "pentagonal pyramid" , ["Z4"] = "Z4" }

p.symbols = { ["/"] = 0, ["g"] = 0 , ["("] = 0, [")"] = 0  }

function p.markup(s) match = string.gmatch(s, "[^0-9]+%d+$") if (match ~= nil) then local alpha = string.gmatch(s, "[^0-9]+") return alpha .. "" .. string.sub(s, string.len(alpha)+1) .. "" end return s end

-- Used to call from other Lua modules function p._Stew(args) local result = "" for key, value in pairs(args) do   if (p.symbols[value] ~= nil) then result = result .. value else local knownLink = p.links[value] if (knownLink ~= nil) then result = result .. "" .. p.markup(value) .. "" else result = result .. p.markup(value) end end end return result end

return p