Module:Chem:修订间差异

化学式
 
已保护“Module:Chem”:​常用模板([编辑=仅允许管理员](无限期)[移动=仅允许管理员](无限期))
 
(未显示5个用户的8个中间版本)
第2行: 第2行:


function p.chem(frame)
function p.chem(frame)
   local chemstr=frame.args[1]
   local args=frame:getParent().args
   if not chemstr then return end
   --local args=frame
  local chemstr=""
  for i, v in pairs(args) do
    if type(i)=="number" then
      chemstr=chemstr .. v
    else
      chemstr=chemstr .. i .. "=" .. v
    end
  end
   chemstr=mw.ustring.gsub(chemstr, "%s", "")
   chemstr=mw.ustring.gsub(chemstr, "%s", "")


第16行: 第24行:
     if ch=="." or ch=="·" then
     if ch=="." or ch=="·" then
       table.insert(res, "·")
       table.insert(res, "·")
      norm=true
    elseif ch=="=" then
      table.insert(res, "=")
       norm=true
       norm=true
     elseif ch=="^" then
     elseif ch=="^" then
第55行: 第66行:
   end
   end


   return mw.html.create("p"):wikitext(table.concat(res))
   return mw.html.create("span"):wikitext(table.concat(res))
end
end


return p
return p