A markdown-it plugin for rendering SMILES chemical structures
Render chemical structures in dedicated blocks with customizable options
Embed molecular structures directly within text paragraphs
Support both client-side and server-side rendering with renderAtParse option
Control size, styling, and rendering options for each structure
```smiles CCO ```
```smiles {"width": 400, "height": 300, "bondThickness": 1.2} C1CCCCC1 ```
```smiles {"width": 500, "height": 350, "theme": "dark"} CC(C)(C)c1ccc(O)cc1 ```
```smiles {"width": 300, "height": 250, "bondLength": 20, "atomVisualization": "balls"} c1ccccc1 ```
The molecule $smiles{CCO} is ethanol, while $smiles{C1CCCCC1} is cyclohexane.
Caffeine $smiles{CN1C=NC2=C1C(=O)N(C(=O)N2C)C}{"width": 100, "height": 80} is a stimulant found in coffee.
# Organic Chemistry Examples ## Simple Alcohols The simplest alcohol is $smiles{CO} (methanol), followed by $smiles{CCO} (ethanol). ## Aromatic Compounds ```smiles {"width": 350, "height": 280} c1ccccc1 ``` Benzene is the fundamental aromatic compound with the molecular formula CโHโ. ## Complex Molecules Aspirin has the structure $smiles{CC(=O)OC1=CC=CC=C1C(=O)O} and is widely used as a pain reliever.
npm install markdown-it-smiles
import MarkdownIt from 'markdown-it'
import { MarkdownItSmiles } from 'markdown-it-smiles'
const md = new MarkdownIt().use(MarkdownItSmiles)
const result = md.render(`
# Chemical Structure
\`\`\`smiles
CCO
\`\`\`
`)
const md = new MarkdownIt().use(MarkdownItSmiles, {
renderAtParse: false, // Client-side rendering
smilesDrawerOptions: {
default: {
width: 400,
height: 300,
theme: 'light'
},
inline: {
width: 50,
height: 50
},
block: {
width: 500,
height: 400,
bondThickness: 1.2
}
}
})
# Block SMILES
\`\`\`smiles
CCO
\`\`\`
# Block SMILES with options
\`\`\`smiles {"width": 400, "height": 300, "theme": "dark"}
C1CCCCC1
\`\`\`
# Inline SMILES
The molecule $smiles{CCO} is ethanol.
# Inline SMILES with parameters
Caffeine $smiles{CN1C=NC2=C1C(=O)N(C(=O)N2C)C}{"width": 80, "height": 60} structure.