Difference between revisions of "Template:Chem2/testcases"

From blackwiki
Jump to navigation Jump to search
imported>DePiep
(linee wrap test)
imported>DePiep
Line 403: Line 403:
 
|}
 
|}
  
Please, fix. {{serif|I}}’m lazy to investigate because have no privilege to edit many templates on this site. [[User:Incnis Mrsi|Incnis Mrsi]] ([[User talk:Incnis Mrsi|talk]]) 19:53, 16 August 2019 (UTC)
 
::Noting for ping purposes that this is a continuation or more limited case than [[User:Jorge Stolfi|Jorge Stolfi]]'s thought in [[#Bad line breaks]]. [[User:DMacks|DMacks]] ([[User talk:DMacks|talk]]) 16:12, 17 August 2019 (UTC)
 
  
:The template here is a wrapper around the real functionality in {{module|Chem2}}. Keeping a chemical formula together is pretty important. But <code>&lt;[[Span and div|div]] class="nowrap"></code> around the whole result is not sufficient—see my first additional example. Using <code>&lt;[[Span and div|span]] class="nowrap"></code> (equivalent to {{tl|nowrap}}), my second example seems better in that regard. But I think we ''do'' want to allow breaking at whitespace, as in a chemical equation rather than just a single formula as in my third example. Even {{tl|wbr}} doesn't seem to allow breaking, despite what that template indicates.
 
:
 
:It seems heavy-handed to wrap each non-space chunk in the formula with its own <code>span</code>. Is there a CSS way to allow breaking ''only'' at whitespace (not at other word-breaks)? [[User:DMacks|DMacks]] ([[User talk:DMacks|talk]]) 16:10, 17 August 2019 (UTC)
 
:: Why namely CSS? A sane HTML code should be generated, not one full of loopholes for bad wrapping. Normally it’s a bad idea to permit one “word” (compound) to be broken, but for long ones—IMHO for cases even longer than examples below—a very thin space can be inserted in places where wrapping is tolerable. See below examples based on U+2009 space. [[User:Incnis Mrsi|Incnis Mrsi]] ([[User talk:Incnis Mrsi|talk]]) 17:04, 17 August 2019 (UTC)
 
 
{| class=wikitable
 
{| class=wikitable
 
! colspan=2 | Table 2  
 
! colspan=2 | Table 2  

Revision as of 11:37, 11 September 2019

from Doc

{{Chems}}
Symbol Gives Example Output
\s {{chem2|CH3\sCH3}} CH
3
−CH
3
\d = {{chem2|CH2\dCH2}} CH
2
=CH
2
\t {{chem2|HC\tCH}} HC≡CH
\q {{chem2|[Cl4Re\qReCl4](2−)|}} [Cl
4
Re≣ReCl
4
]2−
\- -
\\ \
\h η
\h{1} η1-
\m{1} μ1-
-> {{chem2|2H2 + O2 -> 2H2O}} 2H
2
+ O
2
→ 2H
2
O
<->
* · {{chem2|CoCl2*6H2O}} CoCl
2
·6H2O
\* * {{chem2|Cp\*2Fe}} Cp*
2
Fe
_{} {{chem2|CH4_{(g)}|}} * CH
4

(g)
^{} {{chem2|^{13}CH4}} 13
CH
4
&nabla; {{chem2|&nabla;}}

^ If the last character of the template input is }, MediaWiki will confuse it with the end-of-template tag }}. Adding | between the two resolves this ambiguity. Other options include instead inserting (space), {{null}} or <nowiki/>.

Formulas (without charge) are just written. Eg.:

  • {{chem2|CH3(CH2)5CH3}} gives CH
    3
    (CH
    2
    )
    5
    CH
    3
  • {{chem2|Fe3S2(CO)9}} gives Fe
    3
    S
    2
    (CO)
    9
  • {{chem2|C_{''n''}H_{2''n''+2}|}} gives C
    n
    H
    2n+2

Charges are written inside parenthesis, otherwise its treated as +1 or −1, e.g.:

  • {{chem2|Na+}} gives Na+
  • {{chem2|O2-}} gives O
    2
    but can be written as {{chem2|O2(-)}} too.
  • {{chem2|SO4(2-)}} gives SO2−
    4
  • {{chem2|S19(2+)}} gives S2+
    19

Chemical equations can be written too. E.g.:

  • {{chem2|2 S + 3 O2 + 2 H2O -> 2 H2SO4}} gives 2 S + 3 O
    2
    + 2 H
    2
    O → 2 H
    2
    SO
    4
  • {{chem2|2S + 3O2 + 2H2O -> 2H2SO4}} gives 2S + 3O
    2
    + 2H
    2
    O → 2H
    2
    SO
    4

The arrows can be written as -> or just . All characters (and unicode markup) are valid input except \, = (Mediawiki use it), _ and - (endash etc.)

  • {{chem2|2 H2_{(g)} + O2_{(g)} -> 2H2O_{(g)}|}} gives 2 H
    2

    (g)
    + O
    2

    (g)
    → 2H
    2
    O
    (g)
  • {{chem2|NH2RCHCO2H <-> NH3+RCHCO2-}} gives NH
    2
    RCHCO
    2
    H ⇌ NH+
    3
    RCHCO
    2

Hapticity and mu:

  • {{chem2|W(CO)3(PiPr3)2(\h{2}\-H2)}} gives W(CO)
    3
    (PiPr
    3
    )
    2
    2--H
    2
    )
  • {{chem2|auto=yes|W(CO)3(PiPr3)2(\h{2}\-H2)}} gives W(CO)
    3
    (PiPr
    3
    )
    2
    (η2--H
    2
    )

Links: Use link=<wiki page> or ordinary wiki link ([[ and ]]), e.g.:

  • {{chem2|link=Iron(III) chloride|FeCl3}} gives FeCl
    3
  • {{chem2|3[[hydrogen|H2]] + 2[[nitrogen|N2]] <-> 2[[ammonia|NH3]]}} gives 3H
    2
    + 2N
    2
    ⇌ 2NH
    3

Auto links: Automatic link elements: Use auto=<something> (e.g. yes):

  • {{chem2|auto=yes|CH3CH2CH3CBrFCIClCH3}} gives CH
    3
    CH
    2
    CH
    3
    CBrFCIClCH
    3

All \sandbox

{{Chems\sandbox}}
Symbol Gives Example Output
\s Template:Chem2\sandbox {{chem2\sandbox|CH3\sCH3}} Template:Chem2\sandbox
\d Template:Chem2\sandbox {{chem2\sandbox|CH2\dCH2}} Template:Chem2\sandbox
\t Template:Chem2\sandbox {{chem2\sandbox|HC\tCH}} Template:Chem2\sandbox
\q Template:Chem2\sandbox {{chem2\sandbox|[Cl4Re\qReCl4](2−)|}} Template:Chem2\sandbox
\- Template:Chem2\sandbox
\\ Template:Chem2\sandbox
\h Template:Chem2\sandbox
\h{1} Template:Chem2\sandbox
\m{1} Template:Chem2\sandbox
-> Template:Chem2\sandbox {{chem2\sandbox|2H2 + O2 -> 2H2O}} Template:Chem2\sandbox
<-> Template:Chem2\sandbox
* Template:Chem2\sandbox {{chem2\sandbox|CoCl2*6H2O}} Template:Chem2\sandbox
\* * {{chem2\sandbox|Cp\*2Fe}} Template:Chem2\sandbox
_{} {{chem2\sandbox|CH4_{(g)}|}} * Template:Chem2\sandbox
^{} {{chem2\sandbox|^{13}CH4}} Template:Chem2\sandbox
&nabla; Template:Chem2\sandbox {{chem2\sandbox|&nabla;}} Template:Chem2\sandbox

^ If the last character of the template input is }, MediaWiki will confuse it with the end-of-template tag }}. Adding | between the two resolves this ambiguity. Other options include instead inserting (space), {{null}} or <nowiki/>.

Formulas (without charge) are just written. Eg.:

Charges are written inside parenthesis, otherwise its treated as +1 or −1, e.g.:

Chemical equations can be written too. E.g.:

The arrows can be written as -> or just . All characters (and unicode markup) are valid input except \, = (Mediawiki use it), _ and - (endash etc.)

Hapticity and mu:

Links: Use link=<wiki page> or ordinary wiki link ([[ and ]]), e.g.:

Auto links: Automatic link elements: Use auto=<something> (e.g. yes):

Examples






Special





More
Examples






Special





More

Line wrapping

Unexpected wrapping

Table 1: Incnis Mrsi original post demo
(extended by DMacks)
Incnis
Mrsi's
original
Running
text
class=
"nowrap"
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
CO2−
3
DMacks's
additions
C
6
H
12
O
6
C
6
H
12
O
6
C
6
H
12
O
6
C
6
H
12
O
6
2H
2
+ O
2
→ 2H
2
O
Template:Wbr+heat
2H
2
+ O
2
→ 2H
2
O
Template:Wbr+heat


Table 2
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
C2H5 OH
CH3 COO
Attention!
It is not {{chem2}},
it is HTML.