Difference between revisions of "Template:Format molecular formula/sandbox"

From blackwiki
Jump to navigation Jump to search
test>Crissov
m (Lua has no switch statement and %0 or %1 is not handed over to {{#switch}})
test>Crissov
Line 1: Line 1:
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|[0123456789x]|function (match)  
+
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|[0-9x]|function (match)  
   if match == "0" then
+
   if match == '0' then
     return "";  
+
     return '';  
   else if match == "1" then
+
   else if match == '1' then
 
+
     return '';  
     return "";  
+
   else if match == '2' then
   else if match == "2" then
+
     return '';  
 
+
   else if match == '3' then
     return "";  
+
     return '';  
   else if match == "3" then
+
   else if match == '4' then
 
+
     return '';  
     return "";  
+
   else if match == '5' then
   else if match == "4" then
+
     return '';  
 
+
   else if match == '6' then
     return "";  
+
     return '';  
   else if match == "5" then
+
   else if match == '7' then
 
+
     return '';  
     return "";  
+
   else if match == '8' then
   else if match == "6" then
+
     return '';  
 
+
   else if match == '9' then
     return "";  
+
     return '';  
   else if match == "7" then
+
   else if match == 'x' then
 
+
     print '';  
     return "";  
 
   else if match == "8" then
 
 
 
     return "";  
 
   else if match == "9" then
 
 
 
     return "";  
 
   else if match == "x" then
 
 
 
     return "";  
 
 
   else     
 
   else     
 
+
     print '<sub style="font-variant-position:sub">' .. match .. '</sub>';  
     return "<sub style='font-variant-position:sub'>match</sub>";  
 
 
   end
 
   end
 
end|plain=0}}<noinclude>
 
end|plain=0}}<noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 11:13, 12 May 2016

This template requires an unnamed parameter (plain tet molecule representation to format as wikitet).

50px Template documentation[view] [edit] [history] [purge]

Usage

{{Format molecular formula|H2O}} gives the molecular formula for water (H2O).

Example arguments: H2O (above), CO2 (CO2), H6C2O (H6C2O), H2SO4 (H2SO4).

The Lua module just puts "<sub></sub>" tags in the wanted spots.

Similar templates

{{Format ion formula}}, for ion chemical formulas.