Difference between revisions of "Template:Format molecular formula"

From blackwiki
Jump to navigation Jump to search
test>Jackmcbarn
(Undid revision 686543038 by Luis150902 (talk): As far as I can tell, this just added an unnecessary ifeq and level of nesting. If there were ever any ambiguous cases, please explain them)
test>Crissov
(support x and y indices as in NOx, <sub style="font-variant-position:sub">)
Line 1: Line 1:
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|%d+|<sub>%0</sub>|plain=0}}<noinclude>{{Documentation}}</noinclude>
+
{{{{{|safesubst:}}}#invoke:String|replace|{{{1|'''This template requires an unnamed parameter (plain text molecule representation to format as wikitext).'''}}}|(%u%l?)([%dxy]+)|%1<sub style="font-variant-position:sub">%2</sub>|plain=0}}<noinclude>{{Documentation}}</noinclude>

Revision as of 11:29, 12 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 (O).

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

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

Similar templates

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