User Tools

Site Tools


DokuWiki plugins

There are DokuWiki plugins for research & education which I developed. All plugins are under GPL2 license, so feel free to use them in your DokuWiki.

Dokuwiki Official

Scientific plugins

DokuWiki plugins for bioscience and biotechnology.

General plugins


Chem plugin

This DokuWiki plugin formats a molecular formula by using 'chem' tag.


Appearance DokuWiki code memo
C2H6 <chem>C2H6</chem>
Na2HPO4 12H2O <chem>Na2HPO4 12H2O</chem>
Al2(SO4)3 <chem>Al2(SO4)3</chem> Using brackets
C2H5O2-Na+ <chem>C2H5O2|-Na+</chem> Inserted a pipe before a formal charge.
Cl2H6N2Pt2+ <chem>Cl2H6N2Pt2+</chem> Formal charge number before +/-.
[(C6H4)2]412+ <chem>[(C6H4)2]4|12+</chem> Using several combinations

Usage of seperation between atom-numbers and charge-numbers

Appearance code memo
SO42- <chem>SO4|2-</chem> Correctly formated
SO42- <chem>SO42-</chem> Needs a pipe between 4 and 2.
SO4 2- <chem>SO4 2-</chem> Undesired white space


You can install by using 'Manager Plugins' in Admin tools. Download URL is available at


  • 2013-01-20 Source code was moved to GitHub.
  • 2008-09-29 Supported the Open document format export using ODT plugin.
  • 2008-03-21 Seperator implementation and bracket support


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: N-3, N-1, N0, N+1, N+3, H2+1S+6O3-2S-2

Fixed error with “+” in equation: 2H2 + O2 ⇒ 2H2O

Fixed error with alternative formulas like Anion2Cation3

Added support of isotope numbers: 238U, 2239Pu

All you need is replace function getChemFormat with that:

  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);

The examples ahead would be like this:

  • oxidation state: N-3, N-1, N0, N+1, N+3, H2+1S+6O3-2S-2
  • “+” in equation: 2H2 + O2 ⇒ 2H2O
  • alternative formulas like Anion2Cation3
  • isotope numbers: 238U, 2239Pu
Translations of this page:
chem_plugin.txt · Last modified: 2016/10/31 09:07 by swadmin