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

From blackwiki
Jump to navigation Jump to search
test>Crissov
test>Crissov
(Lua patterns are much more restricted than I knew)
Line 1: Line 1:
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|(%d+|x)|{{#switch:%1|0=₀|1=₁|2=₂|3=₃|4=₄|5=₅|6=₆|7=₇|8=₈|9=₉|10=₁₀|11=₁₁|12=₁₂|13=₁₃|14=₁₄|15=₁₅|16=₁₆|17=₁₇|18=₁₈|19=₁₉|x=ₓ|#default=<sub style="font-variant-position:sub">%0</sub>}}|plain=0}}<noinclude>
+
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|[0123456789x]+|{{#switch:%1|0=₀|1=₁|2=₂|3=₃|4=₄|5=₅|6=₆|7=₇|8=₈|9=₉|10=₁₀|11=₁₁|12=₁₂|13=₁₃|14=₁₄|15=₁₅|16=₁₆|17=₁₇|18=₁₈|19=₁₉|x=ₓ|#default=<sub style="font-variant-position:sub">%0</sub>}}|plain=0}}<noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 19:36, 11 May 2016

This template requires an unnamed parameter (plain text molecule representation to format as wikitext).

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.