Chem is a plugin for Obsidian.md providing chemistry support. It allows you to insert chemical structures into your notes through code blocks containing SMILES strings (powered by Smiles Drawer & RDKit.js).
Note
Latest release: 0.4.1
Document version: 0.4.1
You can use this plugin to render chemical structures from SMILES strings. Just type the SMILES strings in a code block with smiles
as the language. Each line should contain only one string.
The data is stored as plain text, so you won’t lose it. The renderer will always work, even if the plugin changes its cheminfo core.
You can enable inline render feature in plugin settings. Code lines with specified prefix would be recognized. The default syntax is $smiles=C1=CC=CC=C1
and the prefix is configurable.
You can adjust the structure scale or the image size and configure light/dark themes of the structure images in the plugin’s settings page. The structures in open notes will be automatically updated when the plugin settings or Obsidian color scheme are changed.
The copy feature is accessible through the right-click menu on images. Images are copied in png
format. Despite common applications, you can also paste the copied image into your note, which will then save the image as a file to your attachment folder. The scale of the export, transparency, and theme can be configured to suit your needs.
Inline Dataview queries and DataviewJS rendering can be enabled in the settings tab. Once enabled, lines within the smiles block will be checked and parsed. The return values from this process will be used to render chemical structures, providing greater flexibility. The prefix and strategy are fetched directly from the corresponding Dataview plugin settings.
Warning
This feature is dependent on the Dataview plugin. Please ensure that you have installed and enabled it.
The execution of DataviewJS is implemented by calling eval()
at the bottom, which is known to have security issues. To avoid unintended execution, only trusted code lines should be passed.
If you wish to keep inline Dataview queries rendering and only disable DataviewJS, you can toggle off the Enable JavaScript Queries
or Enable Inline JavaScript Queries
options through the Dataview plugin settings.
SMILES stands for Simplified Molecular-Input Line-Entry System. It is a specification to describe chemical structures using linear ASCII strings. You can learn more about it from the official website or Wikipedia.
Using SMILES strings to represent molecules is easier and more widely supported by chemistry drawing tools than using LaTeX packages like mhchem and chemfig.
For simple structures, you can type them in manually. However, for more complex ones, you may want to use structure editors, such as ChemDraw, ChemDrawJS, MarvinJS and Ketcher. There's a Ketcher editor integration plugin Obsidian Ketcher available right in Obsidian.
Also, you can use translators like Open Babel, JOELib and the Chemical Translation Service to convert chemical names, CAS numbers and *.mol
files into SMILES strings.
Note
Make sure that you are not in the Restricted Mode.
The plugin is available in the official plugin market. You can go to Settings → Community plugins → Browse, and search for the Chem
plugin by Acylation. After installing, you need to enable the plugin to use it.
You can also follow the steps below to install the plugin manually.
- Go to the repo's latest release page, and download the
main.js
,style.css
, andmanifest.json
. Alternatively, you can download the latest zip file and then unzip it to get the three files. - Copy these files to your local path
[yourvault]/.obsidian/plugins/chem/
. You may need to create the folderchem
by yourself. - Launch/restart Obsidian, or refresh the plugin list, you will see this plugin.
- In the plugin list, enable
Chem
and enjoy!
Note
If you want to utilize RDKit.js
, Chem plugin would try to fetch RDKit_minimal
and RDKit_minimal.wasm
files from release. If you have problem connecting GitHub, please download them manully and put them in the directory [yourvault]/.obsidian/plugins/chem/rdkit/
for recognization and loading.
I have a lot of ideas for this plugin, but my coding skills and resources are limited. I want to make it useful for anyone who needs to take notes on chemistry (such as research records, organic chemistry anki cards, etc.). As examples, here are some of the features I have in mind.
- Displaying chemical formulas and structures.
- Importing structures from the clipboard, .cdxml files, etc.
- Appending chemical info (e.g. exact mass) next to the structures. This can help MS users and beginners in chemistry.
- Supporting internal coordinates like .mol files. Would be useful in computational chemistry.
- Shortcuts for physicochemical formulas in LaTeX.
- ......
I'd love to hear your feedback and suggestions. Actually, the first feature of the plugin, to render SMILES strings, was suggested by community users! I’m very grateful for their input. (See the acknowledgment section for details)
Thank you for your interest in contributing to this project! We welcome bug reports, feature requests, and pull requests from anyone. For more information on how to contribute to Chem, check out CONTRIBUTING.md.
Check out the roadmap to see what's been working on.
Chem
plugin is now primarily focused on rendering texts into structures. If you want to create complex structures from scratch, the Ketcher plugin has integrated a powerful opensource editor.
Chemical Structure Renderer is a similar plugin of Chem
, which uses Ketcher, Indigo online service for parsing and rendering, while Chem
plugin integrates standalone packages and runs locally.
The plugin relies on Smiles Drawer and RDKit.js as the parsing and drawing cores, and takes Mathpix as a good example on integrating Smiles Drawer and use codeblock to decorate the note. Thank you very much!
During the whole process of development, I found the developer documentation super helpful. Massive thanks to @marcusolsson for leading this project!
The plugin is motivated by forum requests for including chemical structures in Obsidian. Thank you for the inspiring discussions and the great ideas!
- https://forum.obsidian.md/t/smiles-in-obsidian/35974
- https://forum.obsidian.md/t/structural-formulas-for-chemistry/29366
- https://forum.obsidian.md/t/chemistry-formulas-in-obsidian/25772
- https://forum.obsidian.md/t/obsidian-for-chemistry/33491
- https://forum.obsidian.md/t/how-to-write-chemical-formulas/12249