Novogenesis Wiki:Chem

From Novogenesis_Wiki
Jump to: navigation, search

In an effort to make this easier to use (particularly in templates, which might want to take straight text as input and format it as a chemical expression) as well as improve overall cleanliness of layout, I offer this {{#Chem:...}} parser function. The goal of this tag is to minimize editing errors while producing style-correct output that is easy to read.

Advantages over current systems

Normal subscripting
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Ca3(PO4)2 Nulla dignissim, erat sed iaculis tempor, elit purus elementum sem, eget tristique velit justo vel nulla.
#Chem subscripting
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Ca3(PO4)2 Nulla dignissim, erat sed iaculis tempor, elit purus elementum sem, eget tristique velit justo vel nu lla.

Figure 1

Simple Input Language

Wikipedia's {{chem}} template requires the input to be broken up into its individual segments for display, sometimes including blank spots to maintain the format. Thus what appears as H2SO4 on the screen must be entered as {{chem|H|2|S||O|4}}, which in turn means you can't use "normal" text found on from external sources as input text without heavy modifications. Both of these are substantial sources of accumulated and hard-to-detect error.

  • The chem system takes "normal" text as input: H2SO4 + KClO3 = Boom becomes H2SO4 + KClO3 Boom with no additional work.

Cut and Paste Safe

Wikipedia's {{chem}} template outputs a different syntax than it takes as input. That means cut-and-paste is a non-starter.

  • The chem system outputs the text in the same syntax (for the most part) as it accepts as input, eliminating that error. So "Ca3(PO4)2" (the text copied off the page) slips right into the curly braces: {{#Chem: Ca3(PO4)2}} and is rendered as Ca3(PO4)2. Thus you can copy the text that is output, and directly enter it as input.

ASCII text promotion

Entering special characters via Unicode or html entities is inconvenient.

  • Chem provides visually straightforward shortcuts for common markup characters such as • → and ΔH=

Thinner level-1 subscripting

One difficulty with chemical formulas is that the subscripts cause highly visible differences in line height, as illustrated on the right.

  • The chem system flattens the first level of subscript so that the line height difference is minimized. (See Figure 1)

Two levels of subscripting

The current alternatives directly support only one level of subscripting, so the formula for calcium triphosphate looks like Ca3(PO4)2, which visually clutters the subscript four with the subscript two.

  • The chem system lowers post-paren subscripts a bit further than regular subscripts, resulting in clearer structure: Ca3(PO4)2

Additional Features

Catalyst/Conditions Markup

Using a curly brace to surround the equals sign allows catalysts to be shown above the arrow and unmodified text (for reaction conditions) below it, so

This:
4 NH3 + 5 O2 { Pt9Rh = 4atm, 217°C } 4 NO + 6 H2O
Will render as:
4 NH3 + 5 O2
{Pt9Rh
4atm, 217°C}
4 NO + 6 H2O

Crystal Forms

Various non-chemistry sciences (including geology, glassmaking, and concrete industries) use a bullet-based system instead of parens. This in turn requires numbers to be rendered slightly differently depending on the context. The {{#Chem: }} system handles this simply.

  • 2Al2O3•3SiO2 4 Al + 3 Si + 6 O2
  • 2 Al2O3•3SiO2 4 Al + 6 Si + 9 O2
  • 2 2Al2O3•3SiO2 8 Al + 6 Si + 12 O2

Note that there is an alternative notation which is more clear:

  • 2 2Al2O3•3SiO2 2 (Al2O3)2(SiO2)3

Comments

Placing a // comment initiator allows for completely unmarked text to the end of the line

Markup

  • No line breaks are permitted.
  • All text is in latin sans serif (helvetica, arial, or the default sans-serif font). This violates the Wikipedia style, which mandates roman (serif) fonts.
Rule Pattern Handling Input Output
Capital letters and Capital-lowercase pairs [A-Z][a-z]? Not marked up PbS PbS
Leading numbers [0-9]+ Unchanged, followed by a space 2HCl 2 HCl
Numbers following an element [0-9]+ Subscripted H2O H2O
Numbers following a close-paren [0-9]+ Deeply subscripted Ca3(PO4)2 Ca3(PO4)2
Plus + Unchanged, prefixed and suffixed with a space. H2SO4+KClO3 H2SO4 + KClO3
ASCII arrows and equals ==>
-->
<=>
<->
=
Converted to a 50% oversized right/horizontal arrow with spaces before and after. 2P2-->P4 2 P2 P4
equals within curly braces { catalysts = conditions } Converted to an arrow long enough to contain the upper and lower text, sandwiched between that text EtOH + AcH { H2SO4 = 100°C, 1atm } Ethyl Acetate EtOH + AcH
{H2SO4
100°C, 1atm}
Ethyl Acetate
Star * Converted to a bullet: "•". SiO2*Al2O3 SiO2•Al2O3
Comment // normal text Retain the comment without markup
Delta H dH= Convert the d to Δ dH=-1407kJ/mol ΔH=-1407kJ/mol
Everything else Not marked up
(Caveat: phase, charge and other notation may be added)
This is a test This is a test

See Also