Dokuwiki for science

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

chem_plugin [2016/10/31 00:07] (現在)
ライン 1: ライン 1:
 +======Chem plugin======
 +This DokuWiki plugin formats a molecular formula by using '​chem'​ tag.
 +
 +|  [[https://​github.com/​iobataya/​dokuwiki-plugin-chem|Repository at GitHub]] ​ |  [[https://​github.com/​iobataya/​dokuwiki-plugin-chem/​archive/​master.zip|Download]] ​ |
 +
 +
 +=====Examples=====
 +^  Appearance ​                 ^  DokuWiki code                   ​^ ​ memo  ^
 +|  <​chem>​C2H6</​chem> ​           |  %%<​chem>​C2H6</​chem>​%% ​           | |
 +|  <​chem>​Na2HPO4 12H2O</​chem> ​  ​| ​ %%<​chem>​Na2HPO4 12H2O</​chem>​%% ​  | |
 +|  <​chem>​Al2(SO4)3</​chem> ​      ​| ​ %%<​chem>​Al2(SO4)3</​chem>​%% ​      ​|Using brackets|
 +|  <​chem>​C2H5O2|-Na+</​chem> ​    ​| ​ %%<​chem>​C2H5O2|-Na+</​chem>​%% ​    ​|Inserted a pipe before a formal charge.|
 +|  <​chem>​Cl2H6N2Pt2+</​chem> ​    ​| ​ %%<​chem>​Cl2H6N2Pt2+</​chem>​%% ​    ​|Formal charge number before +/-.|
 +|  <​chem>​[(C6H4)2]4|12+</​chem> ​ |  %%<​chem>​[(C6H4)2]4|12+</​chem>​%% ​ |Using several combinations|
 +
 +
 +**Usage of seperation between atom-numbers and charge-numbers**
 +
 +^  Appearance ​                 ^  code                   ​^ ​ memo  ^
 +|  <​chem>​SO4|2-</​chem> ​        ​| ​ %%<​chem>​SO4|2-</​chem>​%% ​ | Correctly formated|
 +|  <​chem>​SO42-</​chem> ​         |  %%<​chem>​SO42-</​chem>​%% ​  | Needs a pipe between 4 and 2.|
 +|  <​chem>​SO4 2-</​chem> ​        ​| ​ %%<​chem>​SO4 2-</​chem>​%% ​ | Undesired white space|
 +
 +
 +=====Installation=====
 +You can install by using '​Manager Plugins'​ in Admin tools.
 +Download URL is available at https://​www.dokuwiki.org/​plugin:​chem.
 +
 +===== History =====
 +  *2013-01-20 Source code was moved to [[https://​github.com/​iobataya/​dokuwiki-plugin-chem|GitHub]].
 +  *2008-09-29 Supported the Open document format export using [[http://​www.dokuwiki.org/​plugin:​odt|ODT plugin]].
 +  *2008-03-21 Seperator implementation and bracket support
 +
 +===== DISCUSSION =====
 +==== Kibi's bug-fix ====
 +(Kibi posted bug-fix and made some extension for isotope expression in the previous system of DW. Since a '​discussion plugin'​ is not deployed in this current DW, I pasted his/her comment here. Thanks, Kibi  --- //i.obataya 2009/11/11 19:17//)
 +
 +I've made some improvements to your plugin: now it can handle not only charge number of ion, but oxidation state: <​chem>​N-3,​ N-1, N0, N+1, N+3, H2|+1S+6O3|-2S-2</​chem>​
 +
 +Fixed error with "​+"​ in equation: <​chem>​2H2 + O2 => 2H2O</​chem>​
 +
 +Fixed error with alternative formulas like <​chem>​Anion2Cation3</​chem>​
 +
 +Added support of isotope numbers: <​chem>​238^U,​ 2|239^Pu</​chem>​
 +
 +All you need is replace function **getChemFormat** with that:
 +<code php>
 +  function getChemFormat($raw){
 +    $pattern = array("/​([A-Za-z\]\)]+)(0)/",​ "/​[\|]?​([0-9]*)[\^]/",​ "/([^ ][\]\)]?​)[\|]?​(([\-\+][0-9]*)|([0-9]*[\-\+]))/",​ "/​([A-Z]|[a-z]|\)|\])([1-9][0-9]*)/"​);​
 +    $replace = array("​\${1}<​sup>​\${2}</​sup>",​ "<​sup>​\${1}</​sup>",​ "​\${1}<​sup>​\${2}</​sup>","​\${1}<​sub>​\${2}</​sub>"​);​
 +    return preg_replace($pattern,​$replace,​$raw);​
 +  }
 +</​code>​
 +
 +The examples ahead would be like this:
 +  * oxidation state: N<​sup>​-3</​sup>,​ N<​sup>​-1</​sup>,​ N<​sup>​0</​sup>,​ N<​sup>​+1</​sup>,​ N<​sup>​+3</​sup>,​ H<​sub>​2</​sub><​sup>​+1</​sup>​S<​sup>​+6</​sup>​O<​sub>​3</​sub><​sup>​-2</​sup>​S<​sup>​-2</​sup>​
 +  * "​+"​ in equation: 2H<​sub>​2</​sub>​ + O<​sub>​2</​sub>​ ⇒ 2H<​sub>​2</​sub>​O
 +  * alternative formulas like Anion<​sub>​2</​sub>​Cation<​sub>​3</​sub>​
 +  * isotope numbers: <​sup>​238</​sup>​U,​ 2<​sup>​239</​sup>​Pu
 +
 +
 +{{tag>​Chemistry DokuWiki plugin}}