English | 简体中文
Table of Contents
Render the chemical formula of SVG format in the browser, using the accurate Cuiping formula syntax.
You can experience the demo at icelava.top:
- Try to input Cuiping formula and view rendered results in real time
- Save the formulas you tried to browser
- Modify the rendering configuration at any time
- Check some preset examples and edit them
- Hover over the rendering result to copy Cuiping formula or download SVG images
-
Use your familiar package manager to install the core package
cuiping.$ pnpm i cuiping $ yarn add cuiping $ npm i cuiping
-
Use TypeScript.
import { render } from 'cuiping' const molecule = getMolecule() // Assume to obtain Cuiping formula from user input. const data = render(molecule, { onError: err => { console.warn(err) // Handling errors. }, renderer: 'svg', // Only SVG rendering mode is supported currently. rendererOptions: { /*...*/ } // Render configuration, see below. }) if (data) { // SVG rendering results will be obtained if there is no error. showSvg(data.svg) // Show SVG to the user. }
| Options | Type | Description |
|---|---|---|
unitLen |
integer | Unit length |
paddingX |
integer | X padding |
paddingY |
integer | Y padding |
displayBonds |
boolean | Whether to display bonds |
bondGap |
integer | Gap between double/triple bonds |
lineBaseColor |
string | Base color of lines |
textBaseColor |
string | Base color of text |
halfFontSize |
integer | Half font size |
halfTextBoxWidth |
integer | Half width of text boxes |
halfTextBoxHeight |
integer | Half height of text boxes |
displayTextBox |
boolean | Whether to show text boxes |
See component document.
We use ESLint to unify code style and run checks by Husky and GitHub Action.
The development plan of this project can be found on Notion.
- Clone the code repository in your familiar way.
$ git clone https://github.com/ForkKILLET/Cuiping.js $ gh repo clone ForkKILLET/Cuiping.js
- Use pnpm to install dependencies.
$ pnpm i
- Start the main building job.
Or start package-level building job separately, using workspace.
$ pnpm build
Or$ pnpm -F {cuiping,cuiping-component,cuiping-frontend}cdinto package directories and start package-level building job.$ cd {backend,component,frontend} $ pnpm build
- Test the backend only.
You may set environment variable to enable debug.
$ cd backend $ pnpm build:run$ DEBUG=1 pnpm build:run
- Test all functions in the frontend. (recommended)
Development mode:Production mode:$ cd frontend $ pnpm dev$ cd frontend $ pnpm build $ pnpm preview - You may set
cuipingDebuginlocalStorageto enable debug.localStorage.cuipingDebug = 1
Please use ng style for commit message.
You may refer to git log.
This project is open source under MIT license.